Whlabel.php 259 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->load->library('session');
  8. $this->load->_model('Model_whlabel', 'whlabel');
  9. $this->load->_model('Model_warehouse', 'warehouse');
  10. $this->load->_model('Model_purchase', 'purchase');
  11. $this->load->_model('Model_excel', 'excel');
  12. $this->load->_model('Model_fullorder', 'fullorder');
  13. $this->load->_model('Model_fullordertt', 'fullordertt');
  14. $this->load->_model('Model_fullorderamz', 'fullorderamz');
  15. $this->load->_model('Model_fullorder_smt', 'fullorder_smt');
  16. $this->load->_model('Model_fullordersmt', 'fullordersmt');
  17. $this->load->_model('Model_express', 'express');
  18. $this->load->_model('Model_shop', 'shop');
  19. $this->load->_model('Model_typeclass', 'typeclass');
  20. $this->load->_model('Model_country', 'country');
  21. $this->load->_model('Model_warehouse', 'warehouse');
  22. $this->load->_model('Model_kdniao', 'kdniao');
  23. $this->load->_model('Model_notice', 'notice');
  24. $this->load->_model('Model_dhl', 'dhl');
  25. $this->load->_model('Model_shop', 'shop');
  26. $this->load->_model('Model_fullorderexcel', 'fullorderexcel');
  27. $this->load->_model('Model_ljg', 'ljg');
  28. $this->load->_model('Model_usps', 'usps');
  29. $this->load->_model('Model_specialstock', 'specialstock');
  30. $this->load->_model('Model_whlabellabel', 'whlabellabel');
  31. $this->load->_model('Model_whlabelwz', 'whlabelwz');
  32. $this->load->_model('Model_whlabelbarcode', 'whlabelbarcode');
  33. $this->load->_model('Model_whlabeltransport', 'whlabeltransport');
  34. $this->load->_model('Model_orderurl', 'orderurl');
  35. $this->load->_model('Model_brand', 'brand');
  36. $this->load->_model('Model_classid', 'classid');
  37. $this->load->_model('Model_apiyy', 'apiyy');
  38. $this->load->_model('Model_power', 'power');
  39. $this->load->_model('Model_whlabel_type', 'whlabel_type');
  40. $this->load->_model('Model_company', 'company');
  41. $this->load->_model('Model_whlabel_list', 'whlabel_list');
  42. $this->load->_model("Model_logic_whlabel", "logic_whlabel");
  43. $this->load->_model("Model_logic_order","logic_order");
  44. $this->load->_model("Model_logic_ding","logic_ding");
  45. }
  46. //定义方法的调用规则 获取URI第二段值
  47. public function _remap($arg, $arg_array)
  48. {
  49. if ($arg == 'existence') //在库标签
  50. {
  51. $this->_existence();
  52. } else if ($arg == 'cpbqdc') //在库标签
  53. {
  54. $this->_cpbqdc();
  55. } else if ($arg == 'type') //进销存浏览
  56. {
  57. $this->_type();
  58. } else if ($arg == 'typedy') //进销存浏览店员页面
  59. {
  60. $this->_typedy($arg_array);
  61. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  62. {
  63. $this->_typedy_ck($arg_array);
  64. } else if ($arg == 'typeck') {
  65. $this->_typeck($arg_array);
  66. } else if ($arg == 'whlabeckdc') {
  67. $this->_whlabeckdc($arg_array);
  68. } else if ($arg == 'usatype') //美仓进销存浏览
  69. {
  70. $this->_usatype();
  71. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  72. {
  73. $this->_usatypeapp();
  74. } else if ($arg == 'enteradd') //入库操作
  75. {
  76. $this->_enteradd();
  77. } else if ($arg == 'enteredit') //修改
  78. {
  79. $this->_enteredit($arg_array);
  80. } else if ($arg == 'enter') //入库浏览
  81. {
  82. $this->_enter();
  83. } else if ($arg == 'out') //出库浏览
  84. {
  85. $this->_out();
  86. } else if ($arg == 'label') //出库标签浏览
  87. {
  88. $this->_label();
  89. } else if ($arg == 'outorder') //独立站出库订单
  90. {
  91. $this->_outorder();
  92. } else if ($arg == 'soutorder') //速卖通出库订单
  93. {
  94. $this->_soutorder();
  95. } else if ($arg == 'toutorder') //TT出库订单
  96. {
  97. $this->_toutorder();
  98. }else if ($arg == 'aoutorder') //amz出库订单
  99. {
  100. $this->_aoutorder();
  101. } else if ($arg == 'retreat') //退库订单
  102. {
  103. $this->_retreat();
  104. } else if ($arg == 'retreatlk') //退库订单
  105. {
  106. $this->_retreatlk();
  107. } else if ($arg == 'change') //更换标签
  108. {
  109. $this->_change();
  110. } else if ($arg == 'del') //删除
  111. {
  112. $this->_del();
  113. } else if ($arg == 'exceljxc') //进销存信息导出
  114. {
  115. $this->_exceljxc();
  116. } else if ($arg == 'excelr') //入库信息导出
  117. {
  118. $this->_excelr();
  119. } else if ($arg == 'excelct') //出库、退库信息导出
  120. {
  121. $this->_excelct();
  122. } else if ($arg == 'dccrtype') //根据出入库类型导出
  123. {
  124. $this->_dccrtype();
  125. } else if ($arg == 'excelcr') //出库、退库信息导出
  126. {
  127. $this->_excelcr();
  128. } else if ($arg == 'kcyz') //库存验证
  129. {
  130. $this->_kcyz();
  131. } else if ($arg == 'kj') //库存扣减
  132. {
  133. $this->_kj($arg_array);
  134. } else if ($arg == 'presetout') //预设库存导入
  135. {
  136. $this->_presetout($arg_array);
  137. } else if ($arg == 'presetedit') //预设库存导入
  138. {
  139. $this->_presetedit($arg_array);
  140. } else if ($arg == 'summary') //汇总导出
  141. {
  142. $this->_summary($arg_array);
  143. } else if ($arg == 'manifest') //usps发货清单
  144. {
  145. $this->_manifest();
  146. } else if ($arg == 'abnormal') //占单异常
  147. {
  148. $this->_abnormal();
  149. } else if ($arg == 'error') //0库存SKU
  150. {
  151. $this->_error();
  152. } else if ($arg == 'errorexcel') //0库存SKU导出
  153. {
  154. $this->_errorexcel();
  155. } else if ($arg == 'db') {
  156. $this->_db();
  157. } else if ($arg == 'dbrk') {
  158. $this->_dbrk();
  159. } else if ($arg == 'whlabelczdc') {
  160. $this->_whlabelczdc();
  161. } else if ($arg == 'print') {
  162. $this->_print($arg_array);
  163. } else if ($arg == 'usaprint') {
  164. $this->_usaprint($arg_array);
  165. } else if ($arg == 'printck') {
  166. $this->_printck($arg_array);
  167. } else if ($arg == 'printrk') {
  168. $this->_printrk($arg_array);
  169. } else if ($arg == 'printxzrk') {
  170. $this->_printxzrk($arg_array);
  171. } else if ($arg == 'printexcel') {
  172. $this->_printexcel($arg_array);
  173. } else if ($arg == 'uck') {
  174. $this->_uck();
  175. } else if ($arg == 'whlabelexcelzh') {
  176. $this->_whlabelexcelzh();
  177. } else if ($arg == 'fc') {
  178. $this->_fc();
  179. } else if ($arg == 'fcmb') {
  180. $this->_fcmb();
  181. } else if ($arg == 'fcexcel') {
  182. $this->_fcexcel();
  183. } else if ($arg == 'fcjxc') {
  184. $this->_fcjxc($arg_array);
  185. } else if ($arg == '0kcdel') {
  186. $this->_0kcdel(); //导表删除0库存
  187. } else if ($arg == 'gbhtype') {
  188. $this->_gbhtype(); //更改备货状态
  189. } else {
  190. $this->_index();
  191. }
  192. }
  193. //管理
  194. public function _index()
  195. {
  196. $post = $this->input->post(NULL, TRUE);
  197. if (isset($post['page'])) {
  198. $page = $this->input->post('page', true);
  199. $perpage = $this->input->post('perpage', true);
  200. $sku = $this->input->post('sku', true);
  201. $number = $this->input->post('number', true);
  202. $warehouse = $this->input->post('warehouse', true);
  203. $purchase = $this->input->post('purchase', true);
  204. $orderinfo = $this->input->post('orderinfo', true);
  205. $waybill = $this->input->post('waybill', true);
  206. $category = $this->input->post('category', true);
  207. $size = $this->input->post('size', true);
  208. $grade = $this->input->post('grade', true);
  209. $color = $this->input->post('color', true);
  210. $lowe = $this->input->post('lowe', true);
  211. $state = $this->input->post('state', true);
  212. $label = $this->input->post('label', true);
  213. $timetk = $this->input->post('timetkk', true);
  214. $timetj = $this->input->post('timetjj', true);
  215. $timetk = strtotime($timetk);
  216. $timetj = strtotime($timetj);
  217. $where = "1=1 ";
  218. if ($timetk && $timetj) {
  219. $where .= " and time > '$timetk' and time < '$timetj'";
  220. }
  221. if ($sku) {
  222. $where .= " and sku = '$sku'";
  223. }
  224. if ($number) {
  225. $where .= " and number = '$number'";
  226. }
  227. if ($warehouse) {
  228. $where .= " and warehouse = '$warehouse'";
  229. }
  230. if ($purchase) {
  231. $where .= " and purchase = '$purchase'";
  232. }
  233. if ($orderinfo) {
  234. $where .= " and orderinfo = '$orderinfo'";
  235. }
  236. if ($waybill) {
  237. $where .= " and waybill = '$waybill'";
  238. }
  239. if ($category) {
  240. $where .= " and features like '%-$category-%'";
  241. }
  242. if ($size) {
  243. $where .= " and features like '%-$size-%'";
  244. }
  245. if ($grade) {
  246. $where .= " and features like '%-$grade-%'";
  247. }
  248. if ($color) {
  249. $where .= " and features like '%-$color-%'";
  250. }
  251. if ($lowe) {
  252. $where .= " and features like '%-$lowe-%'";
  253. }
  254. if ($label) {
  255. $where .= " and label = '$label'";
  256. }
  257. if ($state != '') {
  258. $where .= " and state = '$state'";
  259. }
  260. //数据排序
  261. $order_str = "time desc";
  262. if (empty($page)) {
  263. $start = 0;
  264. $perpage = 1;
  265. } else {
  266. $start = ($page - 1) * $perpage;
  267. }
  268. //取得信息列表
  269. $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);
  270. foreach ($info_list as $key => $value) {
  271. $warehouse = $this->warehouse->read($value['warehouse']);
  272. $info_list[$key]['warehouse'] = $warehouse['title'];
  273. $purchase = $this->purchase->read($value['purchase']);
  274. $info_list[$key]['purchase'] = $purchase['title'];
  275. if ($value['enter'] != 0) {
  276. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  277. } else {
  278. $info_list[$key]['enter'] = "";
  279. }
  280. if ($value['outk'] != 0) {
  281. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  282. } else {
  283. $info_list[$key]['outk'] = "";
  284. }
  285. if ($value['printing'] != 0) {
  286. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  287. } else {
  288. $info_list[$key]['printing'] = "";
  289. }
  290. if ($value['orderinfo'] == 0) {
  291. $info_list[$key]['orderinfo'] = "";
  292. }
  293. if ($value['waybill'] == 0) {
  294. $info_list[$key]['waybill'] = "";
  295. }
  296. if ($value['state'] == 0) {
  297. $info_list[$key]['state'] = "在库";
  298. } else if ($value['state'] == 1) {
  299. $info_list[$key]['state'] = "出库";
  300. } else if ($value['state'] == 2) {
  301. $info_list[$key]['state'] = "退库";
  302. } else if ($value['state'] == 3) {
  303. $info_list[$key]['state'] = "调拨中";
  304. } else if ($value['state'] == 4) {
  305. $info_list[$key]['state'] = "再加工";
  306. } else if ($value['state'] == 5) {
  307. $info_list[$key]['state'] = "维修中";
  308. } else if ($value['state'] == 6) {
  309. $info_list[$key]['state'] = "盘亏";
  310. } else if ($value['state'] == 7) {
  311. $info_list[$key]['state'] = "更换标签";
  312. } else if ($value['state'] == 8) {
  313. $info_list[$key]['state'] = "其它";
  314. } else if ($value['state'] == 9) {
  315. $info_list[$key]['state'] = "预设";
  316. } else if ($value['state'] == 10) {
  317. $info_list[$key]['state'] = "美店零售";
  318. }
  319. if ($value['text'] == "") {
  320. $info_list[$key]['text'] = "";
  321. }
  322. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  323. }
  324. $total = $this->whlabel->find_count($where);
  325. $pagenum = ceil($total / $perpage);
  326. $over = $total - ($start + $perpage);
  327. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  328. echo json_encode($rows);
  329. exit;
  330. }
  331. if (isset($post['outsku'])) {
  332. $cz = $this->input->post('cz', true);
  333. if ($cz == '1') {
  334. $sku = $this->input->post('outsku', true);
  335. if ($sku) {
  336. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  337. if (count($data) < 1) {
  338. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  339. exit;
  340. }
  341. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 1), $data[0]['id']);
  342. echo json_encode(array('success' => true));
  343. exit;
  344. }
  345. } else {
  346. $sku = $this->input->post('outsku', true);
  347. if ($sku) {
  348. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  349. if (count($data) < 1) {
  350. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  351. exit;
  352. }
  353. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  354. echo json_encode(array('success' => true));
  355. exit;
  356. }
  357. }
  358. }
  359. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  360. $this->_Template('whlabel', $this->data);
  361. }
  362. //在库标签
  363. public function _existence()
  364. {
  365. $post = $this->input->post(NULL, TRUE);
  366. if (isset($post['s'])) {
  367. $id_arr = $this->input->post('s');
  368. $id_arr = explode(',', $id_arr);
  369. if (!$id_arr) {
  370. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  371. exit;
  372. }
  373. //循环删除记录
  374. foreach ($id_arr as $v) {
  375. $sid = $this->whlabel->read($v);
  376. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  377. if ($count > 0) {
  378. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  379. exit;
  380. }
  381. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  382. if (count($zt) > 0) {
  383. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  384. exit;
  385. }
  386. $this->whlabel->remove($v);
  387. }
  388. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  389. exit;
  390. }
  391. if (isset($post['page'])) {
  392. $page = $this->input->post('page', true);
  393. $perpage = $this->input->post('perpage', true);
  394. $warehouse = $this->input->post('warehouse', true);
  395. $label = $this->input->post('label', true);
  396. $where = "1=1 and state = 0";
  397. if ($warehouse) {
  398. $where .= " and warehouse = '$warehouse'";
  399. }
  400. if ($label) {
  401. $where .= " and label = '$label'";
  402. }
  403. //数据排序
  404. $order_str = "time asc";
  405. if (empty($page)) {
  406. $start = 0;
  407. $perpage = 1;
  408. } else {
  409. $start = ($page - 1) * $perpage;
  410. }
  411. //取得信息列表
  412. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  413. foreach ($info_list as $key => $value) {
  414. if ($value['enter'] != 0) {
  415. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  416. } else {
  417. $info_list[$key]['enter'] = "";
  418. }
  419. if ($value['printing'] != 0) {
  420. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  421. } else {
  422. $info_list[$key]['printing'] = "";
  423. }
  424. }
  425. $total = $this->whlabel->find_count($where);
  426. $pagenum = ceil($total / $perpage);
  427. $over = $total - ($start + $perpage);
  428. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  429. echo json_encode($rows);
  430. exit;
  431. }
  432. $this->_Template('whlabel_existence', $this->data);
  433. }
  434. //进销存浏览
  435. public function _typedy($arg_array)
  436. {
  437. $prc = array();
  438. $purchase = $this->purchase->find_all();
  439. foreach ($purchase as $k => $v) {
  440. $prc[$v['id']] = $v['title'];
  441. }
  442. $post = $this->input->post(NULL, TRUE);
  443. if (isset($post['page'])) {
  444. $page = $this->input->post('page', true);
  445. $perpage = $this->input->post('perpage', true);
  446. $category = $this->input->post('category', true);
  447. $size = $this->input->post('size', true);
  448. $grade = $this->input->post('grade', true);
  449. $color = $this->input->post('color', true);
  450. $lowe = $this->input->post('lowe', true);
  451. $sku = $this->input->post('sku');
  452. $title = $this->input->post('title');
  453. $warehouse = $this->input->post('warehouse', true);
  454. $usa = $this->input->post('usa', true);
  455. $purchase = $this->input->post('purchase', true);
  456. $lacetype = $this->input->post('lacetype', true);
  457. $haircap = $this->input->post('haircap', true);
  458. $density = $this->input->post('density', true);
  459. $details = $this->input->post('details', true);
  460. $state = $this->input->post('state', true);
  461. $lacecolor = $this->input->post('lacecolor', true);
  462. $hairnumber = $this->input->post('hairnumber', true);
  463. $cklx = $this->input->post('cklx', true);
  464. $ktime = $this->input->post('ktime', true);
  465. $jtime = $this->input->post('jtime', true);
  466. $sm = $this->input->post('sm', true);
  467. $cpbz = $this->input->post('cpbz', true);
  468. $type = $this->input->post('type', true);
  469. $ktime = strtotime($ktime);
  470. $jtime = strtotime($jtime);
  471. $where = "1=1";
  472. $gj = "";
  473. $ck = "";
  474. if ($usa) {
  475. if (!$warehouse) {
  476. $where .= " and (warehouse = '5' or warehouse = '8')";
  477. }
  478. }
  479. if ($warehouse) {
  480. $where .= " and warehouse = '$warehouse'";
  481. }
  482. if ($details) {
  483. $where .= " and details = '$details'";
  484. }
  485. if ($purchase) {
  486. $where .= " and purchase = '$purchase'";
  487. }
  488. if ($state) {
  489. $where .= " and state = '$state'";
  490. }
  491. if ($lacetype) {
  492. $where .= " and features like '%-$lacetype-%'";
  493. }
  494. if ($category) {
  495. $where .= " and features like '%-$category-%'";
  496. }
  497. if ($size) {
  498. $where .= " and features like '%-$size-%'";
  499. }
  500. if ($grade) {
  501. $where .= " and features like '%-$grade-%'";
  502. }
  503. if ($color) {
  504. $where .= " and features like '%-$color-%'";
  505. }
  506. if ($lowe) {
  507. $where .= " and features like '%-$lowe-%'";
  508. }
  509. if ($haircap) {
  510. $where .= " and features like '%-$haircap-%'";
  511. }
  512. if ($density) {
  513. $where .= " and features like '%-$density-%'";
  514. }
  515. if ($lacecolor) {
  516. $where .= " and features like '%-$lacecolor-%'";
  517. }
  518. if($sm){
  519. $where .= " and sm like '%".$sm."%'";
  520. }
  521. if($cpbz){
  522. $where .= " and cpbz like '%".$cpbz."%'";
  523. }
  524. if($type){
  525. $where .= " and type = ".$type."";
  526. }
  527. if (!empty($hairnumber)) {
  528. $where .= " and features like '%-128-%' ";
  529. if ($hairnumber < 0) {
  530. $class_list = $this->typeclass->find_all('classid = 43');
  531. foreach ($class_list as $v) {
  532. $where .= " and features not like '%-" . $v['id'] . "-%'";
  533. }
  534. } else {
  535. $where .= " and features like '%-$hairnumber-%'";
  536. }
  537. }
  538. $where_add = '';
  539. if ($cklx) {
  540. $shop = $this->shop->read($cklx);
  541. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  542. }
  543. if ($ktime && $jtime) {
  544. $gj = " and enter > '$ktime' and enter < '$jtime'";
  545. $ck = " and outk > '$ktime' and outk < '$jtime'";
  546. }
  547. //数据排序
  548. $order_str = "id desc";
  549. if (empty($page)) {
  550. $start = 0;
  551. $perpage = 1;
  552. } else {
  553. $start = ($page - 1) * $perpage;
  554. }
  555. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  556. if ($sku) {
  557. $sku = trim($sku, ' ');
  558. $sku = trim($sku, ' ');
  559. $where .= " and sku like '%$sku%'";
  560. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  561. } else if ($title) {
  562. $title = trim($title, ' ');
  563. $title = trim($title, ' ');
  564. $where .= " and title like '%$title%'";
  565. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  566. } else {
  567. //$where .= " and time > '$ktime' and time < '$jtime'";
  568. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  569. }
  570. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  571. foreach ($info_list as $k => $v) {
  572. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  573. unset($info_list[$k]['pm']);
  574. unset($info_list[$k]['jm']);
  575. unset($info_list[$k]['bm']);
  576. }
  577. //取得信息列表
  578. $rows = array();
  579. $list = array();
  580. foreach ($info_list as $key => $value) {
  581. $warehouse = $this->warehouse->read($value['warehouse']);
  582. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  583. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  584. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  585. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  586. $info_list[$key]['label'] = $value['sm'];
  587. $number = $value['number'];
  588. $ftime = time() - 15 * 24 * 3600;
  589. $info_list[$key]['warehouse'] = $warehouse['title'];
  590. $info_list[$key]['features'] = count($c);
  591. $z = count($z); //查看订单号
  592. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  593. $ztdata = '';
  594. if (count($zt) > 0) {
  595. foreach ($zt as $vv) {
  596. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  597. }
  598. }
  599. $info_list[$key]['number'] = $ztdata;
  600. $info_list[$key]['sm'] = $z;
  601. $details = array();
  602. $cpid = array();
  603. foreach ($c as $k => $v) {
  604. $details[$v['details']] = $v['details'];
  605. if ($v['cpid'] != 0) {
  606. $cpid[$v['cpid']] = $v['cpid'];
  607. }
  608. }
  609. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  610. if ($value['shop'] != '') {
  611. $shop = explode(',', trim($value['shop'], ','));
  612. $shop = $this->shop->read($shop[0]);
  613. $info_list[$key]['shop'] = $shop['shopname'];
  614. }
  615. }
  616. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  617. $pagenum = ceil($total / $perpage);
  618. $over = $total - ($start + $perpage);
  619. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  620. echo json_encode($rows);
  621. exit;
  622. }
  623. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  624. $this->_Template('whlabel_typedy', $this->data);
  625. }
  626. //进销存浏览
  627. public function _typedy_ck($arg_array)
  628. {
  629. $prc = array();
  630. $purchase = $this->purchase->find_all();
  631. foreach ($purchase as $k => $v) {
  632. $prc[$v['id']] = $v['title'];
  633. }
  634. $post = $this->input->post(NULL, TRUE);
  635. if (isset($post['page'])) {
  636. $page = $this->input->post('page', true);
  637. $perpage = $this->input->post('perpage', true);
  638. $category = $this->input->post('category', true);
  639. $size = $this->input->post('size', true);
  640. $grade = $this->input->post('grade', true);
  641. $color = $this->input->post('color', true);
  642. $lowe = $this->input->post('lowe', true);
  643. $sku = $this->input->post('sku');
  644. $title = $this->input->post('title');
  645. $warehouse = $this->input->post('warehouse', true);
  646. $usa = $this->input->post('usa', true);
  647. $purchase = $this->input->post('purchase', true);
  648. $lacetype = $this->input->post('lacetype', true);
  649. $haircap = $this->input->post('haircap', true);
  650. $density = $this->input->post('density', true);
  651. $details = $this->input->post('details', true);
  652. $state = $this->input->post('state', true);
  653. $lacecolor = $this->input->post('lacecolor', true);
  654. $cklx = $this->input->post('cklx', true);
  655. $ktime = $this->input->post('ktime', true);
  656. $jtime = $this->input->post('jtime', true);
  657. $ktime = strtotime($ktime);
  658. $jtime = strtotime($jtime);
  659. $where = "1=1";
  660. $gj = "";
  661. $ck = "";
  662. if ($lacetype) {
  663. $where .= " and features like '%-$lacetype-%'";
  664. }
  665. if ($category) {
  666. $where .= " and features like '%-$category-%'";
  667. }
  668. if ($size) {
  669. $where .= " and features like '%-$size-%'";
  670. }
  671. if ($grade) {
  672. $where .= " and features like '%-$grade-%'";
  673. }
  674. if ($color) {
  675. $where .= " and features like '%-$color-%'";
  676. }
  677. if ($lowe) {
  678. $where .= " and features like '%-$lowe-%'";
  679. }
  680. if ($haircap) {
  681. $where .= " and features like '%-$haircap-%'";
  682. }
  683. if ($density) {
  684. $where .= " and features like '%-$density-%'";
  685. }
  686. if ($lacecolor) {
  687. $where .= " and features like '%-$lacecolor-%'";
  688. }
  689. if ($usa) {
  690. if (!$warehouse) {
  691. $where .= " and (warehouse = '5' or warehouse = '8')";
  692. }
  693. }
  694. if ($warehouse) {
  695. $where .= " and warehouse = '$warehouse'";
  696. }
  697. if ($details) {
  698. $where .= " and details = '$details'";
  699. }
  700. if ($purchase) {
  701. $where .= " and purchase = '$purchase'";
  702. }
  703. if ($state) {
  704. $where .= " and state = '$state'";
  705. }
  706. $where_add = '';
  707. if ($cklx) {
  708. $shop = $this->shop->read($cklx);
  709. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  710. }
  711. if ($ktime && $jtime) {
  712. $gj = " and enter > '$ktime' and enter < '$jtime'";
  713. $ck = " and outk > '$ktime' and outk < '$jtime'";
  714. }
  715. //数据排序
  716. $order_str = "id desc";
  717. if (empty($page)) {
  718. $start = 0;
  719. $perpage = 1;
  720. } else {
  721. $start = ($page - 1) * $perpage;
  722. }
  723. if ($sku) {
  724. $sku = trim($sku, ' ');
  725. $sku = trim($sku, ' ');
  726. $where .= " and sku like '%$sku%'";
  727. $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);
  728. } else if ($title) {
  729. $title = trim($title, ' ');
  730. $title = trim($title, ' ');
  731. $where .= " and title like '%$title%'";
  732. $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);
  733. } else {
  734. //$where .= " and time > '$ktime' and time < '$jtime'";
  735. $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);
  736. }
  737. //取得信息列表
  738. $rows = array();
  739. $list = array();
  740. foreach ($info_list as $key => $value) {
  741. $warehouse = $this->warehouse->read($value['warehouse']);
  742. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  743. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  744. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  745. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  746. $ftime = time() - 15 * 24 * 3600;
  747. $info_list[$key]['warehouse'] = $warehouse['title'];
  748. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  749. //$z = count($z);//查看订单号
  750. //$info_list[$key]['zd'] = $z;
  751. $details = array();
  752. $cpid = array();
  753. foreach ($c as $k => $v) {
  754. $details[$v['details']] = $v['details'];
  755. if ($v['cpid'] != 0) {
  756. $cpid[$v['cpid']] = $v['cpid'];
  757. }
  758. }
  759. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  760. if ($value['shop'] != '') {
  761. $shop = explode(',', trim($value['shop'], ','));
  762. $shop = $this->shop->read($shop[0]);
  763. $info_list[$key]['shop'] = $shop['shopname'];
  764. }
  765. }
  766. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  767. $pagenum = ceil($total / $perpage);
  768. $over = $total - ($start + $perpage);
  769. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  770. echo json_encode($rows);
  771. exit;
  772. }
  773. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  774. $this->_Template('whlabel_typedy_ck', $this->data);
  775. }
  776. public function _typeck($arg_array)
  777. {
  778. $prc = array();
  779. $purchase = $this->purchase->find_all();
  780. foreach ($purchase as $k => $v) {
  781. $prc[$v['id']] = $v['title'];
  782. }
  783. $post = $this->input->post(NULL, TRUE);
  784. if (isset($post['page'])) {
  785. $page = $this->input->post('page', true);
  786. $perpage = $this->input->post('perpage', true);
  787. $category = $this->input->post('category', true);
  788. $size = $this->input->post('size', true);
  789. $grade = $this->input->post('grade', true);
  790. $color = $this->input->post('color', true);
  791. $lacecolor = $this->input->post('lacecolor', true);
  792. $lowe = $this->input->post('lowe', true);
  793. $sku = $this->input->post('sku');
  794. $title = $this->input->post('title');
  795. $warehouse = 13;
  796. $usa = $this->input->post('usa', true);
  797. $purchase = $this->input->post('purchase', true);
  798. $lacetype = $this->input->post('lacetype', true);
  799. $haircap = $this->input->post('haircap', true);
  800. $density = $this->input->post('density', true);
  801. $details = $this->input->post('details', true);
  802. $state = $this->input->post('state', true);
  803. $ktime = $this->input->post('ktime', true);
  804. $jtime = $this->input->post('jtime', true);
  805. $ktime = strtotime($ktime);
  806. $jtime = strtotime($jtime);
  807. $where = "1=1";
  808. $gj = "";
  809. $ck = "";
  810. if ($lacetype) {
  811. $where .= " and features like '%-$lacetype-%'";
  812. }
  813. if ($category) {
  814. $where .= " and features like '%-$category-%'";
  815. }
  816. if ($size) {
  817. $where .= " and features like '%-$size-%'";
  818. }
  819. if ($grade) {
  820. $where .= " and features like '%-$grade-%'";
  821. }
  822. if ($color) {
  823. $where .= " and features like '%-$color-%'";
  824. }
  825. if ($lacecolor) {
  826. $where .= " and features like '%-$lacecolor-%'";
  827. }
  828. if ($lowe) {
  829. $where .= " and features like '%-$lowe-%'";
  830. }
  831. if ($haircap) {
  832. $where .= " and features like '%-$haircap-%'";
  833. }
  834. if ($density) {
  835. $where .= " and features like '%-$density-%'";
  836. }
  837. if ($warehouse) {
  838. $where .= " and warehouse = '$warehouse'";
  839. }
  840. if ($details) {
  841. $where .= " and details = '$details'";
  842. }
  843. if ($purchase) {
  844. $where .= " and purchase = '$purchase'";
  845. }
  846. if ($state) {
  847. $where .= " and state = '$state'";
  848. }
  849. if ($ktime && $jtime) {
  850. $gj = " and enter > '$ktime' and enter < '$jtime'";
  851. $ck = " and outk > '$ktime' and outk < '$jtime'";
  852. }
  853. //数据排序
  854. $order_str = "id desc";
  855. if (empty($page)) {
  856. $start = 0;
  857. $perpage = 1;
  858. } else {
  859. $start = ($page - 1) * $perpage;
  860. }
  861. if ($sku) {
  862. $sku = trim($sku, ' ');
  863. $sku = trim($sku, ' ');
  864. $where .= " and sku like '%$sku%'";
  865. } else if ($title) {
  866. $title = trim($title, ' ');
  867. $title = trim($title, ' ');
  868. $where .= " and title like '%$title%'";
  869. }
  870. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  871. //取得信息列表
  872. $t = array();
  873. $typeclass = $this->typeclass->find_all();
  874. foreach ($typeclass as $v) {
  875. $t[$v['id']] = $v;
  876. }
  877. $rows = array();
  878. $list = array();
  879. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  880. foreach ($info_list as $key => $value) {
  881. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  882. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  883. $warehouse = $this->warehouse->read($value['warehouse']);
  884. $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');
  885. $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'] . '"');
  886. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  887. $number = $value['number'];
  888. $ftime = time() - 15 * 24 * 3600;
  889. $z = count($z); //查看订单号
  890. $info_list[$key]['warehouse'] = $warehouse['title'];
  891. $info_list[$key]['features'] = count($c);
  892. $info_list[$key]['number'] = $z;
  893. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  894. $details = array();
  895. $cpid = array();
  896. foreach ($c as $k => $v) {
  897. $details[$v['details']] = $v['details'];
  898. if ($v['cpid'] != 0) {
  899. $cpid[$v['cpid']] = $v['cpid'];
  900. }
  901. }
  902. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  903. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  904. unset($info_list[$key]['pm']);
  905. unset($info_list[$key]['jm']);
  906. unset($info_list[$key]['bm']);
  907. }
  908. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  909. $pagenum = ceil($total / $perpage);
  910. $over = $total - ($start + $perpage);
  911. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  912. echo json_encode($rows);
  913. exit;
  914. }
  915. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  916. $this->_Template('whlabel_typeck', $this->data);
  917. }
  918. //进销存导出
  919. public function _whlabeckdc()
  920. {
  921. $prc = array();
  922. $purchase = $this->purchase->find_all();
  923. foreach ($purchase as $k => $v) {
  924. $prc[$v['id']] = $v['title'];
  925. }
  926. if (isset($_GET['excel'])) {
  927. $where = "sku != 'Preset'";
  928. //数据排序
  929. $order_str = "id desc";
  930. if (empty($page)) {
  931. $start = 0;
  932. $perpage = 1;
  933. } else {
  934. $start = ($page - 1) * $perpage;
  935. }
  936. $category = $this->input->get('category', true);
  937. $color = $this->input->get('color', true);
  938. $lowe = $this->input->get('lowe', true);
  939. $lacetype = $this->input->get('lacetype', true);
  940. $size = $this->input->get('size', true);
  941. $density = $this->input->get('density', true);
  942. $haircap = $this->input->get('haircap', true);
  943. $sku = $this->input->get('sku', true);
  944. $details = $this->input->get('details', true);
  945. $warehouse = 13;
  946. $excelid = $this->input->get('sid', true);
  947. if ($category) {
  948. $where .= " and features like '%-$category-%'";
  949. }
  950. if ($color) {
  951. $where .= " and features like '%-$color-%'";
  952. }
  953. if ($lowe) {
  954. $where .= " and features like '%-$lowe-%'";
  955. }
  956. if ($lacetype) {
  957. $where .= " and features like '%-$lacetype-%'";
  958. }
  959. if ($size) {
  960. $where .= " and features like '%-$size-%'";
  961. }
  962. if ($density) {
  963. $where .= " and features like '%-$density-%'";
  964. }
  965. if ($haircap) {
  966. $where .= " and features like '%-$haircap-%'";
  967. }
  968. if ($warehouse) {
  969. $where .= " and warehouse = '$warehouse'";
  970. }
  971. if ($sku) {
  972. $where .= " and sku like '%$sku%'";
  973. }
  974. if ($details) {
  975. $where .= " and details = '$details'";
  976. }
  977. $xzid = '';
  978. if ($excelid) {
  979. $excelid = explode(',', trim($excelid, ','));
  980. foreach ($excelid as $key => $value) {
  981. $xzid .= " id = " . $value . " or";
  982. }
  983. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  984. }
  985. //取得信息列表
  986. /**
  987. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  988. $rows = array();$list = array();
  989. foreach ($info_list as $key=>$value)
  990. {
  991. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  992. }
  993. **/
  994. $wh = array();
  995. $w = $this->warehouse->find_all('1=1', 'id,title');
  996. foreach ($w as $v) {
  997. $wh[$v['id']] = $v['title'];
  998. }
  999. $tc = array();
  1000. $tcdata = array();
  1001. $list = array();
  1002. $classid = $this->classid->sku();
  1003. $tcall = $this->typeclass->find_all();
  1004. $typeclass = array();
  1005. foreach ($tcall as $v)
  1006. {
  1007. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1008. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1009. }
  1010. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1011. foreach ($rows as $key => $value) {
  1012. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1013. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1014. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1015. $rows[$key]['cpbz'] = $u9_info['bm'];
  1016. $rows[$key]['cs'] = $u9_info['jm'];
  1017. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1018. $details = array();
  1019. $cpid = array();
  1020. $cpbz = array();
  1021. $c = 0;
  1022. $g = 0;
  1023. $x = 0;
  1024. $t = 0;
  1025. $s = 0;
  1026. $q = 0;
  1027. foreach ($sd as $k => $v) {
  1028. if ($v['state'] == 0) {
  1029. $c++;
  1030. }
  1031. if ($v['state'] != 9) {
  1032. $g++;
  1033. }
  1034. if ($v['state'] == 1) {
  1035. $x++;
  1036. }
  1037. if ($v['state'] == 2) {
  1038. $t++;
  1039. }
  1040. if ($v['state'] == 8) {
  1041. $s++;
  1042. }
  1043. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1044. $q++;
  1045. }
  1046. $details[$v['details']] = $v['details'];
  1047. if ($v['cpid'] != 0) {
  1048. $cpid[$v['cpid']] = $v['cpid'];
  1049. }
  1050. if ($v['cpbz'] != '') {
  1051. $cpbz[$v['cpbz']] = $v['cpbz'];
  1052. }
  1053. }
  1054. $rows[$key]['details'] = implode("、", $details);
  1055. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1056. $number = $value['number'];
  1057. $ftime = time() - 15 * 24 * 3600;
  1058. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1059. $rows[$key]['number'] = $g;
  1060. $rows[$key]['features'] = $c;
  1061. $rows[$key]['x'] = $x;
  1062. $rows[$key]['t'] = $t;
  1063. $rows[$key]['s'] = $s;
  1064. $rows[$key]['q'] = $q;
  1065. $rows[$key]['wzsl'] = count($details);
  1066. }
  1067. $title = "进销存统计表" . date('Y-m-d', time());
  1068. $titlename = "<table border=1>
  1069. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1070. <tr align='center'>
  1071. <td>仓库</td>
  1072. <td>供应商</td>
  1073. <td>位置</td>
  1074. <td>库存编码</td>
  1075. <td>SKU</td>
  1076. <td>用友编码</td>
  1077. <td>用友料号</td>
  1078. <td>产品英文名</td>
  1079. <td>产品中文名</td>
  1080. <td>入库总量</td>
  1081. <td>库存数量</td>
  1082. <td>销售数量</td>
  1083. <td>退货数量</td>
  1084. <td>删除数量</td>
  1085. <td>其它操作</td>
  1086. <td>位置数量</td>
  1087. </tr>
  1088. </table>";
  1089. $filename = $title . ".xls";
  1090. $tail = "";
  1091. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1092. }
  1093. }
  1094. public function _type()
  1095. {
  1096. $vip = 0;
  1097. if (isset($_SESSION['api'])) {
  1098. $user = $this->user->get_api($_SESSION['api']);
  1099. $fgshop = "";
  1100. $sid = "";
  1101. $usersp = explode('|', trim($user['shop'], '|'));
  1102. foreach ($usersp as $value) {
  1103. $fgshop .= " shop = " . $value . " or";
  1104. $sid .= " id = " . $value . " or";
  1105. }
  1106. if ($user['vip'] == 1) {
  1107. $vip = 1;
  1108. }
  1109. } else {
  1110. header('Location: /');
  1111. exit;
  1112. }
  1113. $prc = array();
  1114. $purchase = $this->purchase->find_all();
  1115. foreach ($purchase as $k => $v) {
  1116. $prc[$v['id']] = $v['title'];
  1117. }
  1118. $company = array();
  1119. $ct = $this->company->find_all();
  1120. foreach ($ct as $k => $v) {
  1121. $company[$v['id']] = $v['title'];
  1122. }
  1123. $sp = array();
  1124. $s = $this->shop->find_all('1=1', 'id,shopname');
  1125. foreach ($s as $v) {
  1126. $sp[$v['id']] = $v['shopname'];
  1127. }
  1128. $wh = array();
  1129. $w = $this->warehouse->find_all('1=1', 'id,title');
  1130. foreach ($w as $v) {
  1131. $wh[$v['id']] = $v['title'];
  1132. }
  1133. $post = $this->input->post(NULL, TRUE);
  1134. if (isset($post['page'])) {
  1135. $page = $this->input->post('page', true);
  1136. $perpage = $this->input->post('perpage', true);
  1137. $category = $this->input->post('category', true);
  1138. $size = $this->input->post('size', true);
  1139. $grade = $this->input->post('grade', true);
  1140. $color = $this->input->post('color', true);
  1141. $lowe = $this->input->post('lowe', true);
  1142. $sku = $this->input->post('sku');
  1143. $title = $this->input->post('title');
  1144. $warehouse = $this->input->post('warehouse', true);
  1145. $usa = $this->input->post('usa', true);
  1146. $purchase = $this->input->post('purchase', true);
  1147. $lacetype = $this->input->post('lacetype', true);
  1148. $haircap = $this->input->post('haircap', true);
  1149. $density = $this->input->post('density', true);
  1150. $details = $this->input->post('details', true);
  1151. $state = $this->input->post('state', true);
  1152. $shop = $this->input->post('shop', true);
  1153. $lacecolor = $this->input->post('lacecolor', true);
  1154. $hairnumber = $this->input->post('hairnumber', true);
  1155. $type = $this->input->post('type', true);
  1156. $ktime = $this->input->post('ktime', true);
  1157. $jtime = $this->input->post('jtime', true);
  1158. $ktime = strtotime($ktime);
  1159. $jtime = strtotime($jtime);
  1160. $cpbz = $this->input->post('cpbz', true);
  1161. $sm = $this->input->post('sm', true);
  1162. $where = "1=1";
  1163. $gj = "";
  1164. $ck = "";
  1165. if ($usa) {
  1166. if (!$warehouse) {
  1167. $where .= " and (warehouse = '5' or warehouse = '8')";
  1168. }
  1169. }
  1170. if ($warehouse) {
  1171. $where .= " and warehouse = '$warehouse'";
  1172. }
  1173. if ($details) {
  1174. $where .= " and details = '$details'";
  1175. }
  1176. if ($purchase) {
  1177. $where .= " and purchase = '$purchase'";
  1178. }
  1179. if ($state) {
  1180. $where .= " and state = '$state'";
  1181. }
  1182. if ($shop) {
  1183. $where .= " and shop like '%$shop%'";
  1184. }
  1185. if ($type) {
  1186. $where .= " and type = '$type'";
  1187. }
  1188. if ($ktime && $jtime) {
  1189. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1190. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1191. }
  1192. if ($cpbz) {
  1193. $where .= " and cpbz like '%$cpbz%' ";
  1194. }
  1195. if ($sm) {
  1196. $where .= " and sm like '%$sm%' ";
  1197. }
  1198. if ($lacecolor) {
  1199. $where .= " and features like '%-$lacecolor-%'";
  1200. }
  1201. if ($lacetype) {
  1202. $where .= " and features like '%-$lacetype-%'";
  1203. }
  1204. if ($category) {
  1205. $where .= " and features like '%-$category-%'";
  1206. }
  1207. if ($size) {
  1208. $where .= " and features like '%-$size-%'";
  1209. }
  1210. if ($grade) {
  1211. $where .= " and features like '%-$grade-%'";
  1212. }
  1213. if ($color) {
  1214. $where .= " and features like '%-$color-%'";
  1215. }
  1216. if ($lowe) {
  1217. $where .= " and features like '%-$lowe-%'";
  1218. }
  1219. if ($haircap) {
  1220. $where .= " and features like '%-$haircap-%'";
  1221. }
  1222. if ($density) {
  1223. $where .= " and features like '%-$density-%'";
  1224. }
  1225. if (!empty($hairnumber)) {
  1226. $where .= " and features like '%-128-%' ";
  1227. if ($hairnumber < 0) {
  1228. $class_list = $this->typeclass->find_all('classid = 43');
  1229. foreach ($class_list as $v) {
  1230. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1231. }
  1232. } else {
  1233. $where .= " and features like '%-$hairnumber-%'";
  1234. }
  1235. }
  1236. //数据排序
  1237. $order_str = "id desc";
  1238. if (empty($page)) {
  1239. $start = 0;
  1240. $perpage = 1;
  1241. } else {
  1242. $start = ($page - 1) * $perpage;
  1243. }
  1244. $fjnr = '';
  1245. if ($sku) {
  1246. $sku = trim($sku, ' ');
  1247. $sku = trim($sku, ' ');
  1248. $fjnr .= " and sku like '%$sku%'";
  1249. }
  1250. if ($title) {
  1251. $title = trim($title, ' ');
  1252. $title = trim($title, ' ');
  1253. $fjnr .= " and title like '%$title%'";
  1254. }
  1255. $wt = array();
  1256. $whlabel_type = $this->whlabel_type->find_all();
  1257. foreach ($whlabel_type as $v) {
  1258. $wt[$v['id']] = $v['title'];
  1259. }
  1260. //$where .= " and time > '$ktime' and time < '$jtime'";
  1261. $info_list = $this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,type,features,number,sm', $order_str, $start, $perpage); //改这需要修改_gbhtype
  1262. //取得信息列表
  1263. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1264. $rows = array();
  1265. $list = array();
  1266. foreach ($info_list as $key => $value) {
  1267. if (isset($wt[$value['type']])) {
  1268. $info_list[$key]['type'] = $wt[$value['type']];
  1269. } else {
  1270. $info_list[$key]['type'] = '未设置';
  1271. }
  1272. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1273. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1274. $ztdata = '';
  1275. if (count($zt) > 0) {
  1276. foreach ($zt as $vv) {
  1277. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1278. }
  1279. }
  1280. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1281. $cdata = array_filter($qbdata, function ($item) {
  1282. return $item['state'] < 1;
  1283. });
  1284. $c = array_sum(array_column($cdata, 'jnum'));
  1285. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1286. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1287. });
  1288. $g = array_sum(array_column($gdata, 'jnum'));
  1289. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1290. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1291. });
  1292. $x = array_sum(array_column($xdata, 'jnum'));
  1293. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1294. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1295. });
  1296. $t = array_sum(array_column($tdata, 'jnum'));
  1297. $zdata = array_filter($qbdata, function ($item) {
  1298. return $item['zd'] != "" && $item['state'] < 1;
  1299. });
  1300. $z = array_sum(array_column($zdata, 'jnum'));
  1301. $zdata = array_filter($qbdata, function ($item) {
  1302. return $item['zd'] != "" && $item['state'] < 1;
  1303. });
  1304. $z = array_sum(array_column($zdata, 'jnum'));
  1305. //$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');
  1306. //$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'].'"');
  1307. //$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'].'"');
  1308. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1309. //$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'].'"');
  1310. $details = array();
  1311. $cpid = array();
  1312. $od = array();
  1313. $odid = '';
  1314. $companytitle = '';
  1315. $shop_list = [];
  1316. foreach ($qbdata as $v) {
  1317. if ($v['zd'] != "" && $v['state'] < 1) {
  1318. if (!isset($od[$v['zd']])) {
  1319. $od[$v['zd']] = 1; //所有数据sku
  1320. } else {
  1321. $od[$v['zd']] = $od[$v['zd']] + 1;
  1322. }
  1323. }
  1324. if ($v['state'] < 1) {
  1325. $details[$v['details']] = $v['details'];
  1326. if ($v['cpid'] != 0) {
  1327. $cpid[$v['cpid']] = $v['cpid'];
  1328. }
  1329. }
  1330. if($v['state'] == 0){
  1331. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1332. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1333. }
  1334. if ($v['shop'] != '') {
  1335. $shop = explode(',', trim($v['shop'], ','));
  1336. foreach ($shop as $vv) {
  1337. if (!in_array($vv, $shop_list)) {
  1338. $shop_list[] = $vv;
  1339. }
  1340. }
  1341. }
  1342. }
  1343. }
  1344. foreach ($od as $k => $vv) {
  1345. $odid .= $k . '数量' . $vv;
  1346. }
  1347. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1348. $info_list[$key]['label'] = $value['sm'];
  1349. $number = $value['number'];
  1350. $ftime = time() - 15 * 24 * 3600;
  1351. $z = $z . '(' . $odid . ')'; //查看订单号
  1352. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1353. $info_list[$key]['features'] = $c;
  1354. $info_list[$key]['number'] = $ztdata;
  1355. $info_list[$key]['sm'] = $g;
  1356. $info_list[$key]['x'] = $x;
  1357. $info_list[$key]['t'] = $t;
  1358. $info_list[$key]['z'] = $z;
  1359. /**
  1360. foreach ($cdata as $k=>$v)
  1361. {
  1362. $details[$v['details']] = $v['details'];
  1363. if($v['cpid'] != 0)
  1364. {
  1365. $cpid[$v['cpid']] = $v['cpid'];
  1366. }
  1367. }
  1368. **/
  1369. $info_list[$key]['shop'] = '';
  1370. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1371. // if ($value['shop'] != '') {
  1372. // $shop = explode(',', trim($value['shop'], ','));
  1373. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1374. // }
  1375. $shop_list = array_unique($shop_list);
  1376. $shop_str = '';
  1377. foreach ($shop_list as $v) {
  1378. if(isset($sp[$v])){
  1379. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1380. }
  1381. }
  1382. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1383. /**
  1384. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1385. if(isset($companytitle[0]))
  1386. {
  1387. foreach ($companytitle as $k=>$v)
  1388. {
  1389. if($v['companytitle'] != '')
  1390. {
  1391. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1392. }
  1393. }
  1394. }
  1395. **/
  1396. }
  1397. $final_all_list = [];
  1398. foreach ($info_list as $k => $v) {
  1399. $final_all_list[] = [
  1400. 'id' => $v['id'],
  1401. "warehouse" => $v["warehouse"],
  1402. "purchase" => $v["purchase"],
  1403. "sku" => $v["sku"],
  1404. "title" => $v["title"] . "<br/>" . $v["pm"],
  1405. "details" => $v["details"],
  1406. "shop" => $v["shop"],
  1407. "cpbz" => $v["cpbz"],
  1408. 'label' => $v['label'],
  1409. "type" => $v["type"],
  1410. "features" => $v["features"],
  1411. "number" => $v["number"],
  1412. "sm" => $v["sm"],
  1413. "x" => $v["x"],
  1414. "t" => $v["t"],
  1415. "z" => $v["z"]
  1416. ];
  1417. }
  1418. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1419. $pagenum = ceil($total / $perpage);
  1420. $over = $total - ($start + $perpage);
  1421. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1422. echo json_encode($rows);
  1423. exit;
  1424. }
  1425. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1426. $this->data['shop'] = $wlshop;
  1427. $this->data['vip'] = $vip;
  1428. $this->_Template('whlabel_type', $this->data);
  1429. }
  1430. //美仓进销存浏览
  1431. public function _usatype()
  1432. {
  1433. if (isset($_SESSION['api'])) {
  1434. $user = $this->user->get_api($_SESSION['api']);
  1435. $usp = $user;
  1436. $fgshop = "";
  1437. $sid = "";
  1438. $wid = "";
  1439. $wtype = "";
  1440. $userwh = explode('|', trim($user['warehouse'], '|'));
  1441. foreach ($userwh as $value) {
  1442. $wid .= " id = " . $value . " or";
  1443. $wtype .= " type = " . $value . " or";
  1444. }
  1445. }
  1446. $prc = array();
  1447. $purchase = $this->purchase->find_all();
  1448. foreach ($purchase as $k => $v) {
  1449. $prc[$v['id']] = $v['title'];
  1450. }
  1451. $post = $this->input->post(NULL, TRUE);
  1452. if (isset($post['page'])) {
  1453. $page = $this->input->post('page', true);
  1454. $perpage = $this->input->post('perpage', true);
  1455. $category = $this->input->post('category', true);
  1456. $size = $this->input->post('size', true);
  1457. $grade = $this->input->post('grade', true);
  1458. $color = $this->input->post('color', true);
  1459. $lowe = $this->input->post('lowe', true);
  1460. $sku = $this->input->post('sku');
  1461. $title = $this->input->post('title');
  1462. $warehouse = $this->input->post('warehouse', true);
  1463. $usa = $this->input->post('usa', true);
  1464. $purchase = $this->input->post('purchase', true);
  1465. $lacetype = $this->input->post('lacetype', true);
  1466. $haircap = $this->input->post('haircap', true);
  1467. $density = $this->input->post('density', true);
  1468. $details = $this->input->post('details', true);
  1469. $state = $this->input->post('state', true);
  1470. $lacecolor = $this->input->post('lacecolor', true);
  1471. $cklx = $this->input->post('cklx', true);
  1472. $ktime = $this->input->post('ktime', true);
  1473. $jtime = $this->input->post('jtime', true);
  1474. $ktime = strtotime($ktime);
  1475. $jtime = strtotime($jtime);
  1476. $where = "1=1";
  1477. $gj = "";
  1478. $ck = "";
  1479. if ($lacetype) {
  1480. $where .= " and features like '%-$lacetype-%'";
  1481. }
  1482. if ($category) {
  1483. $where .= " and features like '%-$category-%'";
  1484. }
  1485. if ($size) {
  1486. $where .= " and features like '%-$size-%'";
  1487. }
  1488. if ($grade) {
  1489. $where .= " and features like '%-$grade-%'";
  1490. }
  1491. if ($color) {
  1492. $where .= " and features like '%-$color-%'";
  1493. }
  1494. if ($lowe) {
  1495. $where .= " and features like '%-$lowe-%'";
  1496. }
  1497. if ($haircap) {
  1498. $where .= " and features like '%-$haircap-%'";
  1499. }
  1500. if ($density) {
  1501. $where .= " and features like '%-$density-%'";
  1502. }
  1503. if ($lacecolor) {
  1504. $where .= " and features like '%-$lacecolor-%'";
  1505. }
  1506. if ($usa) {
  1507. if (!$warehouse) {
  1508. $where .= " and (warehouse = '5' or warehouse = '8')";
  1509. }
  1510. }
  1511. if ($warehouse) {
  1512. $where .= " and warehouse = '$warehouse'";
  1513. }
  1514. if ($details) {
  1515. $where .= " and details = '$details'";
  1516. }
  1517. if ($purchase) {
  1518. $where .= " and purchase = '$purchase'";
  1519. }
  1520. if ($state) {
  1521. $where .= " and state = '$state'";
  1522. }
  1523. $where_add = '';
  1524. if ($cklx) {
  1525. $shop = $this->shop->read($cklx);
  1526. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1527. }
  1528. if ($ktime && $jtime) {
  1529. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1530. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1531. }
  1532. //数据排序
  1533. $order_str = "id desc";
  1534. if (empty($page)) {
  1535. $start = 0;
  1536. $perpage = 1;
  1537. } else {
  1538. $start = ($page - 1) * $perpage;
  1539. }
  1540. if ($sku) {
  1541. $sku = trim($sku, ' ');
  1542. $sku = trim($sku, ' ');
  1543. $where .= " and sku like '%$sku%'";
  1544. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1545. } else if ($title) {
  1546. $title = trim($title, ' ');
  1547. $title = trim($title, ' ');
  1548. $where .= " and title like '%$title%'";
  1549. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1550. } else {
  1551. //$where .= " and time > '$ktime' and time < '$jtime'";
  1552. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1553. }
  1554. //取得信息列表
  1555. $rows = array();
  1556. $list = array();
  1557. foreach ($info_list as $key => $value) {
  1558. $warehouse = $this->warehouse->read($value['warehouse']);
  1559. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1560. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1561. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1562. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1563. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1564. $od = array();
  1565. $odid = '';
  1566. foreach ($z as $v) {
  1567. if (!isset($od[$v['zd']])) {
  1568. $od[$v['zd']] = 1; //所有数据sku
  1569. } else {
  1570. $od[$v['zd']] = $od[$v['zd']] + 1;
  1571. }
  1572. }
  1573. foreach ($od as $k => $vv) {
  1574. $odid .= $k . '数量' . $vv . ' ';
  1575. }
  1576. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1577. $info_list[$key]['features'] = $c;
  1578. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1579. $ztdata = '';
  1580. if (count($zt) > 0) {
  1581. foreach ($zt as $vv) {
  1582. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1583. }
  1584. }
  1585. $info_list[$key]['warehouse'] = $ztdata;
  1586. $info_list[$key]['g'] = $g;
  1587. $info_list[$key]['x'] = $x;
  1588. $info_list[$key]['t'] = $t;
  1589. $info_list[$key]['z'] = $z;
  1590. }
  1591. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1592. $pagenum = ceil($total / $perpage);
  1593. $over = $total - ($start + $perpage);
  1594. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1595. echo json_encode($rows);
  1596. exit;
  1597. }
  1598. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1599. $this->data['warehouse'] = $warehouse;
  1600. $this->_Template('whlabel_typeusa', $this->data);
  1601. }
  1602. //美仓进销存浏览
  1603. public function _usatypeapp()
  1604. {
  1605. $post = $this->input->post(NULL, TRUE);
  1606. if (isset($post['page'])) {
  1607. $page = $this->input->post('page', true);
  1608. $perpage = $this->input->post('perpage', true);
  1609. $sku = $this->input->post('sku', true);
  1610. $warehouse = 5;
  1611. $title = $this->input->post('title', true);
  1612. $state = $this->input->post('state', true);
  1613. $ktime = $this->input->post('ktime', true);
  1614. $jtime = $this->input->post('jtime', true);
  1615. $ktime = strtotime($ktime);
  1616. $jtime = strtotime($jtime);
  1617. $where = "1=1";
  1618. $gj = "";
  1619. $ck = "";
  1620. if ($title) {
  1621. $st = explode(' ', trim($title, ' '));
  1622. foreach ($st as $v) {
  1623. $where .= " and title like '%$v%'";
  1624. }
  1625. }
  1626. if ($warehouse) {
  1627. $where .= " and warehouse = '$warehouse'";
  1628. }
  1629. if ($state) {
  1630. $where .= " and state = '$state'";
  1631. }
  1632. if ($sku) {
  1633. $where .= " and sku like '%$sku%'";
  1634. }
  1635. if ($ktime && $jtime) {
  1636. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1637. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1638. }
  1639. //数据排序
  1640. $order_str = "id desc";
  1641. if (empty($page)) {
  1642. $start = 0;
  1643. $perpage = 1;
  1644. } else {
  1645. $start = ($page - 1) * $perpage;
  1646. }
  1647. //取得信息列表
  1648. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1649. $rows = array();
  1650. $list = array();
  1651. foreach ($info_list as $key => $value) {
  1652. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1653. }
  1654. $rowsdq = array_slice($rows, $start, $perpage);
  1655. foreach ($rowsdq as $value) {
  1656. $warehouse = $this->warehouse->read($value['warehouse']);
  1657. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1658. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1659. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1660. $od = array();
  1661. $odid = '';
  1662. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1663. }
  1664. $total = count($rows);
  1665. $pagenum = ceil($total / $perpage);
  1666. $over = $total - ($start + $perpage);
  1667. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1668. echo json_encode($rows);
  1669. exit;
  1670. }
  1671. $this->_Template('phone/p_usatypeapp', $this->data);
  1672. }
  1673. //入库操作
  1674. public function _enteradd()
  1675. {
  1676. $dt = 0;
  1677. if (isset($_SESSION['api'])) {
  1678. $user = $this->user->get_api($_SESSION['api']);
  1679. $usp = $user;
  1680. $fgshop = "";
  1681. $sid = "";
  1682. $user = explode('|', trim($user['shop'], '|'));
  1683. foreach ($user as $value) {
  1684. $fgshop .= " shop = " . $value . " or";
  1685. $sid .= " id = " . $value . " or";
  1686. }
  1687. }
  1688. $tc = $this->typeclass->find_all();
  1689. $typeclass = array();
  1690. foreach ($tc as $v) {
  1691. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1692. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1693. }
  1694. $post = $this->input->post(NULL, TRUE);
  1695. if (isset($post['sku'])) {
  1696. $list = array();
  1697. $num = "";
  1698. $title = "";
  1699. $features = "";
  1700. $order = $this->input->post('order', true);
  1701. $shop = $this->input->post('shop', true);
  1702. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1703. $sku = $this->input->post('sku', true);
  1704. $post['sm'] = $this->input->post('sm', true);
  1705. $post['warehouse'] = $this->input->post('warehouse', true);
  1706. $post['purchase'] = $this->input->post('purchase', true);
  1707. $post['retreatwarehouse'] = $post['warehouse'];
  1708. $post['state'] = $this->input->post('state', true);
  1709. $post['rktype'] = $this->input->post('rktype', true);
  1710. $post['text'] = $this->input->post('text', true);
  1711. $category = $this->input->post('category', true);
  1712. $list['category'] = $category;
  1713. $list['hairtype'] = $this->input->post('hairtype', true);
  1714. $list['grade'] = $this->input->post('grade', true);
  1715. $size = $this->input->post('size', true);
  1716. $xzsku = $this->input->post('xzsku', true);
  1717. $list['size'] = rtrim($size, ',');
  1718. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1719. $list['extension'] = $this->input->post('extension', true);
  1720. if ($category == 1297) {
  1721. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1722. }
  1723. if ($category == 1702) {
  1724. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1725. $list['syother'] = $this->input->post('syother', true);
  1726. }
  1727. if ($category == 133) {
  1728. $list['fittype'] = $this->input->post('fittype', true);
  1729. $list['acother'] = $this->input->post('acother', true);
  1730. }
  1731. $list['color'] = $this->input->post('color', true);
  1732. $list['lowe'] = $this->input->post('lowe', true);
  1733. if (!$post['purchase']) {
  1734. $post['purchase'] = 1;
  1735. }
  1736. if ($category == 127) {
  1737. $list['type'] = $this->input->post('type', true);
  1738. $list['headroad'] = $this->input->post('headroad', true);
  1739. $list['density'] = $this->input->post('density', true);
  1740. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1741. $list['lacesize'] = $this->input->post('lacesize', true);
  1742. }
  1743. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1744. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1745. }
  1746. if ($category == 128) {
  1747. $list['lacetype'] = $this->input->post('lacetype', true);
  1748. $list['haircap'] = $this->input->post('haircap', true);
  1749. $list['density'] = $this->input->post('density', true);
  1750. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1751. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1752. $list['wigother'] = $this->input->post('wigother', true);
  1753. $list['wigother1'] = $this->input->post('wigother1', true);
  1754. $list['wigother2'] = $this->input->post('wigother2', true);
  1755. }
  1756. if ($category == 129) {
  1757. $list['wide'] = $this->input->post('wide', true);
  1758. }
  1759. if ($category == 131) {
  1760. $list['gifttype'] = $this->input->post('gifttype', true);
  1761. $list['giftother'] = $this->input->post('giftother', true);
  1762. }
  1763. if ($category == 134) {
  1764. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1765. }
  1766. if ($category == 1297) {
  1767. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1768. $list['sywigother'] = $this->input->post('sywigother', true);
  1769. }
  1770. if ($category == 130 || $category == 133 || $category == 1702) {
  1771. $list['items'] = $this->input->post('items', true);
  1772. $list['weight'] = $this->input->post('weight', true);
  1773. }
  1774. if ($category == 1702) {
  1775. $list['syhairther'] = $this->input->post('syhairther', true);
  1776. }
  1777. $classid = $this->classid->sku();
  1778. $scsku = $classid;
  1779. $pm = $classid;
  1780. foreach ($list as $k => $v) {
  1781. if ($v != 0) {
  1782. $num .= $v;
  1783. $features .= $v . '-';
  1784. $post[$k] = $v;
  1785. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1786. if ($k != 'size') {
  1787. $title .= $typeclass[$v]['title'] . " ";
  1788. }
  1789. if (isset($pm[$typeclass[$v]['classid']])) {
  1790. if ($typeclass[$v]['title'] == '9A') {
  1791. $pm[$typeclass[$v]['classid']] = '9A';
  1792. } else if ($typeclass[$v]['title'] == '10A') {
  1793. $pm[$typeclass[$v]['classid']] = '10A';
  1794. } else {
  1795. $clzh = $typeclass[$v]['zh'];
  1796. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1797. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1798. $clzh = $clzh[0];
  1799. }
  1800. $pm[$typeclass[$v]['classid']] = $clzh;
  1801. }
  1802. }
  1803. }
  1804. }
  1805. $zh = implode(" ", $pm);
  1806. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1807. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1808. if ($list['size']) {
  1809. $typeclass = $this->typeclass->read($list['size']);
  1810. $title .= $typeclass['title'];
  1811. }
  1812. $time = time();
  1813. if ($xzsku) {
  1814. $scsku = implode("-", $scsku);
  1815. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1816. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1817. $post['sku'] = trim($scsku, ' ');
  1818. } else {
  1819. $post['sku'] = $sku;
  1820. }
  1821. //$post['sku'] = trim($sku,' ');
  1822. $post['title'] = rtrim($title, ' ');
  1823. $post['number'] = $num;
  1824. $post['features'] = '-' . $features;
  1825. $post['enter'] = $time;
  1826. $post['time'] = $time; //操作时间
  1827. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1828. if ($yza) {
  1829. if ($post['features'] != $yza[0]['features']) {
  1830. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1831. exit;
  1832. }
  1833. }
  1834. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1835. if ($yzb) {
  1836. if ($post['sku'] != $yzb[0]['sku']) {
  1837. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1838. exit;
  1839. }
  1840. }
  1841. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1842. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1843. exit;
  1844. }
  1845. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1846. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1847. exit;
  1848. }
  1849. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1850. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1851. exit;
  1852. }
  1853. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1854. if (isset($yz[0]['type'])) {
  1855. $post['type'] = $yz[0]['type'];
  1856. }
  1857. if ($post['state'] == 9) //如果选择预设库存
  1858. {
  1859. $this->whlabel->insert($post);
  1860. } else {
  1861. /**
  1862. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1863. if($ljg == 1)
  1864. {
  1865. for($i=0;$i<$order;$i++)
  1866. {
  1867. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1868. $this->whlabel->insert($post);
  1869. }
  1870. }
  1871. **/
  1872. //if($post['warehouse'] == '5')
  1873. //{
  1874. //}
  1875. $yydata = $post;
  1876. $yydata['zh'] = $zh;
  1877. /**
  1878. $wl = $this->apiyy->get_cjlp($yydata);
  1879. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1880. {
  1881. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1882. }
  1883. if($wl['Data'][0]['m_isSucess'] != 1)
  1884. {
  1885. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1886. }
  1887. **/
  1888. for ($i = 0; $i < $order; $i++) {
  1889. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1890. $this->whlabel->insert($post);
  1891. }
  1892. }
  1893. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1894. exit;
  1895. }
  1896. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1897. $this->data['wlshop'] = $wlshop;
  1898. $this->_Template('whlabel_enteradd', $this->data);
  1899. }
  1900. //修改产品
  1901. public function _enteredit($arg_array)
  1902. {
  1903. $dt = 0;
  1904. if (isset($_SESSION['api'])) {
  1905. $user = $this->user->get_api($_SESSION['api']);
  1906. $usp = $user;
  1907. $fgshop = "";
  1908. $sid = "";
  1909. $user = explode('|', trim($user['shop'], '|'));
  1910. foreach ($user as $value) {
  1911. $fgshop .= " shop = " . $value . " or";
  1912. $sid .= " id = " . $value . " or";
  1913. }
  1914. }
  1915. $post = $this->input->post(NULL, TRUE);
  1916. if (isset($post['sku'])) {
  1917. $list = array();
  1918. $num = "";
  1919. $title = "";
  1920. $features = "";
  1921. $id = $this->input->post('id', true);
  1922. $order = $this->input->post('order', true);
  1923. $shop = $this->input->post('shop', true);
  1924. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1925. $post['sku'] = $this->input->post('sku', true);
  1926. $post['sm'] = $this->input->post('sm', true);
  1927. $post['warehouse'] = $this->input->post('warehouse', true);
  1928. $post['purchase'] = $this->input->post('purchase', true);
  1929. $post['retreatwarehouse'] = $post['warehouse'];
  1930. $category = $this->input->post('category', true);
  1931. $list['category'] = $category;
  1932. $list['hairtype'] = $this->input->post('hairtype', true);
  1933. $list['grade'] = $this->input->post('grade', true);
  1934. $size = $this->input->post('size', true);
  1935. $list['size'] = rtrim($size, ',');
  1936. $post['rktype'] = $this->input->post('rktype', true);
  1937. $post['text'] = $this->input->post('text', true);
  1938. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1939. $list['extension'] = $this->input->post('extension', true);
  1940. if ($category == 1297) {
  1941. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1942. }
  1943. if ($category == 1702) {
  1944. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1945. $list['syother'] = $this->input->post('syother', true);
  1946. }
  1947. if ($category == 133) {
  1948. $list['fittype'] = $this->input->post('fittype', true);
  1949. $list['acother'] = $this->input->post('acother', true);
  1950. }
  1951. $list['color'] = $this->input->post('color', true);
  1952. $list['lowe'] = $this->input->post('lowe', true);
  1953. if (!$post['purchase']) {
  1954. $post['purchase'] = 1;
  1955. }
  1956. if ($category == 127) {
  1957. $list['type'] = $this->input->post('type', true);
  1958. $list['headroad'] = $this->input->post('headroad', true);
  1959. $list['density'] = $this->input->post('density', true);
  1960. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1961. $list['lacesize'] = $this->input->post('lacesize', true);
  1962. }
  1963. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1964. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1965. }
  1966. if ($category == 128) {
  1967. $list['lacetype'] = $this->input->post('lacetype', true);
  1968. $list['haircap'] = $this->input->post('haircap', true);
  1969. $list['density'] = $this->input->post('density', true);
  1970. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1971. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1972. $list['wigother'] = $this->input->post('wigother', true);
  1973. $list['wigother1'] = $this->input->post('wigother1', true);
  1974. $list['wigother2'] = $this->input->post('wigother2', true);
  1975. }
  1976. if ($category == 129) {
  1977. $list['wide'] = $this->input->post('wide', true);
  1978. }
  1979. if ($category == 131) {
  1980. $list['gifttype'] = $this->input->post('gifttype', true);
  1981. $list['giftother'] = $this->input->post('giftother', true);
  1982. }
  1983. if ($category == 134) {
  1984. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1985. }
  1986. if ($category == 1297) {
  1987. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1988. $list['sywigother'] = $this->input->post('sywigother', true);
  1989. }
  1990. if ($category == 130 || $category == 133 || $category == 1702) {
  1991. $list['items'] = $this->input->post('items', true);
  1992. $list['weight'] = $this->input->post('weight', true);
  1993. }
  1994. if ($category == 1702) {
  1995. $list['syhairther'] = $this->input->post('syhairther', true);
  1996. }
  1997. foreach ($list as $k => $v) {
  1998. if ($v != 0) {
  1999. $num .= $v;
  2000. $features .= $v . '-';
  2001. $typeclass = $this->typeclass->read($v);
  2002. if ($k != 'size') {
  2003. $title .= $typeclass['title'] . " ";
  2004. }
  2005. }
  2006. }
  2007. $typeclass = $this->typeclass->read($list['size']);
  2008. $title .= $typeclass['title'];
  2009. $time = time();
  2010. $post['title'] = rtrim($title, ' ');
  2011. $post['number'] = $num;
  2012. $post['features'] = '-' . $features;
  2013. $post['time'] = $time; //操作时间
  2014. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2015. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2016. exit;
  2017. }
  2018. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2019. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2020. exit;
  2021. }
  2022. $uid = $this->whlabel->read($id);
  2023. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2024. if ($datanum > 0) {
  2025. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2026. exit;
  2027. }
  2028. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2029. {
  2030. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2031. if ($yza) {
  2032. if ($post['features'] != $yza[0]['features']) {
  2033. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2034. exit;
  2035. }
  2036. }
  2037. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2038. if ($yzb) {
  2039. if ($post['sku'] != $yzb[0]['sku']) {
  2040. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2041. exit;
  2042. }
  2043. }
  2044. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2045. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2046. exit;
  2047. }
  2048. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2049. foreach ($data as $v) {
  2050. $post['id'] = $v['id'];
  2051. $this->whlabel->save($post, $v['id']);
  2052. }
  2053. } else {
  2054. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2055. if ($data > 0) {
  2056. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2057. exit;
  2058. } else {
  2059. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2060. foreach ($data as $v) {
  2061. $post['id'] = $v['id'];
  2062. $this->whlabel->save($post, $v['id']);
  2063. }
  2064. }
  2065. }
  2066. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2067. exit;
  2068. }
  2069. $uid = $this->whlabel->read($arg_array[0]);
  2070. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2071. $this->data['enter'] = $uid;
  2072. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2073. $this->data['wlshop'] = $wlshop;
  2074. $this->_Template('whlabel_enteredit', $this->data);
  2075. }
  2076. //入库浏览
  2077. public function _enter()
  2078. {
  2079. $post = $this->input->post(NULL, TRUE);
  2080. if (isset($post['s'])) {
  2081. $id_arr = $this->input->post('s');
  2082. $id_arr = explode(',', $id_arr);
  2083. if (!$id_arr) {
  2084. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2085. exit;
  2086. }
  2087. //循环删除记录
  2088. foreach ($id_arr as $v) {
  2089. $sid = $this->whlabel->read($v);
  2090. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2091. if ($count > 0) {
  2092. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2093. exit;
  2094. }
  2095. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2096. foreach ($info_list as $va) {
  2097. $this->whlabel->remove($va['id']);
  2098. }
  2099. }
  2100. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2101. exit;
  2102. }
  2103. $sp = array();
  2104. $s = $this->shop->find_all('1=1', 'id,shopname');
  2105. foreach ($s as $v) {
  2106. $sp[$v['id']] = $v['shopname'];
  2107. }
  2108. $wh = array();
  2109. $w = $this->warehouse->find_all('1=1', 'id,title');
  2110. foreach ($w as $v) {
  2111. $wh[$v['id']] = $v['title'];
  2112. }
  2113. if (isset($post['page'])) {
  2114. $page = $this->input->post('page', true);
  2115. $perpage = $this->input->post('perpage', true);
  2116. $category = $this->input->post('category', true);
  2117. $size = $this->input->post('size', true);
  2118. $grade = $this->input->post('grade', true);
  2119. $color = $this->input->post('color', true);
  2120. $lowe = $this->input->post('lowe', true);
  2121. $sku = $this->input->post('sku', true);
  2122. $warehouse = $this->input->post('warehouse', true);
  2123. $purchase = $this->input->post('purchase', true);
  2124. $ktime = $this->input->post('ktime', true);
  2125. $jtime = $this->input->post('jtime', true);
  2126. $ktime = strtotime($ktime);
  2127. $jtime = strtotime($jtime);
  2128. $where = "1=1";
  2129. $gj = "";
  2130. $ck = "";
  2131. if ($category) {
  2132. $where .= " and features like '%-$category-%'";
  2133. }
  2134. if ($size) {
  2135. $where .= " and features like '%-$size-%'";
  2136. }
  2137. if ($grade) {
  2138. $where .= " and features like '%-$grade-%'";
  2139. }
  2140. if ($color) {
  2141. $where .= " and features like '%-$color-%'";
  2142. }
  2143. if ($lowe) {
  2144. $where .= " and features like '%-$lowe-%'";
  2145. }
  2146. if ($warehouse) {
  2147. $where .= " and warehouse = '$warehouse'";
  2148. }
  2149. if ($purchase) {
  2150. $where .= " and purchase = '$purchase'";
  2151. }
  2152. if ($sku) {
  2153. $where .= " and sku like '%$sku%'";
  2154. }
  2155. if ($ktime && $jtime) {
  2156. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2157. }
  2158. //数据排序
  2159. $order_str = "enter desc";
  2160. if (empty($page)) {
  2161. $start = 0;
  2162. $perpage = 1;
  2163. } else {
  2164. $start = ($page - 1) * $perpage;
  2165. }
  2166. //取得信息列表
  2167. $info_list = $this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2168. foreach ($info_list as $k => $v) {
  2169. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2170. if ($v['shop'] == '') {
  2171. $s = '通用';
  2172. } else {
  2173. $info_list[$k]['shop'] = '';
  2174. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2175. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2176. }
  2177. }
  2178. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2179. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2180. $info_list[$k]['g'] = $g;
  2181. }
  2182. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2183. $total = count($this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,sku,title,features,number'));
  2184. $pagenum = ceil($total / $perpage);
  2185. $over = $total - ($start + $perpage);
  2186. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2187. echo json_encode($rows);
  2188. exit;
  2189. }
  2190. $this->_Template('whlabel_enter', $this->data);
  2191. }
  2192. //出库浏览
  2193. public function _out()
  2194. {
  2195. $post = $this->input->post(NULL, TRUE);
  2196. if (isset($post['page'])) {
  2197. $page = $this->input->post('page', true);
  2198. $perpage = $this->input->post('perpage', true);
  2199. $category = $this->input->post('category', true);
  2200. $size = $this->input->post('size', true);
  2201. $grade = $this->input->post('grade', true);
  2202. $color = $this->input->post('color', true);
  2203. $lowe = $this->input->post('lowe', true);
  2204. $sku = $this->input->post('sku', true);
  2205. $warehouse = $this->input->post('warehouse', true);
  2206. $purchase = $this->input->post('purchase', true);
  2207. $state = $this->input->post('state', true);
  2208. $ktime = $this->input->post('ktime', true);
  2209. $jtime = $this->input->post('jtime', true);
  2210. $ktime = strtotime($ktime);
  2211. $jtime = strtotime($jtime);
  2212. $where = "state=3";
  2213. $gj = "";
  2214. $ck = "";
  2215. if ($category) {
  2216. $where .= " and features like '%-$category-%'";
  2217. }
  2218. if ($size) {
  2219. $where .= " and features like '%-$size-%'";
  2220. }
  2221. if ($grade) {
  2222. $where .= " and features like '%-$grade-%'";
  2223. }
  2224. if ($color) {
  2225. $where .= " and features like '%-$color-%'";
  2226. }
  2227. if ($lowe) {
  2228. $where .= " and features like '%-$lowe-%'";
  2229. }
  2230. if ($state) {
  2231. $where .= " and state = '$state'";
  2232. }
  2233. if ($warehouse) {
  2234. $where .= " and warehouse = '$warehouse'";
  2235. }
  2236. if ($purchase) {
  2237. $where .= " and purchase = '$purchase'";
  2238. }
  2239. if ($sku) {
  2240. $where .= " and sku = '$sku'";
  2241. }
  2242. if ($ktime && $jtime) {
  2243. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2244. }
  2245. //数据排序
  2246. $order_str = "id desc";
  2247. if (empty($page)) {
  2248. $start = 0;
  2249. $perpage = 1;
  2250. } else {
  2251. $start = ($page - 1) * $perpage;
  2252. }
  2253. //取得信息列表
  2254. $info_list = $this->whlabel->find_all($where, 'sku');
  2255. $rows = array();
  2256. $list = array();
  2257. foreach ($info_list as $key => $value) {
  2258. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2259. }
  2260. $rows = array_unique($rows); //删除重复记录
  2261. foreach ($rows as $key => $value) {
  2262. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2263. $ck = $this->warehouse->read($data['warehouse']);
  2264. $warehouse = $ck['title'];
  2265. $gy = $this->purchase->read($data['purchase']);
  2266. $purchase = $gy['purchase'];
  2267. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2268. $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);
  2269. }
  2270. $total = count($list);
  2271. $pagenum = ceil($total / $perpage);
  2272. $over = $total - ($start + $perpage);
  2273. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2274. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2275. echo json_encode($rows);
  2276. exit;
  2277. }
  2278. $this->_Template('whlabel_out', $this->data);
  2279. }
  2280. //出库标签浏览
  2281. public function _label()
  2282. {
  2283. $post = $this->input->post(NULL, TRUE);
  2284. if (isset($post['page'])) {
  2285. $page = $this->input->post('page', true);
  2286. $perpage = $this->input->post('perpage', true);
  2287. $sku = $this->input->post('sku', true);
  2288. $warehouse = $this->input->post('warehouse', true);
  2289. $purchase = $this->input->post('purchase', true);
  2290. $orderinfo = $this->input->post('orderinfo', true);
  2291. $waybill = $this->input->post('waybill', true);
  2292. $category = $this->input->post('category', true);
  2293. $size = $this->input->post('size', true);
  2294. $grade = $this->input->post('grade', true);
  2295. $color = $this->input->post('color', true);
  2296. $lowe = $this->input->post('lowe', true);
  2297. $where = "state=1";
  2298. if ($sku) {
  2299. $where .= " and sku = '$sku'";
  2300. }
  2301. if ($warehouse) {
  2302. $where .= " and warehouse = '$warehouse'";
  2303. }
  2304. if ($purchase) {
  2305. $where .= " and purchase = '$purchase'";
  2306. }
  2307. if ($orderinfo) {
  2308. $where .= " and orderinfo = '$orderinfo'";
  2309. }
  2310. if ($waybill) {
  2311. $where .= " and waybill = '$waybill'";
  2312. }
  2313. if ($category) {
  2314. $where .= " and features like '%-$category-%'";
  2315. }
  2316. if ($size) {
  2317. $where .= " and features like '%-$size-%'";
  2318. }
  2319. if ($grade) {
  2320. $where .= " and features like '%-$grade-%'";
  2321. }
  2322. if ($color) {
  2323. $where .= " and features like '%-$color-%'";
  2324. }
  2325. if ($lowe) {
  2326. $where .= " and features like '%-$lowe-%'";
  2327. }
  2328. //数据排序
  2329. $order_str = "outk desc";
  2330. if (empty($page)) {
  2331. $start = 0;
  2332. $perpage = 1;
  2333. } else {
  2334. $start = ($page - 1) * $perpage;
  2335. }
  2336. //取得信息列表
  2337. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2338. foreach ($info_list as $key => $value) {
  2339. $warehouse = $this->warehouse->read($value['warehouse']);
  2340. $info_list[$key]['warehouse'] = $warehouse['title'];
  2341. $purchase = $this->purchase->read($value['purchase']);
  2342. $info_list[$key]['purchase'] = $purchase['title'];
  2343. if ($value['outk'] != 0) {
  2344. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2345. } else {
  2346. $info_list[$key]['outk'] = "";
  2347. }
  2348. if ($value['orderinfo'] == 0) {
  2349. $info_list[$key]['orderinfo'] = "";
  2350. }
  2351. if ($value['waybill'] == 0) {
  2352. $info_list[$key]['waybill'] = "";
  2353. }
  2354. }
  2355. $total = $this->whlabel->find_count($where);
  2356. $pagenum = ceil($total / $perpage);
  2357. $over = $total - ($start + $perpage);
  2358. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2359. echo json_encode($rows);
  2360. exit;
  2361. }
  2362. $this->_Template('whlabel_label', $this->data);
  2363. }
  2364. //独立站出库订单
  2365. public function _outorder()
  2366. {
  2367. if (isset($_SESSION['api'])) {
  2368. $user = $this->user->get_api($_SESSION['api']);
  2369. $usp = $user;
  2370. $fgshop = "";
  2371. $sid = "";
  2372. $user = explode('|', trim($user['shop'], '|'));
  2373. foreach ($user as $value) {
  2374. $fgshop .= " shop = " . $value . " or";
  2375. $sid .= " id = " . $value . " or";
  2376. }
  2377. } else {
  2378. echo "请重新登录";
  2379. }
  2380. $post = $this->input->post(NULL, TRUE);
  2381. if (isset($post['page'])) {
  2382. $page = $this->input->post('page', true);
  2383. $perpage = $this->input->post('perpage', true);
  2384. $warehouse = $this->input->post('warehouse', true);
  2385. $xztime = $this->input->post('xztime', true);
  2386. $timetk = $this->input->post('timetkk', true);
  2387. $timetj = $this->input->post('timetjj', true);
  2388. $shop = $this->input->post('shop', true);
  2389. $source = $this->input->post('source', true);
  2390. $orderinfo = $this->input->post('orderinfo', true);
  2391. $number = $this->input->post('number', true);
  2392. $sfxh = $this->input->post('sfxh', true);
  2393. $express = $this->input->post('express', true);
  2394. $waybill = $this->input->post('waybill', true);
  2395. $library = $this->input->post('library', true);
  2396. $country = $this->input->post('country', true);
  2397. $so = $this->input->post('so', true);
  2398. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2399. $print = $this->input->post('print', true);
  2400. $state = $this->input->post('state', true);
  2401. $orderurl = $this->input->post('orderurl', true);
  2402. $timetk = strtotime($timetk);
  2403. $timetj = strtotime($timetj);
  2404. /**
  2405. $sj = $this->input->post('sj',true);
  2406. if($sj)
  2407. {
  2408. $sj = $this->input->post('sj',true);
  2409. }
  2410. else
  2411. {
  2412. $sj = "fullorder";
  2413. }
  2414. **/
  2415. $sj = "fullorder";
  2416. $where = "1=1";
  2417. if ($warehouse) {
  2418. $where .= " and type = '$warehouse'";
  2419. }
  2420. if ($timetk && $timetj) {
  2421. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2422. }
  2423. if ($orderinfo) {
  2424. $where .= " and orderinfo = '$orderinfo'";
  2425. }
  2426. if ($number) {
  2427. $where .= " and number = '$number'";
  2428. }
  2429. if ($express) {
  2430. $where .= " and express = '$express'";
  2431. }
  2432. if ($waybill) {
  2433. $where .= " and waybill = '$waybill'";
  2434. }
  2435. if ($library) {
  2436. $where .= " and library = '$library'";
  2437. }
  2438. if ($print) {
  2439. $where .= " and print = '$print'";
  2440. }
  2441. if ($libraryconfirm) {
  2442. $where .= " and libraryconfirm = '$libraryconfirm'";
  2443. }
  2444. if ($state) {
  2445. $where .= " and state = '$state'";
  2446. }
  2447. if ($shop) {
  2448. $where .= " and shop = '$shop'";
  2449. }
  2450. if ($country) {
  2451. $where .= " and country = '$country'";
  2452. }
  2453. if ($sfxh != '') {
  2454. $where .= " and sfxh = '$sfxh'";
  2455. }
  2456. if ($so) {
  2457. $where .= " and shipremarks like '%$so%'";
  2458. }
  2459. if ($source) {
  2460. if ($source == '2d') {
  2461. $where .= " and source >= '2'";
  2462. } else {
  2463. $where .= " and source = '$source'";
  2464. }
  2465. }
  2466. if (isset($_SESSION['api'])) {
  2467. foreach ($user as $value) {
  2468. $fgshop .= " shop = " . $value . " or";
  2469. }
  2470. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2471. }
  2472. if ($orderurl) {
  2473. $url = $this->orderurl->read($orderurl);
  2474. $where .= " and link like '%" . $url['url'] . "%'";
  2475. }
  2476. //数据排序
  2477. $order_str = "librarytime desc";
  2478. if (empty($page)) {
  2479. $start = 0;
  2480. $perpage = 1;
  2481. } else {
  2482. $start = ($page - 1) * $perpage;
  2483. }
  2484. //取得信息列表
  2485. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2486. //格式化数据
  2487. foreach ($info_list as $key => $value) {
  2488. $shop = $this->shop->read($value['shop']);
  2489. $info_list[$key]['shop'] = $shop['shopname'];
  2490. $express = $this->express->read($value['express']);
  2491. $info_list[$key]['express'] = $express['servicename'];
  2492. $warehouse = $this->warehouse->read($value['type']);
  2493. $info_list[$key]['type'] = $warehouse['title'];
  2494. if ($value['librarytime'] == '0') {
  2495. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2496. } else {
  2497. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2498. }
  2499. }
  2500. $total = $this->$sj->find_count($where);
  2501. $pagenum = ceil($total / $perpage);
  2502. $over = $total - ($start + $perpage);
  2503. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2504. echo json_encode($rows);
  2505. exit;
  2506. }
  2507. $this->data['express'] = $this->express->find_all();
  2508. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2509. $this->data['wlshop'] = $wlshop;
  2510. $user = $this->user->get_api($_SESSION['api']);
  2511. $powerid = $this->power->read($user['power']);
  2512. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2513. $pid = '';
  2514. foreach ($powertext as $v) {
  2515. $pid .= " id = " . $v . " or";
  2516. }
  2517. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2518. $this->data['fullorderexcel'] = $fullorderexcel;
  2519. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2520. $this->data['orderurl'] = $orderurl;
  2521. $this->_Template('whlabel_outorder', $this->data);
  2522. }
  2523. //tt出库
  2524. public function _toutorder()
  2525. {
  2526. if (isset($_SESSION['api'])) {
  2527. $user = $this->user->get_api($_SESSION['api']);
  2528. $usp = $user;
  2529. $fgshop = "";
  2530. $sid = "";
  2531. $user = explode('|', trim($user['shop'], '|'));
  2532. foreach ($user as $value) {
  2533. $fgshop .= " shop = " . $value . " or";
  2534. $sid .= " id = " . $value . " or";
  2535. }
  2536. } else {
  2537. echo "请重新登录";
  2538. }
  2539. $post = $this->input->post(NULL, TRUE);
  2540. if (isset($post['page'])) {
  2541. $page = $this->input->post('page', true);
  2542. $perpage = $this->input->post('perpage', true);
  2543. $warehouse = $this->input->post('warehouse', true);
  2544. $xztime = $this->input->post('xztime', true);
  2545. $timetk = $this->input->post('timetkk', true);
  2546. $timetj = $this->input->post('timetjj', true);
  2547. $shop = $this->input->post('shop', true);
  2548. $source = $this->input->post('source', true);
  2549. $orderinfo = $this->input->post('orderinfo', true);
  2550. $number = $this->input->post('number', true);
  2551. $sfxh = $this->input->post('sfxh', true);
  2552. $express = $this->input->post('express', true);
  2553. $waybill = $this->input->post('waybill', true);
  2554. $library = $this->input->post('library', true);
  2555. $country = $this->input->post('country', true);
  2556. $so = $this->input->post('so', true);
  2557. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2558. $print = $this->input->post('print', true);
  2559. $state = $this->input->post('state', true);
  2560. $orderurl = $this->input->post('orderurl', true);
  2561. $timetk = strtotime($timetk);
  2562. $timetj = strtotime($timetj);
  2563. /**
  2564. $sj = $this->input->post('sj',true);
  2565. if($sj)
  2566. {
  2567. $sj = $this->input->post('sj',true);
  2568. }
  2569. else
  2570. {
  2571. $sj = "fullorder";
  2572. }
  2573. **/
  2574. $sj = "fullordertt";
  2575. $where = "1=1";
  2576. if ($warehouse) {
  2577. $where .= " and type = '$warehouse'";
  2578. }
  2579. if ($timetk && $timetj) {
  2580. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2581. }
  2582. if ($orderinfo) {
  2583. $where .= " and orderinfo = '$orderinfo'";
  2584. }
  2585. if ($number) {
  2586. $where .= " and number = '$number'";
  2587. }
  2588. if ($express) {
  2589. $where .= " and express = '$express'";
  2590. }
  2591. if ($waybill) {
  2592. $where .= " and waybill = '$waybill'";
  2593. }
  2594. if ($library) {
  2595. $where .= " and library = '$library'";
  2596. }
  2597. if ($print) {
  2598. $where .= " and print = '$print'";
  2599. }
  2600. if ($libraryconfirm) {
  2601. $where .= " and libraryconfirm = '$libraryconfirm'";
  2602. }
  2603. if ($state) {
  2604. $where .= " and state = '$state'";
  2605. }
  2606. if ($shop) {
  2607. $where .= " and shop = '$shop'";
  2608. }
  2609. if ($country) {
  2610. $where .= " and country = '$country'";
  2611. }
  2612. if ($sfxh != '') {
  2613. $where .= " and sfxh = '$sfxh'";
  2614. }
  2615. if ($so) {
  2616. $where .= " and shipremarks like '%$so%'";
  2617. }
  2618. if ($source) {
  2619. if ($source == '2d') {
  2620. $where .= " and source >= '2'";
  2621. } else {
  2622. $where .= " and source = '$source'";
  2623. }
  2624. }
  2625. if (isset($_SESSION['api'])) {
  2626. foreach ($user as $value) {
  2627. $fgshop .= " shop = " . $value . " or";
  2628. }
  2629. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2630. }
  2631. if ($orderurl) {
  2632. $url = $this->orderurl->read($orderurl);
  2633. $where .= " and link like '%" . $url['url'] . "%'";
  2634. }
  2635. //数据排序
  2636. $order_str = "librarytime desc";
  2637. if (empty($page)) {
  2638. $start = 0;
  2639. $perpage = 1;
  2640. } else {
  2641. $start = ($page - 1) * $perpage;
  2642. }
  2643. //取得信息列表
  2644. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2645. //格式化数据
  2646. foreach ($info_list as $key => $value) {
  2647. $shop = $this->shop->read($value['shop']);
  2648. $info_list[$key]['shop'] = $shop['shopname'];
  2649. $express = $this->express->read($value['express']);
  2650. $info_list[$key]['express'] = $express['servicename'];
  2651. $warehouse = $this->warehouse->read($value['type']);
  2652. $info_list[$key]['type'] = $warehouse['title'];
  2653. if ($value['librarytime'] == '0') {
  2654. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2655. } else {
  2656. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2657. }
  2658. }
  2659. $total = $this->$sj->find_count($where);
  2660. $pagenum = ceil($total / $perpage);
  2661. $over = $total - ($start + $perpage);
  2662. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2663. echo json_encode($rows);
  2664. exit;
  2665. }
  2666. $this->data['express'] = $this->express->find_all();
  2667. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2668. $this->data['wlshop'] = $wlshop;
  2669. $user = $this->user->get_api($_SESSION['api']);
  2670. $powerid = $this->power->read($user['power']);
  2671. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2672. $pid = '';
  2673. foreach ($powertext as $v) {
  2674. $pid .= " id = " . $v . " or";
  2675. }
  2676. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2677. $this->data['fullorderexcel'] = $fullorderexcel;
  2678. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2679. $this->data['orderurl'] = $orderurl;
  2680. $this->_Template('whlabel_toutorder', $this->data);
  2681. }
  2682. //tt出库
  2683. public function _aoutorder()
  2684. {
  2685. if (isset($_SESSION['api'])) {
  2686. $user = $this->user->get_api($_SESSION['api']);
  2687. $usp = $user;
  2688. $fgshop = "";
  2689. $sid = "";
  2690. $user = explode('|', trim($user['shop'], '|'));
  2691. foreach ($user as $value) {
  2692. $fgshop .= " shop = " . $value . " or";
  2693. $sid .= " id = " . $value . " or";
  2694. }
  2695. } else {
  2696. echo "请重新登录";
  2697. }
  2698. $post = $this->input->post(NULL, TRUE);
  2699. if (isset($post['page'])) {
  2700. $page = $this->input->post('page', true);
  2701. $perpage = $this->input->post('perpage', true);
  2702. $warehouse = $this->input->post('warehouse', true);
  2703. $xztime = $this->input->post('xztime', true);
  2704. $timetk = $this->input->post('timetkk', true);
  2705. $timetj = $this->input->post('timetjj', true);
  2706. $shop = $this->input->post('shop', true);
  2707. $source = $this->input->post('source', true);
  2708. $orderinfo = $this->input->post('orderinfo', true);
  2709. $number = $this->input->post('number', true);
  2710. $sfxh = $this->input->post('sfxh', true);
  2711. $express = $this->input->post('express', true);
  2712. $waybill = $this->input->post('waybill', true);
  2713. $library = $this->input->post('library', true);
  2714. $country = $this->input->post('country', true);
  2715. $so = $this->input->post('so', true);
  2716. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2717. $print = $this->input->post('print', true);
  2718. $state = $this->input->post('state', true);
  2719. $orderurl = $this->input->post('orderurl', true);
  2720. $timetk = strtotime($timetk);
  2721. $timetj = strtotime($timetj);
  2722. /**
  2723. $sj = $this->input->post('sj',true);
  2724. if($sj)
  2725. {
  2726. $sj = $this->input->post('sj',true);
  2727. }
  2728. else
  2729. {
  2730. $sj = "fullorder";
  2731. }
  2732. **/
  2733. $sj = "fullorderamz";
  2734. $where = "1=1";
  2735. if ($warehouse) {
  2736. $where .= " and type = '$warehouse'";
  2737. }
  2738. if ($timetk && $timetj) {
  2739. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2740. }
  2741. if ($orderinfo) {
  2742. $where .= " and orderinfo = '$orderinfo'";
  2743. }
  2744. if ($number) {
  2745. $where .= " and number = '$number'";
  2746. }
  2747. if ($express) {
  2748. $where .= " and express = '$express'";
  2749. }
  2750. if ($waybill) {
  2751. $where .= " and waybill = '$waybill'";
  2752. }
  2753. if ($library) {
  2754. $where .= " and library = '$library'";
  2755. }
  2756. if ($print) {
  2757. $where .= " and print = '$print'";
  2758. }
  2759. if ($libraryconfirm) {
  2760. $where .= " and libraryconfirm = '$libraryconfirm'";
  2761. }
  2762. if ($state) {
  2763. $where .= " and state = '$state'";
  2764. }
  2765. if ($shop) {
  2766. $where .= " and shop = '$shop'";
  2767. }
  2768. if ($country) {
  2769. $where .= " and country = '$country'";
  2770. }
  2771. if ($sfxh != '') {
  2772. $where .= " and sfxh = '$sfxh'";
  2773. }
  2774. if ($so) {
  2775. $where .= " and shipremarks like '%$so%'";
  2776. }
  2777. if ($source) {
  2778. if ($source == '2d') {
  2779. $where .= " and source >= '2'";
  2780. } else {
  2781. $where .= " and source = '$source'";
  2782. }
  2783. }
  2784. if (isset($_SESSION['api'])) {
  2785. foreach ($user as $value) {
  2786. $fgshop .= " shop = " . $value . " or";
  2787. }
  2788. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2789. }
  2790. if ($orderurl) {
  2791. $url = $this->orderurl->read($orderurl);
  2792. $where .= " and link like '%" . $url['url'] . "%'";
  2793. }
  2794. //数据排序
  2795. $order_str = "librarytime desc";
  2796. if (empty($page)) {
  2797. $start = 0;
  2798. $perpage = 1;
  2799. } else {
  2800. $start = ($page - 1) * $perpage;
  2801. }
  2802. //取得信息列表
  2803. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2804. //格式化数据
  2805. foreach ($info_list as $key => $value) {
  2806. $shop = $this->shop->read($value['shop']);
  2807. $info_list[$key]['shop'] = $shop['shopname'];
  2808. $express = $this->express->read($value['express']);
  2809. $info_list[$key]['express'] = $express['servicename'];
  2810. $warehouse = $this->warehouse->read($value['type']);
  2811. $info_list[$key]['type'] = $warehouse['title'];
  2812. if ($value['librarytime'] == '0') {
  2813. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2814. } else {
  2815. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2816. }
  2817. }
  2818. $total = $this->$sj->find_count($where);
  2819. $pagenum = ceil($total / $perpage);
  2820. $over = $total - ($start + $perpage);
  2821. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2822. echo json_encode($rows);
  2823. exit;
  2824. }
  2825. $this->data['express'] = $this->express->find_all();
  2826. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2827. $this->data['wlshop'] = $wlshop;
  2828. $user = $this->user->get_api($_SESSION['api']);
  2829. $powerid = $this->power->read($user['power']);
  2830. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2831. $pid = '';
  2832. foreach ($powertext as $v) {
  2833. $pid .= " id = " . $v . " or";
  2834. }
  2835. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2836. $this->data['fullorderexcel'] = $fullorderexcel;
  2837. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2838. $this->data['orderurl'] = $orderurl;
  2839. $this->_Template('whlabel_aoutorder', $this->data);
  2840. }
  2841. //速卖通出库订单
  2842. public function _soutorder()
  2843. {
  2844. if (isset($_SESSION['api'])) {
  2845. $user = $this->user->get_api($_SESSION['api']);
  2846. $usp = $user;
  2847. $fgshop = "";
  2848. $sid = "";
  2849. $user = explode('|', trim($user['shop'], '|'));
  2850. foreach ($user as $value) {
  2851. $sid .= " id = " . $value . " or";
  2852. }
  2853. }
  2854. $post = $this->input->post(NULL, TRUE);
  2855. if (isset($post['page'])) {
  2856. $page = $this->input->post('page', true);
  2857. $perpage = $this->input->post('perpage', true);
  2858. $warehouse = $this->input->post('warehouse', true);
  2859. $xztime = $this->input->post('xztime', true);
  2860. $timetk = $this->input->post('timetkk', true);
  2861. $timetj = $this->input->post('timetjj', true);
  2862. $shop = $this->input->post('shop', true);
  2863. $source = $this->input->post('source', true);
  2864. $orderinfo = $this->input->post('orderinfo', true);
  2865. $number = $this->input->post('number', true);
  2866. $express = $this->input->post('express', true);
  2867. $waybill = $this->input->post('waybill', true);
  2868. $library = $this->input->post('library', true);
  2869. $country = $this->input->post('country', true);
  2870. $sfxh = $this->input->post('sfxh', true);
  2871. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2872. $print = $this->input->post('print', true);
  2873. $state = $this->input->post('state', true);
  2874. $so = $this->input->post('so', true);
  2875. $timetk = strtotime($timetk);
  2876. $timetj = strtotime($timetj);
  2877. /**
  2878. $sj = $this->input->post('sj',true);
  2879. if($sj)
  2880. {
  2881. $sj = $this->input->post('sj',true);
  2882. }
  2883. else
  2884. {
  2885. $sj = "fullorder";
  2886. }
  2887. **/
  2888. $sj = "fullordersmt";
  2889. $where = "1=1";
  2890. if ($warehouse) {
  2891. $where .= " and type = '$warehouse'";
  2892. }
  2893. if ($timetk && $timetj) {
  2894. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2895. }
  2896. if ($orderinfo) {
  2897. $where .= " and orderinfo = '$orderinfo'";
  2898. }
  2899. if ($number) {
  2900. $where .= " and number = '$number'";
  2901. }
  2902. if ($express) {
  2903. $where .= " and express = '$express'";
  2904. }
  2905. if ($waybill) {
  2906. $where .= " and waybill = '$waybill'";
  2907. }
  2908. if ($library) {
  2909. $where .= " and library = '$library'";
  2910. }
  2911. if ($print) {
  2912. $where .= " and print = '$print'";
  2913. }
  2914. if ($libraryconfirm) {
  2915. $where .= " and libraryconfirm = '$libraryconfirm'";
  2916. }
  2917. if ($state) {
  2918. $where .= " and state = '$state'";
  2919. }
  2920. if ($shop) {
  2921. $where .= " and shop = '$shop'";
  2922. }
  2923. if ($sfxh != '') {
  2924. $where .= " and sfxh = '$sfxh'";
  2925. }
  2926. if ($so) {
  2927. $where .= " and shipremarks like '%$so%'";
  2928. }
  2929. if ($source) {
  2930. $where .= " and source = '$source'";
  2931. }
  2932. if ($country) {
  2933. $where .= " and country = '$country'";
  2934. } else {
  2935. if (isset($_SESSION['api'])) {
  2936. foreach ($user as $value) {
  2937. $fgshop .= " shop = " . $value . " or";
  2938. }
  2939. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2940. }
  2941. }
  2942. //数据排序
  2943. $order_str = "librarytime desc";
  2944. if (empty($page)) {
  2945. $start = 0;
  2946. $perpage = 1;
  2947. } else {
  2948. $start = ($page - 1) * $perpage;
  2949. }
  2950. //取得信息列表
  2951. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2952. //格式化数据
  2953. foreach ($info_list as $key => $value) {
  2954. $shop = $this->shop->read($value['shop']);
  2955. $info_list[$key]['shop'] = $shop['shopname'];
  2956. $express = $this->express->read($value['express']);
  2957. $info_list[$key]['express'] = $express['servicename'];
  2958. $warehouse = $this->warehouse->read($value['type']);
  2959. $info_list[$key]['type'] = $warehouse['title'];
  2960. if ($value['librarytime'] == '0') {
  2961. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2962. } else {
  2963. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2964. }
  2965. }
  2966. $total = $this->$sj->find_count($where);
  2967. $pagenum = ceil($total / $perpage);
  2968. $over = $total - ($start + $perpage);
  2969. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2970. echo json_encode($rows);
  2971. exit;
  2972. }
  2973. $this->data['express'] = $this->express->find_all();
  2974. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2975. $this->data['wlshop'] = $wlshop;
  2976. $user = $this->user->get_api($_SESSION['api']);
  2977. $powerid = $this->power->read($user['power']);
  2978. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2979. $pid = '';
  2980. foreach ($powertext as $v) {
  2981. $pid .= " id = " . $v . " or";
  2982. }
  2983. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2984. $this->data['fullorderexcel'] = $fullorderexcel;
  2985. $this->_Template('whlabel_soutorder', $this->data);
  2986. }
  2987. //订单退库
  2988. public function _retreat()
  2989. {
  2990. $post = $this->input->post(NULL, TRUE);
  2991. if (isset($post['page'])) {
  2992. $page = $this->input->post('page', true);
  2993. $perpage = $this->input->post('perpage', true);
  2994. $warehouse = $this->input->post('warehouse', true);
  2995. $timetk = $this->input->post('timetk', true);
  2996. $timetj = $this->input->post('timetj', true);
  2997. $shop = $this->input->post('shop', true);
  2998. $source = $this->input->post('source', true);
  2999. $state = $this->input->post('state', true);
  3000. $review = $this->input->post('review', true);
  3001. $state = $this->input->post('state', true);
  3002. $express = $this->input->post('express', true);
  3003. $orderinfo = $this->input->post('orderinfo', true);
  3004. $user = $this->input->post('user', true);
  3005. $name = $this->input->post('name', true);
  3006. $waybill = $this->input->post('waybill', true);
  3007. $timetk = strtotime($timetk);
  3008. $timetj = strtotime($timetj);
  3009. $where = "(state=206 or state=210) and mergeid = 0";
  3010. if ($warehouse) {
  3011. $where .= " and state = '$warehouse'";
  3012. }
  3013. if ($timetk && $timetj) {
  3014. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3015. }
  3016. if ($shop) {
  3017. $where .= " and shop = '$shop'";
  3018. }
  3019. if ($source) {
  3020. $where .= " and source = '$source'";
  3021. }
  3022. if ($state) {
  3023. $where .= " and state = '$state'";
  3024. }
  3025. if ($review) {
  3026. $where .= " and review = '$review'";
  3027. }
  3028. if ($state) {
  3029. $where .= " and state = '$state'";
  3030. }
  3031. if ($express) {
  3032. $where .= " and express = '$express'";
  3033. }
  3034. if ($orderinfo) {
  3035. $where .= " and orderinfo = '$orderinfo'";
  3036. }
  3037. if ($user) {
  3038. $where .= " and user = '$user'";
  3039. }
  3040. if ($name) {
  3041. $where .= " and name = '$name'";
  3042. }
  3043. if ($waybill) {
  3044. $where .= " and waybill = '$waybill'";
  3045. }
  3046. //数据排序
  3047. $order_str = "id desc";
  3048. if (empty($page)) {
  3049. $start = 0;
  3050. $perpage = 1;
  3051. } else {
  3052. $start = ($page - 1) * $perpage;
  3053. }
  3054. //取得信息列表
  3055. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3056. //格式化数据
  3057. foreach ($info_list as $key => $value) {
  3058. $shop = $this->shop->read($value['shop']);
  3059. $info_list[$key]['shop'] = $shop['shopname'];
  3060. $warehouse = $this->warehouse->read($value['warehouse']);
  3061. $info_list[$key]['warehouse'] = $warehouse['title'];
  3062. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3063. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3064. if ($value['waybill'] == 0) {
  3065. $info_list[$key]['waybill'] = "";
  3066. }
  3067. $express = $this->express->read($value['express']);
  3068. $info_list[$key]['express'] = $express['title'];
  3069. $typeclass = $this->typeclass->read($value['state']);
  3070. $info_list[$key]['state'] = $typeclass['title'];
  3071. }
  3072. $total = $this->fullorder->find_count($where);
  3073. $pagenum = ceil($total / $perpage);
  3074. $over = $total - ($start + $perpage);
  3075. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3076. echo json_encode($rows);
  3077. exit;
  3078. }
  3079. $this->data['express'] = $this->express->find_all();
  3080. $this->_Template('whlabel_retreat', $this->data);
  3081. }
  3082. //退库标签浏览
  3083. public function _retreatlk()
  3084. {
  3085. $post = $this->input->post(NULL, TRUE);
  3086. if (isset($post['page'])) {
  3087. $page = $this->input->post('page', true);
  3088. $perpage = $this->input->post('perpage', true);
  3089. $timetk = $this->input->post('timetk', true);
  3090. $timetj = $this->input->post('timetj', true);
  3091. $sku = $this->input->post('sku', true);
  3092. $warehouse = $this->input->post('warehouse', true);
  3093. $purchase = $this->input->post('purchase', true);
  3094. $orderinfo = $this->input->post('orderinfo', true);
  3095. $waybill = $this->input->post('waybill', true);
  3096. $category = $this->input->post('category', true);
  3097. $size = $this->input->post('size', true);
  3098. $grade = $this->input->post('grade', true);
  3099. $color = $this->input->post('color', true);
  3100. $lowe = $this->input->post('lowe', true);
  3101. $state = $this->input->post('state', true);
  3102. $timetk = strtotime($timetk);
  3103. $timetj = strtotime($timetj);
  3104. $where = "state=2";
  3105. if ($timetk && $timetj) {
  3106. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3107. }
  3108. if ($sku) {
  3109. $where .= " and sku = '$sku'";
  3110. }
  3111. if ($warehouse) {
  3112. $where .= " and warehouse = '$warehouse'";
  3113. }
  3114. if ($purchase) {
  3115. $where .= " and purchase = '$purchase'";
  3116. }
  3117. if ($orderinfo) {
  3118. $where .= " and orderinfo = '$orderinfo'";
  3119. }
  3120. if ($waybill) {
  3121. $where .= " and waybill = '$waybill'";
  3122. }
  3123. if ($category) {
  3124. $where .= " and features like '%-$category-%'";
  3125. }
  3126. if ($size) {
  3127. $where .= " and features like '%-$size-%'";
  3128. }
  3129. if ($grade) {
  3130. $where .= " and features like '%-$grade-%'";
  3131. }
  3132. if ($color) {
  3133. $where .= " and features like '%-$color-%'";
  3134. }
  3135. if ($lowe) {
  3136. $where .= " and features like '%-$lowe-%'";
  3137. }
  3138. //数据排序
  3139. $order_str = "time desc";
  3140. if (empty($page)) {
  3141. $start = 0;
  3142. $perpage = 1;
  3143. } else {
  3144. $start = ($page - 1) * $perpage;
  3145. }
  3146. //取得信息列表
  3147. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3148. foreach ($info_list as $key => $value) {
  3149. $warehouse = $this->warehouse->read($value['warehouse']);
  3150. $info_list[$key]['warehouse'] = $warehouse['title'];
  3151. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3152. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3153. $purchase = $this->purchase->read($value['purchase']);
  3154. $info_list[$key]['purchase'] = $purchase['title'];
  3155. if ($value['outk'] != 0) {
  3156. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3157. } else {
  3158. $info_list[$key]['outk'] = "";
  3159. }
  3160. if ($value['retreat'] != 0) {
  3161. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3162. } else {
  3163. $info_list[$key]['retreat'] = "";
  3164. }
  3165. if ($value['orderinfo'] == 0) {
  3166. $info_list[$key]['orderinfo'] = "";
  3167. }
  3168. if ($value['waybill'] == 0) {
  3169. $info_list[$key]['waybill'] = "";
  3170. }
  3171. }
  3172. $total = $this->whlabel->find_count($where);
  3173. $pagenum = ceil($total / $perpage);
  3174. $over = $total - ($start + $perpage);
  3175. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3176. echo json_encode($rows);
  3177. exit;
  3178. }
  3179. $this->_Template('whlabel_retreatlk', $this->data);
  3180. }
  3181. //更换标签及浏览
  3182. public function _change()
  3183. {
  3184. $post = $this->input->post(NULL, TRUE);
  3185. if (isset($post['page'])) {
  3186. $page = $this->input->post('page', true);
  3187. $perpage = $this->input->post('perpage', true);
  3188. $timetk = $this->input->post('timetk', true);
  3189. $timetj = $this->input->post('timetj', true);
  3190. $label = $this->input->post('label', true);
  3191. $oldlabel = $this->input->post('oldlabel', true);
  3192. $timetk = strtotime($timetk);
  3193. $timetj = strtotime($timetj);
  3194. $where = "state=10 ";
  3195. if ($timetk && $timetj) {
  3196. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3197. }
  3198. if ($label) {
  3199. $where .= " and label = '$label'";
  3200. }
  3201. if ($oldlabel) {
  3202. $where .= " and oldlabel = '$oldlabel'";
  3203. }
  3204. //数据排序
  3205. $order_str = "time asc";
  3206. if (empty($page)) {
  3207. $start = 0;
  3208. $perpage = 1;
  3209. } else {
  3210. $start = ($page - 1) * $perpage;
  3211. }
  3212. //取得信息列表
  3213. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3214. foreach ($info_list as $key => $value) {
  3215. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3216. }
  3217. $total = $this->whlabel->find_count($where);
  3218. $pagenum = ceil($total / $perpage);
  3219. $over = $total - ($start + $perpage);
  3220. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3221. echo json_encode($rows);
  3222. exit;
  3223. }
  3224. $this->_Template('whlabel_change', $this->data);
  3225. }
  3226. //产品标签
  3227. public function _cpbqdc()
  3228. {
  3229. if (isset($_GET['excel'])) {
  3230. $where = "1=1";
  3231. //数据排序
  3232. $order_str = "id desc";
  3233. if (empty($page)) {
  3234. $start = 0;
  3235. $perpage = 1;
  3236. } else {
  3237. $start = ($page - 1) * $perpage;
  3238. }
  3239. $warehouse = $this->input->get('warehouse', true);
  3240. $state = $this->input->get('state', true);
  3241. $timetk = $this->input->get('timetkk', true);
  3242. $timetj = $this->input->get('timetjj', true);
  3243. $timetk = strtotime($timetk);
  3244. $timetj = strtotime($timetj);
  3245. if ($warehouse) {
  3246. $where .= " and warehouse = '$warehouse'";
  3247. }
  3248. if ($state || $state == 0) {
  3249. $where .= " and state = '$state'";
  3250. }
  3251. if ($timetk && $timetj) {
  3252. $where .= " and time > '$timetk' and time < '$timetj'";
  3253. }
  3254. //取得信息列表
  3255. $info_list = $this->whlabel->find_all($where, '*');
  3256. $rows = array();
  3257. $list = array();
  3258. foreach ($info_list as $key => $value) {
  3259. $rows[$value['time']] = $value; //所有数据sku
  3260. }
  3261. foreach ($rows as $value) {
  3262. $warehouse = $this->warehouse->read($value['warehouse']);
  3263. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3264. $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);
  3265. }
  3266. $title = "产品标签统计表";
  3267. $titlename = "<table border=1>
  3268. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3269. <tr align='center'>
  3270. <td>仓库</td>
  3271. <td>SKU</td>
  3272. <td>产品</td>
  3273. <td>入库时间</td>
  3274. <td>操作时间</td>
  3275. <td>备注</td>
  3276. <td>数量</td>
  3277. </tr>
  3278. </table>";
  3279. $filename = $title . ".xls";
  3280. $tail = "";
  3281. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3282. }
  3283. }
  3284. //进销存导出
  3285. public function _exceljxc()
  3286. {
  3287. $classid = $this->classid->sku();
  3288. $pm = $classid;
  3289. $typeclass = array();
  3290. $tc = $this->typeclass->find_all();
  3291. foreach ($tc as $v) {
  3292. $typeclass[$v['id']] = $v;
  3293. }
  3294. $prc = array();
  3295. $purchase = $this->purchase->find_all();
  3296. foreach ($purchase as $k => $v) {
  3297. $prc[$v['id']] = $v['title'];
  3298. }
  3299. if (isset($_GET['excel'])) {
  3300. $where = "sku != 'Preset'";
  3301. //数据排序
  3302. $order_str = "id desc";
  3303. if (empty($page)) {
  3304. $start = 0;
  3305. $perpage = 1;
  3306. } else {
  3307. $start = ($page - 1) * $perpage;
  3308. }
  3309. $category = $this->input->get('category', true);
  3310. $warehouse = $this->input->get('warehouse', true);
  3311. $excelid = $this->input->get('sid', true);
  3312. if ($category) {
  3313. $where .= " and features like '%-$category-%'";
  3314. }
  3315. if ($warehouse) {
  3316. $where .= " and warehouse = '$warehouse'";
  3317. }
  3318. $xzid = '';
  3319. if ($excelid) {
  3320. $excelid = explode(',', trim($excelid, ','));
  3321. foreach ($excelid as $key => $value) {
  3322. $xzid .= " id = " . $value . " or";
  3323. }
  3324. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3325. }
  3326. //取得信息列表
  3327. /**
  3328. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3329. $rows = array();$list = array();
  3330. foreach ($info_list as $key=>$value)
  3331. {
  3332. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3333. }
  3334. **/
  3335. $wt = array();
  3336. $whlabel_type = $this->whlabel_type->find_all();
  3337. foreach ($whlabel_type as $v) {
  3338. $wt[$v['id']] = $v['title'];
  3339. }
  3340. $wh = array();
  3341. $w = $this->warehouse->find_all('1=1', 'id,title');
  3342. foreach ($w as $v) {
  3343. $wh[$v['id']] = $v['title'];
  3344. }
  3345. $list = array();
  3346. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3347. foreach ($rows as $key => $value) {
  3348. if (isset($wt[$value['type']])) {
  3349. $rows[$key]['type'] = $wt[$value['type']];
  3350. } else {
  3351. $rows[$key]['type'] = '未设置';
  3352. }
  3353. $bm = '03';
  3354. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3355. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3356. $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');
  3357. $details = array();
  3358. $cpid = array();
  3359. $cpbz = array();
  3360. $c = 0;
  3361. $g = 0;
  3362. $x = 0;
  3363. $t = 0;
  3364. $s = 0;
  3365. $q = 0;
  3366. foreach ($sd as $k => $v) {
  3367. if ($v['state'] == 0) {
  3368. $c++;
  3369. if ($v['cpid'] != 0) {
  3370. $cpid[$v['cpid']] = $v['cpid'];
  3371. }
  3372. if ($v['cpbz'] != '') {
  3373. $cpbz[$v['cpbz']] = $v['cpbz'];
  3374. }
  3375. }
  3376. if ($v['state'] != 9) {
  3377. $g++;
  3378. }
  3379. if ($v['state'] == 1) {
  3380. $x++;
  3381. }
  3382. if ($v['state'] == 2) {
  3383. $t++;
  3384. }
  3385. if ($v['state'] == 8) {
  3386. $s++;
  3387. }
  3388. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3389. $q++;
  3390. }
  3391. $details[$v['details']] = $v['details'];
  3392. }
  3393. $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'] . '"');
  3394. $rows[$key]['details'] = implode("、", $details);
  3395. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3396. $number = $value['number'];
  3397. $ftime = time() - 15 * 24 * 3600;
  3398. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3399. $rows[$key]['number'] = $g;
  3400. $rows[$key]['c'] = $c;
  3401. $rows[$key]['x'] = $x;
  3402. $rows[$key]['t'] = $t;
  3403. $rows[$key]['s'] = $s;
  3404. $rows[$key]['q'] = $q;
  3405. $rows[$key]['z'] = $z;
  3406. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3407. $features = explode('-', trim($features, '-'));
  3408. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3409. // $pm = $classid;
  3410. // $jm = $classid;
  3411. // foreach($features as $k=>$v)
  3412. // {
  3413. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3414. // {
  3415. // if($typeclass[$v]['bm'] != '')
  3416. // {
  3417. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3418. // }
  3419. // }
  3420. // if($v != 0)
  3421. // {
  3422. // if(!isset($typeclass[$v]))
  3423. // {
  3424. // continue;
  3425. // }
  3426. // if(isset($pm[$typeclass[$v]['classid']]))
  3427. // {
  3428. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3429. // {
  3430. // $tz = explode('|',$typeclass[$v]['zh']);
  3431. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3432. // }
  3433. // else
  3434. // {
  3435. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3436. // }
  3437. // }
  3438. // if(isset($jm[$typeclass[$v]['classid']]))
  3439. // {
  3440. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3441. // }
  3442. // }
  3443. // }
  3444. // $jm = array_filter($jm);
  3445. // $rows[$key]['bs'] = implode("-",$jm);
  3446. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3447. // $zh = implode(" ",$pm);
  3448. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3449. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3450. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3451. // $rows[$key]['features'] = $zh;
  3452. }
  3453. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3454. $final_list = [];
  3455. foreach ($list as $k => $v) {
  3456. if (empty($v['sku'])) {
  3457. continue;
  3458. }
  3459. $final_list[] = [
  3460. "warehouse" => $v["warehouse"],
  3461. "purchase" => $v["purchase"],
  3462. "details" => $v["details"],
  3463. "cpid" => $v["cpid"],
  3464. "dbcontent" => $v["dbcontent"],
  3465. "sku" => $v["sku"],
  3466. "cs" => $v["bm"],
  3467. "bs" => $v["jm"],
  3468. "title" => $v["title"],
  3469. "features" => $v["pm"],
  3470. "cpbz" => $v["cpbz"],
  3471. "sm" => $v["sm"],
  3472. "type" => $v["type"],
  3473. "number" => $v["number"],
  3474. "c" => $v["c"],
  3475. "x" => $v["x"],
  3476. "t" => $v["t"],
  3477. "s" => $v["s"],
  3478. "q" => $v["q"],
  3479. "z" => $v["z"],
  3480. "weight" => $v['weight'],
  3481. ];
  3482. }
  3483. $title = "总进销存统计表";
  3484. $titlename = "<table border=1>
  3485. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3486. <tr align='center'>
  3487. <td>仓库</td>
  3488. <td>供应商</td>
  3489. <td>位置</td>
  3490. <td>库存编码</td>
  3491. <td>类目</td>
  3492. <td>SKU</td>
  3493. <td>用友编码</td>
  3494. <td>用友料号</td>
  3495. <td>商品名称</td>
  3496. <td>商品中文</td>
  3497. <td>产品备注</td>
  3498. <td>说明</td>
  3499. <td>类型</td>
  3500. <td>入库总量</td>
  3501. <td>库存数量</td>
  3502. <td>销售数量</td>
  3503. <td>退货数量</td>
  3504. <td>删除数量</td>
  3505. <td>其它操作</td>
  3506. <td>占单数量</td>
  3507. <td>重量(g)</td>
  3508. </tr>
  3509. </table>";
  3510. $filename = $title . ".xls";
  3511. $tail = "";
  3512. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3513. }
  3514. }
  3515. //入库导出
  3516. public function _excelr()
  3517. {
  3518. if (isset($_GET['excel'])) {
  3519. $category = $this->input->get('category', true);
  3520. $size = $this->input->get('size', true);
  3521. $grade = $this->input->get('grade', true);
  3522. $color = $this->input->get('color', true);
  3523. $lowe = $this->input->get('lowe', true);
  3524. $sku = $this->input->get('sku', true);
  3525. $warehouse = $this->input->get('warehouse', true);
  3526. $purchase = $this->input->get('purchase', true);
  3527. $ktime = $this->input->get('ktime', true);
  3528. $jtime = $this->input->get('jtime', true);
  3529. $ktime = strtotime($ktime);
  3530. $jtime = strtotime($jtime);
  3531. $where = "1=1";
  3532. $gj = "";
  3533. $ck = "";
  3534. if ($category) {
  3535. $where .= " and features like '%-$category-%'";
  3536. }
  3537. if ($size) {
  3538. $where .= " and features like '%-$size-%'";
  3539. }
  3540. if ($grade) {
  3541. $where .= " and features like '%-$grade-%'";
  3542. }
  3543. if ($color) {
  3544. $where .= " and features like '%-$color-%'";
  3545. }
  3546. if ($lowe) {
  3547. $where .= " and features like '%-$lowe-%'";
  3548. }
  3549. if ($warehouse) {
  3550. $where .= " and warehouse = '$warehouse'";
  3551. }
  3552. if ($purchase) {
  3553. $where .= " and purchase = '$purchase'";
  3554. }
  3555. if ($sku) {
  3556. $where .= " and sku = '$sku'";
  3557. }
  3558. if ($ktime && $jtime) {
  3559. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3560. }
  3561. //数据排序
  3562. $order_str = "id desc";
  3563. if (empty($page)) {
  3564. $start = 0;
  3565. $perpage = 1;
  3566. } else {
  3567. $start = ($page - 1) * $perpage;
  3568. }
  3569. $list = array();
  3570. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3571. foreach ($rows as $value) {
  3572. $ck = $this->warehouse->read($value['warehouse']);
  3573. $warehouse = $ck['title'];
  3574. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3575. $retreatwarehouse = $tkck['title'];
  3576. $gy = $this->purchase->read($value['purchase']);
  3577. $purchase = $gy['title'];
  3578. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3579. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3580. }
  3581. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3582. $titlename = "<table border=1>
  3583. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3584. <tr align='center'>
  3585. <td>仓库</td>
  3586. <td>SKU</td>
  3587. <td>产品</td>
  3588. <td>时间</td>
  3589. <td>数量</td>
  3590. </tr>
  3591. </table>";
  3592. $filename = $title . ".xls";
  3593. $tail = "";
  3594. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3595. }
  3596. }
  3597. //出库、退库导出
  3598. public function _excelct()
  3599. {
  3600. $classid = $this->classid->sku();
  3601. $pm = $classid;
  3602. $typeclass = array();
  3603. $tc = $this->typeclass->find_all();
  3604. foreach ($tc as $v) {
  3605. $typeclass[$v['id']] = $v;
  3606. }
  3607. $prc = array();
  3608. $purchase = $this->purchase->find_all();
  3609. foreach ($purchase as $k => $v) {
  3610. $prc[$v['id']] = $v['title'];
  3611. }
  3612. if (isset($_GET['excel'])) {
  3613. $wh = array();
  3614. $w = $this->warehouse->find_all('1=1', 'id,title');
  3615. foreach ($w as $v) {
  3616. $wh[$v['id']] = $v['title'];
  3617. }
  3618. $type = $this->input->get('excel', true);
  3619. $category = $this->input->get('category', true);
  3620. $size = $this->input->get('size', true);
  3621. $grade = $this->input->get('grade', true);
  3622. $color = $this->input->get('color', true);
  3623. $lowe = $this->input->get('lowe', true);
  3624. $sku = $this->input->get('sku', true);
  3625. $warehouse = $this->input->get('warehouse', true);
  3626. $lacetype = $this->input->get('lacetype', true);
  3627. $lacecolor = $this->input->get('lacecolor', true);
  3628. $density = $this->input->get('density', true);
  3629. $haircap = $this->input->get('haircap', true);
  3630. $purchase = $this->input->get('purchase', true);
  3631. $title = $this->input->get('title', true);
  3632. $state = $this->input->get('state', true);
  3633. $sid = $this->input->get('sid', true);
  3634. $ktime = $this->input->get('ktime', true);
  3635. $jtime = $this->input->get('jtime', true);
  3636. $ktime = strtotime($ktime);
  3637. $jtime = strtotime($jtime);
  3638. $where = "1=1";
  3639. $gj = "";
  3640. $ck = "";
  3641. if ($category) {
  3642. $where .= " and features like '%-$category-%'";
  3643. }
  3644. if ($size) {
  3645. $where .= " and features like '%-$size-%'";
  3646. }
  3647. if ($grade) {
  3648. $where .= " and features like '%-$grade-%'";
  3649. }
  3650. if ($color) {
  3651. $where .= " and features like '%-$color-%'";
  3652. }
  3653. if ($lowe) {
  3654. $where .= " and features like '%-$lowe-%'";
  3655. }
  3656. if ($warehouse) {
  3657. $where .= " and warehouse = '$warehouse'";
  3658. }
  3659. if ($purchase) {
  3660. $where .= " and purchase = '$purchase'";
  3661. }
  3662. if ($state) {
  3663. $where .= " and state = '$state'";
  3664. }
  3665. if ($lacetype) {
  3666. $where .= " and features like '%-$lacetype-%'";
  3667. }
  3668. if ($lacecolor) {
  3669. $where .= " and features like '%-$lacecolor-%'";
  3670. }
  3671. if ($density) {
  3672. $where .= " and features like '%-$density-%'";
  3673. }
  3674. if ($haircap) {
  3675. $where .= " and features like '%-$haircap-%'";
  3676. }
  3677. if ($title) {
  3678. $title = trim($title, ' ');
  3679. $title = trim($title, ' ');
  3680. $where .= " and title like '%$title%'";
  3681. }
  3682. if ($sku) {
  3683. $sku = trim($sku, ' ');
  3684. $sku = trim($sku, ' ');
  3685. $where .= " and sku like '%$sku%'";
  3686. }
  3687. if ($ktime && $jtime) {
  3688. if ($type == 1) {
  3689. $tl = '出库';
  3690. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3691. } else if ($type == 2) {
  3692. $tl = '退库';
  3693. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3694. } else if ($type == 3) {
  3695. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3696. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3697. } else if ($type == 4) {
  3698. $tl = '出库+零售';
  3699. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3700. } else if ($type == 5) {
  3701. $tl = '零售';
  3702. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3703. }
  3704. }
  3705. $sidwhere = '';
  3706. if ($sid) {
  3707. $sd = "";
  3708. $s = explode(',', trim($sid, ','));
  3709. foreach ($s as $value) {
  3710. $sd .= " id = " . $value . " or";
  3711. }
  3712. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3713. }
  3714. //数据排序
  3715. $order_str = "time desc";
  3716. if (empty($page)) {
  3717. $start = 0;
  3718. $perpage = 1;
  3719. } else {
  3720. $start = ($page - 1) * $perpage;
  3721. }
  3722. $this->logic_ding->sendToDing("导出出入库分类数据".$where);
  3723. //取得信息列表
  3724. if ($type != 3 && $type != 5) {
  3725. if ($type == 1 || $type == 4) {
  3726. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3727. foreach ($info_list as $key => $value) {
  3728. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3729. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3730. $warehouse = $this->warehouse->read($value['warehouse']);
  3731. $info_list[$key]['warehouse'] = $warehouse['title'];
  3732. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3733. $features = explode('-', trim($features, '-'));
  3734. $pm = $classid;
  3735. foreach ($features as $k => $v) {
  3736. if ($v != 0) {
  3737. if (!isset($typeclass[$v])) {
  3738. continue;
  3739. }
  3740. if (isset($pm[$typeclass[$v]['classid']])) {
  3741. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3742. $tz = explode('|', $typeclass[$v]['zh']);
  3743. $pm[$typeclass[$v]['classid']] = $tz[0];
  3744. } else {
  3745. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3746. }
  3747. }
  3748. }
  3749. }
  3750. $zh = implode(" ", $pm);
  3751. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3752. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3753. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3754. $info_list[$key]['features'] = $zh;
  3755. }
  3756. $final_list = [];
  3757. foreach($info_list as $k=>$v){
  3758. $number = "";
  3759. if(!empty($v['orderinfo'])){
  3760. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3761. if(!empty($tmp_info['number'])){
  3762. $number = $tmp_info['number'];
  3763. }
  3764. }
  3765. $final_list[] = [
  3766. 'warehouse'=>$v['warehouse'],
  3767. 'purchase'=>$v['purchase'],
  3768. 'sku'=>$v['sku'],
  3769. 'title'=>$v['title'],
  3770. 'features'=>$v['features'],
  3771. 'label'=>$v['label'],
  3772. 'orderinfo'=>$v['orderinfo'],
  3773. 'number'=>$number,
  3774. 'waybill'=>$v['waybill'],
  3775. 'outk'=>$v['outk'],
  3776. ];
  3777. }
  3778. } else {
  3779. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3780. foreach ($info_list as $key => $value) {
  3781. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3782. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3783. $warehouse = $this->warehouse->read($value['warehouse']);
  3784. $info_list[$key]['warehouse'] = $warehouse['title'];
  3785. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3786. $features = explode('-', trim($features, '-'));
  3787. $pm = $classid;
  3788. foreach ($features as $k => $v) {
  3789. if ($v != 0) {
  3790. if (!isset($typeclass[$v])) {
  3791. continue;
  3792. }
  3793. if (isset($pm[$typeclass[$v]['classid']])) {
  3794. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3795. $tz = explode('|', $typeclass[$v]['zh']);
  3796. $pm[$typeclass[$v]['classid']] = $tz[0];
  3797. } else {
  3798. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3799. }
  3800. }
  3801. }
  3802. }
  3803. $zh = implode(" ", $pm);
  3804. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3805. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3806. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3807. $info_list[$key]['features'] = $zh;
  3808. }
  3809. $final_list = [];
  3810. foreach($info_list as $k=>$v){
  3811. $number = "";
  3812. if(!empty($v['orderinfo'])){
  3813. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3814. if(!empty($tmp_info['number'])){
  3815. $number = $tmp_info['number'];
  3816. }
  3817. }
  3818. $final_list[] = [
  3819. 'warehouse'=>$v['warehouse'],
  3820. 'purchase'=>$v['purchase'],
  3821. 'sku'=>$v['sku'],
  3822. 'title'=>$v['title'],
  3823. 'features'=>$v['features'],
  3824. 'label'=>$v['label'],
  3825. 'orderinfo'=>$v['orderinfo'],
  3826. 'number'=>$number,
  3827. 'waybill'=>$v['waybill'],
  3828. 'retreat'=>$v['retreat'],
  3829. ];
  3830. }
  3831. }
  3832. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3833. $titlename = "<table border=1>
  3834. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3835. <tr align='center'>
  3836. <td>仓库</td>
  3837. <td>供应商</td>
  3838. <td>SKU</td>
  3839. <td>商品名称</td>
  3840. <td>商品中文</td>
  3841. <td>标签</td>
  3842. <td>订单号</td>
  3843. <td>订单编码</td>
  3844. <td>运单号</td>
  3845. <td>" . $tl . "时间(中国时间)</td>
  3846. </tr>
  3847. </table>";
  3848. $filename = $title . ".xls";
  3849. $tail = "";
  3850. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3851. } else if ($type == 5) {
  3852. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3853. $this->logic_ding->sendToDing("导出出入库分类数据".json_encode($info_list));
  3854. foreach ($info_list as $key => $value) {
  3855. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3856. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3857. $warehouse = $this->warehouse->read($value['warehouse']);
  3858. $info_list[$key]['warehouse'] = $warehouse['title'];
  3859. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3860. $features = explode('-', trim($features, '-'));
  3861. $pm = $classid;
  3862. foreach ($features as $k => $v) {
  3863. if ($v != 0) {
  3864. if (!isset($typeclass[$v])) {
  3865. continue;
  3866. }
  3867. if (isset($pm[$typeclass[$v]['classid']])) {
  3868. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3869. $tz = explode('|', $typeclass[$v]['zh']);
  3870. $pm[$typeclass[$v]['classid']] = $tz[0];
  3871. } else {
  3872. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3873. }
  3874. }
  3875. }
  3876. }
  3877. $zh = implode(" ", $pm);
  3878. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3879. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3880. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3881. $info_list[$key]['features'] = $zh;
  3882. }
  3883. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3884. $titlename = "<table border=1>
  3885. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3886. <tr align='center'>
  3887. <td>仓库</td>
  3888. <td>供应商</td>
  3889. <td>SKU</td>
  3890. <td>商品名称</td>
  3891. <td>商品中文</td>
  3892. <td>标签</td>
  3893. <td>" . $tl . "时间(中国时间)</td>
  3894. </tr>
  3895. </table>";
  3896. $filename = $title . ".xls";
  3897. $tail = "";
  3898. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  3899. } else {
  3900. /**
  3901. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  3902. $rows = array();$list = array();
  3903. foreach ($info_list as $key=>$value)
  3904. {
  3905. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  3906. }
  3907. **/
  3908. $wh = array();
  3909. $w = $this->warehouse->find_all('1=1', 'id,title');
  3910. foreach ($w as $v) {
  3911. $wh[$v['id']] = $v['title'];
  3912. }
  3913. $wt = array();
  3914. $whlabel_type = $this->whlabel_type->find_all();
  3915. foreach ($whlabel_type as $v) {
  3916. $wt[$v['id']] = $v['title'];
  3917. }
  3918. $classid = $this->classid->sku();
  3919. $list = array();
  3920. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  3921. foreach ($rows as $key => $value) {
  3922. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3923. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3924. $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');
  3925. $details = array();
  3926. $cpid = array();
  3927. $cpbz = array();
  3928. $c = 0;
  3929. $g = 0;
  3930. $x = 0;
  3931. $t = 0;
  3932. $s = 0;
  3933. $q = 0;
  3934. foreach ($sd as $k => $v) {
  3935. if ($v['state'] == 0) {
  3936. $c++;
  3937. }
  3938. if ($v['state'] != 9) {
  3939. $g++;
  3940. }
  3941. if ($v['outk'] > 1) {
  3942. $x++;
  3943. }
  3944. if ($v['retreat'] > 0) {
  3945. $t++;
  3946. }
  3947. if ($v['state'] == 8) {
  3948. $s++;
  3949. }
  3950. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3951. $q++;
  3952. }
  3953. $details[$v['details']] = $v['details'];
  3954. if ($v['cpid'] != 0) {
  3955. $cpid[$v['cpid']] = $v['cpid'];
  3956. }
  3957. if ($v['cpbz'] != '') {
  3958. $cpbz[$v['cpbz']] = $v['cpbz'];
  3959. }
  3960. }
  3961. if (isset($wt[$value['type']])) {
  3962. $rows[$key]['type'] = $wt[$value['type']];
  3963. } else {
  3964. $rows[$key]['type'] = '未设置';
  3965. }
  3966. $rows[$key]['details'] = implode("、", $details);
  3967. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3968. $ftime = time() - 15 * 24 * 3600;
  3969. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3970. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  3971. $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);
  3972. $rows[$key]['c'] = $c;
  3973. $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);
  3974. $rows[$key]['t'] = $t;
  3975. $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'] . '"');
  3976. $rows[$key]['z'] = $z;
  3977. // $jm = $classid;
  3978. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3979. $features = explode('-', trim($features, '-'));
  3980. // $pm = $classid;
  3981. // foreach ($features as $k => $v) {
  3982. // if ($v != 0) {
  3983. // if (!isset($typeclass[$v])) {
  3984. // continue;
  3985. // }
  3986. // if (isset($pm[$typeclass[$v]['classid']])) {
  3987. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3988. // $tz = explode('|', $typeclass[$v]['zh']);
  3989. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3990. // } else {
  3991. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3992. // }
  3993. // if (isset($jm[$typeclass[$v]['classid']])) {
  3994. // if ($typeclass[$v]['jm']) {
  3995. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3996. // }
  3997. // }
  3998. // }
  3999. // }
  4000. // }
  4001. // $zh = implode(" ", $pm);
  4002. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4003. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4004. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4005. // $rows[$key]['features'] = $zh;
  4006. // $jm = array_filter($jm); //去除空值
  4007. // $jm = implode("-", $jm);
  4008. // $rows[$key]['jm'] = $jm;
  4009. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4010. }
  4011. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4012. // echo "<pre>";
  4013. // print_r($tmp_list);
  4014. // die;
  4015. $final_list =[];
  4016. foreach($tmp_list as $k=>$v){
  4017. $final_list[] = [
  4018. "warehouse"=>$v['warehouse'],
  4019. "purchase"=>$v['purchase'],
  4020. "details"=>$v['details'],
  4021. "cpid"=>$v['cpid'],
  4022. "sku"=>$v['sku'],
  4023. "title"=>$v['title'],
  4024. "features"=>$v['pm'],
  4025. "cpbz"=>$v['cpbz'],
  4026. "sm"=>$v['sm'],
  4027. "type"=>$v['type'],
  4028. "g"=>$v["g"],
  4029. "c"=>$v["c"],
  4030. "x"=>$v["x"],
  4031. "t"=>$v["t"],
  4032. "z"=>$v["z"],
  4033. "jm"=>$v["jm"],
  4034. "weight"=>$v["weight"],
  4035. "asd"=>$v["asd"],
  4036. ];
  4037. }
  4038. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4039. $titlename = "<table border=1>
  4040. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4041. <tr align='center'>
  4042. <td>仓库</td>
  4043. <td>供应商</td>
  4044. <td>位置</td>
  4045. <td>库存编码</td>
  4046. <td>SKU</td>
  4047. <td>商品名称</td>
  4048. <td>商品中文</td>
  4049. <td>产品备注</td>
  4050. <td>说明</td>
  4051. <td>类型</td>
  4052. <td>入库总量</td>
  4053. <td>库存数量</td>
  4054. <td>销售数量</td>
  4055. <td>退货数量</td>
  4056. <td>占单数量</td>
  4057. <td>料号</td>
  4058. <td>重量</td>
  4059. <td>类目</td>
  4060. </tr>
  4061. </table>";
  4062. $filename = $title . ".xls";
  4063. $tail = "";
  4064. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4065. }
  4066. }
  4067. }
  4068. //出库+入库数据整合
  4069. public function _excelcr()
  4070. {
  4071. if (isset($_GET['excel'])) {
  4072. $type = $this->input->get('excel', true);
  4073. $category = $this->input->get('category', true);
  4074. $size = $this->input->get('size', true);
  4075. $grade = $this->input->get('grade', true);
  4076. $color = $this->input->get('color', true);
  4077. $lowe = $this->input->get('lowe', true);
  4078. $sku = $this->input->get('sku', true);
  4079. $warehouse = $this->input->get('warehouse', true);
  4080. $purchase = $this->input->get('purchase', true);
  4081. $state = $this->input->get('state', true);
  4082. $sid = $this->input->get('sid', true);
  4083. $ktime = $this->input->get('ktime', true);
  4084. $jtime = $this->input->get('jtime', true);
  4085. $ktime = strtotime($ktime);
  4086. $jtime = strtotime($jtime);
  4087. $where = "1=1";
  4088. $gj = "";
  4089. $ck = "";
  4090. if ($category) {
  4091. $where .= " and features like '%-$category-%'";
  4092. }
  4093. if ($size) {
  4094. $where .= " and features like '%-$size-%'";
  4095. }
  4096. if ($grade) {
  4097. $where .= " and features like '%-$grade-%'";
  4098. }
  4099. if ($color) {
  4100. $where .= " and features like '%-$color-%'";
  4101. }
  4102. if ($lowe) {
  4103. $where .= " and features like '%-$lowe-%'";
  4104. }
  4105. if ($warehouse) {
  4106. $where .= " and warehouse = '$warehouse'";
  4107. }
  4108. if ($purchase) {
  4109. $where .= " and purchase = '$purchase'";
  4110. }
  4111. if ($state) {
  4112. $where .= " and state = '$state'";
  4113. }
  4114. if ($sku) {
  4115. $where .= " and sku like '%$sku%'";
  4116. }
  4117. if ($ktime && $jtime) {
  4118. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4119. }
  4120. $sidwhere = '';
  4121. if ($sid) {
  4122. $sd = "";
  4123. $s = explode(',', trim($sid, ','));
  4124. foreach ($s as $value) {
  4125. $sd .= " id = " . $value . " or";
  4126. }
  4127. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4128. }
  4129. //取得信息列表
  4130. $timeread = $ktime;
  4131. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4132. $timelist = array();
  4133. for ($i = 0; $i < $timenum; $i++) {
  4134. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4135. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4136. }
  4137. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4138. //echo "<pre>";
  4139. //print_r($info_list);
  4140. //exit();
  4141. $rows = array();
  4142. $list = array();
  4143. foreach ($info_list as $key => $value) {
  4144. $thistime = $timelist;
  4145. if (isset($rows[strtolower($value['sku'])])) {
  4146. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4147. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4148. }
  4149. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4150. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4151. }
  4152. } else {
  4153. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4154. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4155. }
  4156. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4157. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4158. }
  4159. $rows[strtolower($value['sku'])] = $thistime;
  4160. }
  4161. }
  4162. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4163. <head>
  4164. <!--[if gte mso 9]><xml>
  4165. <x:ExcelWorkbook>
  4166. <x:ExcelWorksheets>
  4167. <x:ExcelWorksheet>
  4168. <x:Name>EXCEL</x:Name>
  4169. <x:WorksheetOptions>
  4170. <x:Print>
  4171. <x:ValidPrinterInfo />
  4172. </x:Print>
  4173. </x:WorksheetOptions>
  4174. </x:ExcelWorksheet>
  4175. </x:ExcelWorksheets>
  4176. </x:ExcelWorkbook>
  4177. </xml>
  4178. <![endif]-->
  4179. </head><body>";
  4180. $str .= "<table border=1><tr><td>SKU</td>";
  4181. foreach ($timelist as $k => $v) {
  4182. $str .= "<td>" . $k . "出库</td>";
  4183. $str .= "<td>" . $k . "入库</td>";
  4184. }
  4185. $str .= "</tr></table>";
  4186. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4187. foreach ($rows as $key => $val) {
  4188. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4189. foreach ($val as $k => $v) {
  4190. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4191. if ($val[$k]['r'] > 0) {
  4192. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4193. } else {
  4194. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4195. }
  4196. }
  4197. $str .= "</tr>";
  4198. }
  4199. $str .= "</table>";
  4200. $str .= "</body></html>";
  4201. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4202. header("Content-type: application/octet-stream");
  4203. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4204. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4205. header("Pragma: no-cache");
  4206. header("Expires: 0");
  4207. exit($str);
  4208. }
  4209. }
  4210. //数量调整模板导出
  4211. public function _presetout()
  4212. {
  4213. if (isset($_GET['excel'])) {
  4214. $where = "sku != 'Preset' and purchase != 0";
  4215. //数据排序
  4216. $order_str = "id desc";
  4217. if (empty($page)) {
  4218. $start = 0;
  4219. $perpage = 1;
  4220. } else {
  4221. $start = ($page - 1) * $perpage;
  4222. }
  4223. //取得信息列表
  4224. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4225. $rows = array();
  4226. $list = array();
  4227. foreach ($info_list as $value) {
  4228. $warehouse = $this->warehouse->read($value['warehouse']);
  4229. $number = $value['number'];
  4230. $ftime = time() - 15 * 24 * 3600;
  4231. $purchase = $this->purchase->read($value['purchase']);
  4232. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4233. }
  4234. $title = "库存模板";
  4235. $titlename = "<table border=1>
  4236. <tr align='center'>
  4237. <td>仓库</td>
  4238. <td>供应商编码</td>
  4239. <td>SKU</td>
  4240. <td>增减数量(正数或负数)</td>
  4241. <td>增减备注</td>
  4242. <td>扣减方式:0减少库存1删除库存</td>
  4243. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4244. <td>扣减类型(扣减为必填,填数字):1.销售出库2.销售美国出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4245. </tr>
  4246. </table>";
  4247. $filename = $title . ".xls";
  4248. $tail = "";
  4249. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4250. }
  4251. }
  4252. //数量调整模板导入
  4253. public function _presetedit()
  4254. {
  4255. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4256. $config['upload_path'] = '.' . $dir;
  4257. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4258. $config['allowed_types'] = 'xls|xlsx|csv';
  4259. $config['max_size'] = 10240;
  4260. $this->load->library('upload', $config);
  4261. $this->upload->initialize($config);
  4262. if ($this->upload->do_upload('userfile')) {
  4263. $full_path = $dir . $this->upload->data('file_name');
  4264. $fileName = '.' . $full_path;
  4265. if (!file_exists($fileName)) {
  4266. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4267. exit;
  4268. } else {
  4269. require_once "./data/excel/PHPExcel/IOFactory.php";
  4270. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4271. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4272. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4273. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4274. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4275. ++$column; //如果列数大于26行
  4276. $list = array();
  4277. for ($i = 2; $i <= $row; $i++) // 行数循环
  4278. {
  4279. $data = array();
  4280. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4281. {
  4282. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4283. }
  4284. $list[] = $data;
  4285. }
  4286. }
  4287. $i = 0;
  4288. $j = 0;
  4289. $ed = array();
  4290. foreach ($list as $key => $value) {
  4291. $time = time();
  4292. if ($value['0'] == "") {
  4293. continue;
  4294. }
  4295. $warehouse = $this->warehouse->get_title($value['0']);
  4296. $purchase = $this->purchase->get_bm($value['1']);
  4297. $sku = $value['2'];
  4298. $num = $value['3']; //调整数量
  4299. $text = $value['4']; //扣减说明
  4300. $type = $value['5']; //调整方式0扣减1删除
  4301. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4302. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4303. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4304. if (!$purchase) //如果没有这个SKU
  4305. {
  4306. $ed[] = array($purchase . '-不存在此供应商编码');
  4307. $j++;
  4308. continue;
  4309. }
  4310. if (!$d) //如果没有这个SKU
  4311. {
  4312. $ed[] = array($sku . '-库存中不存在此SKU');
  4313. $j++;
  4314. continue;
  4315. }
  4316. if (!isset($warehouse['id'])) {
  4317. $ed[] = array($sku . '-仓库名错误!');
  4318. $j++;
  4319. continue;
  4320. }
  4321. if ($type != '0' && $type != '1') {
  4322. $ed[] = array($sku . '-扣减方式填写错误!');
  4323. $j++;
  4324. continue;
  4325. }
  4326. if ($num < 0) //扣减库存
  4327. {
  4328. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4329. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4330. $j++;
  4331. continue;
  4332. }
  4333. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4334. if (count($data) < abs($num)) {
  4335. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4336. $j++;
  4337. continue;
  4338. }
  4339. if ($type == 0) //如果扣减方式为 扣减库存
  4340. {
  4341. for ($i = 0; $i < abs($num); $i++) {
  4342. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4343. }
  4344. } else if ($type == 1) {
  4345. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4346. if (count($zt) > 0) {
  4347. $ed[] = array($sku . '-有在途库存无法删除!');
  4348. $j++;
  4349. continue;
  4350. }
  4351. for ($i = 0; $i < abs($num); $i++) {
  4352. $this->whlabel->remove($data[$i]['id']);
  4353. }
  4354. }
  4355. } else if ($num > 0) //增加库存
  4356. {
  4357. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4358. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4359. $j++;
  4360. continue;
  4361. }
  4362. $post['sku'] = $d['sku'];
  4363. $post['shop'] = $d['shop'];
  4364. $post['warehouse'] = $warehouse['id'];
  4365. $post['purchase'] = $purchase['id'];
  4366. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4367. $post['state'] = 0;
  4368. $post['title'] = $d['title'];
  4369. $post['number'] = $d['number'];
  4370. $post['features'] = $d['features'];
  4371. $post['enter'] = $time;
  4372. $post['time'] = $time; //操作时间
  4373. $post['rktype'] = $rktype;
  4374. for ($i = 0; $i < $num; $i++) {
  4375. $post['label'] = time() . rand(100, 999) . $i;
  4376. $this->whlabel->insert($post);
  4377. }
  4378. }
  4379. sleep(1); //防止入库时间一样,需要延迟1秒
  4380. }
  4381. if ($j > 0) {
  4382. $tt = date('Ymd', time());
  4383. $title = '库存导入错误信息-' . $tt;
  4384. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4385. $tail = "\n";
  4386. $filename = $title . ".xls";
  4387. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4388. $dir = '/data/excel/' . $time . '/';
  4389. $file_name = 'error_' . $time . rand(1000, 9999);
  4390. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4391. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4392. fwrite($myfile, $ecl);
  4393. fclose($myfile);
  4394. $error = $dir . $file_name . '.xls';
  4395. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4396. exit;
  4397. } else {
  4398. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4399. exit;
  4400. }
  4401. }
  4402. }
  4403. //笛卡儿积
  4404. function cp($ps, $sets, $list)
  4405. {
  4406. $result = array();
  4407. $j = 0;
  4408. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4409. if ($i == 0) {
  4410. $result = $sets[$i];
  4411. }
  4412. $tmp = array();
  4413. foreach ($result as $res) {
  4414. foreach ($sets[$i + 1] as $set) {
  4415. $tmp[] = $res . ',' . $set;
  4416. }
  4417. }
  4418. $result = $tmp;
  4419. }
  4420. $this->db->trans_begin();
  4421. foreach ($result as $v) {
  4422. $post = array();
  4423. $title = "";
  4424. $num = "";
  4425. $data = explode(',', $v);
  4426. for ($i = 0; $i < count($list); $i++) {
  4427. $post[$list[$i]] = $data[$i];
  4428. $typeclass = $this->typeclass->read($data[$i]);
  4429. $title = $title . $typeclass['title'] . " ";
  4430. if ($data[$i] != 0) {
  4431. $num .= $data[$i]; //所有数据ID拼接
  4432. }
  4433. }
  4434. foreach ($ps as $kp => $vp) {
  4435. $post[$kp] = $vp;
  4436. }
  4437. $post['number'] = $num;
  4438. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4439. if ($info_list) {
  4440. $j++;
  4441. } else {
  4442. $skunum = $this->whlabel->find_count();
  4443. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4444. $post['title'] = rtrim($title, ' ');
  4445. $this->whlabel->insert($post);
  4446. }
  4447. }
  4448. if ($this->db->trans_status() === FALSE) {
  4449. $this->db->trans_commit();
  4450. return NULL;
  4451. } else {
  4452. $this->db->trans_commit();
  4453. return $j;
  4454. }
  4455. }
  4456. public function _kj($arg_array)
  4457. {
  4458. if (isset($_POST['sku'])) {
  4459. $time = time();
  4460. $sku = $this->input->post('sku', true);
  4461. $warehouse = $this->input->post('warehouse', true);
  4462. $num = $this->input->post('num', true);
  4463. $text = $this->input->post('text', true);
  4464. $purchase = $this->input->post('purchase', true);
  4465. $cktype = $this->input->post('cktype', true);
  4466. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4467. if ($cktype != 1 && $text == '') {
  4468. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4469. exit;
  4470. }
  4471. if ($num > count($order)) {
  4472. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4473. exit;
  4474. } else {
  4475. for ($i = 0; $i < $num; $i++) {
  4476. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4477. }
  4478. }
  4479. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4480. exit;
  4481. }
  4482. $uid = $this->whlabel->read($arg_array[0]);
  4483. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4484. $this->data['data'] = $uid;
  4485. $this->_Template('whlabel_kj', $this->data);
  4486. }
  4487. public function _summary($arg_array)
  4488. {
  4489. $prc = array();
  4490. $purchase = $this->purchase->find_all();
  4491. foreach ($purchase as $k => $v) {
  4492. $prc[$v['id']] = $v['title'];
  4493. }
  4494. if (isset($_GET['excel'])) {
  4495. $ktime = $this->input->get('ktime', true);
  4496. $jtime = $this->input->get('jtime', true);
  4497. $ktime = strtotime($ktime);
  4498. $jtime = strtotime($jtime);
  4499. $where = "1=1";
  4500. if ($ktime && $jtime) {
  4501. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4502. }
  4503. //数据排序
  4504. $order_str = "time desc";
  4505. if (empty($page)) {
  4506. $start = 0;
  4507. $perpage = 1;
  4508. } else {
  4509. $start = ($page - 1) * $perpage;
  4510. }
  4511. //取得信息列表
  4512. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4513. foreach ($info_list as $key => $value) {
  4514. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4515. $warehouse = $this->warehouse->read($value['warehouse']);
  4516. $info_list[$key]['warehouse'] = $warehouse['title'];
  4517. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4518. $details = array();
  4519. $cpid = array();
  4520. foreach ($x as $k => $v) {
  4521. if ($v['details'] != '') {
  4522. $details[$v['details']] = $v['details'];
  4523. }
  4524. if ($v['cpid'] != 0) {
  4525. $cpid[$v['cpid']] = $v['cpid'];
  4526. }
  4527. }
  4528. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4529. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4530. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4531. $info_list[$key]['s'] = $s;
  4532. $info_list[$key]['x'] = count($x);
  4533. }
  4534. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4535. $titlename = "<table border=1>
  4536. <tr align='center'>
  4537. <td>仓库</td>
  4538. <td>供应商</td>
  4539. <td>出库位置</td>
  4540. <td>出库编码</td>
  4541. <td>SKU</td>
  4542. <td>产品名</td>
  4543. <td>总剩余库存</td>
  4544. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4545. </tr>
  4546. </table>";
  4547. $filename = $title . ".xls";
  4548. $tail = "";
  4549. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4550. }
  4551. }
  4552. //usps发货清单
  4553. public function _manifest()
  4554. {
  4555. if (isset($_POST['manifest'])) {
  4556. $wltext = $this->input->post('wltext', true);
  4557. $time = time() - 16 * 3600;
  4558. $ptime = strtotime(date('Y-m-d', $time));
  4559. $waybill = array();
  4560. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4561. foreach ($fullorder as $v) {
  4562. $waybill[$v['waybill']] = $v['waybill'];
  4563. }
  4564. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4565. foreach ($fullordersmt as $v) {
  4566. $waybill[$v['waybill']] = $v['waybill'];
  4567. }
  4568. $wltext = explode(';', $wltext);
  4569. foreach ($wltext as $v) {
  4570. if (isset($waybill[$v])) {
  4571. unset($waybill[$v]);
  4572. }
  4573. }
  4574. $data = $this->usps->get_manifest($waybill);
  4575. if (isset($data['Description'])) {
  4576. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4577. exit;
  4578. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4579. $bctime = date('Ymd', time());
  4580. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4581. echo json_encode(array('msg' => $pdf, 'success' => true));
  4582. exit;
  4583. } else {
  4584. echo json_encode(array('msg' => $data, 'success' => false));
  4585. exit;
  4586. }
  4587. }
  4588. }
  4589. public function _pdf($pdf, $title, $bctime)
  4590. {
  4591. $pdf_path = './data/pdf/' . $bctime . '/';
  4592. $file_base64 = $pdf;
  4593. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4594. $file_base64 = base64_decode($file_base64);
  4595. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4596. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4597. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4598. }
  4599. /**
  4600. *
  4601. *
  4602. *
  4603. 进销存占单异常索引
  4604. *
  4605. *
  4606. *
  4607. **/
  4608. public function _abnormal()
  4609. {
  4610. $post = $this->input->post(NULL, TRUE);
  4611. if (isset($post['page'])) {
  4612. $page = $this->input->post('page', true);
  4613. $perpage = $this->input->post('perpage', true);
  4614. $sku = $this->input->post('sku', true);
  4615. $where = "1=1";
  4616. //数据排序
  4617. $order_str = "id desc";
  4618. if (empty($page)) {
  4619. $start = 0;
  4620. $perpage = 1;
  4621. } else {
  4622. $start = ($page - 1) * $perpage;
  4623. }
  4624. //取得信息列表
  4625. $info_list = $this->whlabel->find_all($where, '*');
  4626. $rows = array();
  4627. $list = array();
  4628. foreach ($info_list as $key => $value) {
  4629. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4630. }
  4631. foreach ($rows as $value) {
  4632. $warehouse = $this->warehouse->read($value['warehouse']);
  4633. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4634. $number = $value['number'];
  4635. $ftime = time() - 15 * 24 * 3600;
  4636. if ($value['shop'] != '') {
  4637. $shop = $value['shop'];
  4638. $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');
  4639. $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');
  4640. $order = array_merge($orderdlz, $ordersmt);
  4641. $od = 0;
  4642. $a = '';
  4643. $orid = '';
  4644. foreach ($order as $v) {
  4645. $or = explode('|', ltrim($v['whlabel'], '|'));
  4646. for ($i = 0; $i < count($or); $i++) {
  4647. $orod = explode('-', $or[$i]);
  4648. if ($orod[0] == $number) {
  4649. $od += $orod[1];
  4650. }
  4651. }
  4652. $orid .= $v['number'] . '-';
  4653. }
  4654. } else {
  4655. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4656. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4657. $order = array_merge($orderdlz, $ordersmt);
  4658. $od = 0;
  4659. $a = '';
  4660. $orid = '';
  4661. $qt = array();
  4662. foreach ($order as $v) {
  4663. $or = explode('|', ltrim($v['whlabel'], '|'));
  4664. for ($i = 0; $i < count($or); $i++) {
  4665. $orod = explode('-', $or[$i]);
  4666. if ($orod[0] == $number) {
  4667. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4668. if ($czzs > 0) {
  4669. if (isset($qt[$v['shop']])) {
  4670. if ($qt[$v['shop']] < $orod[1]) {
  4671. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4672. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4673. } else {
  4674. $qt[$v['shop']] -= $orod[1];
  4675. }
  4676. } else {
  4677. $qt[$v['shop']] = $czzs;
  4678. }
  4679. } else {
  4680. $od += $orod[1];
  4681. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4682. }
  4683. }
  4684. }
  4685. }
  4686. }
  4687. $z = $od . '(' . $orid . ')'; //查看订单号
  4688. //$z = $od;
  4689. if ($od > $c) {
  4690. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4691. }
  4692. }
  4693. $listdata = array_slice($list, $start, $perpage);
  4694. $total = count($list);
  4695. $pagenum = ceil($total / $perpage);
  4696. $over = $total - ($start + $perpage);
  4697. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4698. echo json_encode($rows);
  4699. exit;
  4700. }
  4701. $this->_Template('whlabel_abnormal', $this->data);
  4702. }
  4703. /**
  4704. *
  4705. *
  4706. *
  4707. 进销存占单异常索引
  4708. *
  4709. *
  4710. *
  4711. **/
  4712. public function _error()
  4713. {
  4714. $post = $this->input->post(NULL, TRUE);
  4715. if (isset($post['page'])) {
  4716. $page = $this->input->post('page', true);
  4717. $perpage = $this->input->post('perpage', true);
  4718. $sku = $this->input->post('sku', true);
  4719. $warehouse = $this->input->post('warehouse', true);
  4720. $ktime = $this->input->post('ktime', true);
  4721. $jtime = $this->input->post('jtime', true);
  4722. $ktime = strtotime($ktime);
  4723. $jtime = strtotime($jtime);
  4724. $where = "sku != 'Preset'";
  4725. $gj = '';
  4726. if ($sku) {
  4727. $where .= " and sku like '%$sku%'";
  4728. } else {
  4729. if ($ktime && $jtime) {
  4730. $gj = " and time > '$ktime' and time < '$jtime'";
  4731. }
  4732. }
  4733. if ($warehouse) {
  4734. $where .= " and warehouse = '$warehouse'";
  4735. }
  4736. //数据排序
  4737. $order_str = "id desc";
  4738. if (empty($page)) {
  4739. $start = 0;
  4740. $perpage = 1;
  4741. } else {
  4742. $start = ($page - 1) * $perpage;
  4743. }
  4744. //取得信息列表
  4745. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4746. $rows = array();
  4747. $list = array();
  4748. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4749. // foreach ($info_list as $value)
  4750. // {
  4751. // $warehouse = $this->warehouse->read($value['warehouse']);
  4752. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4753. // $number = $value['number'];$ftime = time()-15*24*3600;
  4754. // if($c < 1)
  4755. // {
  4756. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4757. // }
  4758. // }
  4759. $warehouse_list = $this->warehouse->find_all();
  4760. $warehouse_list = array_column($warehouse_list, null, 'id');
  4761. foreach ($info_list as $value) {
  4762. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4763. 'title' => "",
  4764. ];
  4765. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4766. $number = $value['number'];
  4767. $ftime = time() - 15 * 24 * 3600;
  4768. if ($c < 1) {
  4769. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4770. }
  4771. }
  4772. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4773. // $query = $this->db->query($sql);
  4774. // $info_list = $query->result_array();
  4775. // $sql_two = "select title,id from crowd_warehouse";
  4776. // $query_two = $this->db->query($sql_two);
  4777. // $warehouse_list = $query_two->result_array();
  4778. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4779. // foreach ($info_list as $value)
  4780. // {
  4781. // if(isset($warehouse_arr[$value['warehouse']])){
  4782. // $warehouse = $warehouse_arr[$value['warehouse']];
  4783. // }else{
  4784. // $warehouse = [
  4785. // 'id'=>0,
  4786. // 'title'=>"异常",
  4787. // ];
  4788. // }
  4789. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4790. // $number = $value['number'];$ftime = time()-15*24*3600;
  4791. // if($c < 1)
  4792. // {
  4793. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4794. // }
  4795. // }
  4796. $listdata = array_slice($list, $start, $perpage);
  4797. $total = count($list);
  4798. $pagenum = ceil($total / $perpage);
  4799. $over = $total - ($start + $perpage);
  4800. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4801. echo json_encode($rows);
  4802. exit;
  4803. }
  4804. if (isset($post['s'])) {
  4805. $id_arr = $this->input->post('s');
  4806. $id_arr = explode(',', trim($id_arr, ','));
  4807. if (!$id_arr) {
  4808. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4809. exit;
  4810. }
  4811. //循环删除记录
  4812. foreach ($id_arr as $v) {
  4813. $dd = $this->whlabel->read($v);
  4814. if (!isset($dd['id'])) {
  4815. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4816. exit;
  4817. }
  4818. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4819. if (isset($zt[0])) {
  4820. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4821. exit;
  4822. }
  4823. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4824. foreach ($deldd as $vv) {
  4825. $this->whlabel->remove($vv['id']);
  4826. }
  4827. }
  4828. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4829. exit;
  4830. }
  4831. $this->_Template('whlabel_error', $this->data);
  4832. }
  4833. public function _errorexcel()
  4834. {
  4835. $post = $this->input->post(NULL, TRUE);
  4836. if (isset($_GET['page'])) {
  4837. $page = $this->input->get('page', true);
  4838. $perpage = $this->input->get('perpage', true);
  4839. $sku = $this->input->get('sku', true);
  4840. $warehouse = $this->input->get('warehouse', true);
  4841. $ktime = $this->input->get('ktime', true);
  4842. $jtime = $this->input->get('jtime', true);
  4843. $ktime = strtotime($ktime);
  4844. $jtime = strtotime($jtime);
  4845. $where = "sku != 'Preset'";
  4846. $gj = '';
  4847. if ($sku) {
  4848. $where .= " and sku like '%$sku%'";
  4849. } else {
  4850. if ($ktime && $jtime) {
  4851. $gj = " and time > '$ktime' and time < '$jtime'";
  4852. }
  4853. }
  4854. if ($warehouse) {
  4855. $where .= " and warehouse = '$warehouse'";
  4856. }
  4857. //数据排序
  4858. $order_str = "id desc";
  4859. if (empty($page)) {
  4860. $start = 0;
  4861. $perpage = 1;
  4862. } else {
  4863. $start = ($page - 1) * $perpage;
  4864. }
  4865. //取得信息列表
  4866. $rows = array();
  4867. $list = array();
  4868. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4869. foreach ($info_list as $value) {
  4870. $warehouse = $this->warehouse->read($value['warehouse']);
  4871. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4872. $number = $value['number'];
  4873. $ftime = time() - 15 * 24 * 3600;
  4874. if ($c < 1) {
  4875. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4876. }
  4877. }
  4878. $title = "0库存汇总";
  4879. $titlename = "<table border=1>
  4880. <tr align='center'>
  4881. <td>仓库</td>
  4882. <td>SKU</td>
  4883. <td>产品</td>
  4884. <td>当前库存</td>
  4885. </tr>
  4886. </table>";
  4887. $filename = $title . ".xls";
  4888. $tail = "";
  4889. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4890. }
  4891. }
  4892. /**
  4893. *
  4894. *
  4895. * 占单
  4896. *
  4897. *
  4898. **/
  4899. public function _kcyz()
  4900. {
  4901. $post = $this->input->post(NULL, TRUE);
  4902. if (isset($post['warehouse'])) {
  4903. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  4904. exit; //不再使用
  4905. $warehouse = $this->input->post('warehouse', true);
  4906. $whlabel = $this->input->post('whlabel', true);
  4907. $id = $this->input->post('id', true);
  4908. $shop = $this->input->post('shop', true);
  4909. $number = $this->input->post('number', true);
  4910. if (!$whlabel || $whlabel == '|') {
  4911. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  4912. exit;
  4913. }
  4914. $pp = explode('|', trim($whlabel, '|'));
  4915. $x = 0;
  4916. $save = array();
  4917. foreach ($pp as $va) {
  4918. $num = explode('-', $va);
  4919. if ($number) {
  4920. $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 = '')"); //通用
  4921. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  4922. } else {
  4923. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  4924. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  4925. }
  4926. $x++;
  4927. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  4928. $save[] = $x - 1;
  4929. continue; //提前先加X不然出错,所以要减1
  4930. }
  4931. }
  4932. if (isset($save[0])) {
  4933. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  4934. exit;
  4935. } else {
  4936. echo json_encode(array('success' => true));
  4937. exit;
  4938. }
  4939. }
  4940. }
  4941. public function _db()
  4942. {
  4943. $post = $this->input->post(NULL, TRUE);
  4944. if (isset($post['page'])) {
  4945. $page = $this->input->post('page', true);
  4946. $perpage = $this->input->post('perpage', true);
  4947. $sku = $this->input->post('sku', true);
  4948. $number = $this->input->post('number', true);
  4949. $warehouse = $this->input->post('warehouse', true);
  4950. $purchase = $this->input->post('purchase', true);
  4951. $orderinfo = $this->input->post('orderinfo', true);
  4952. $waybill = $this->input->post('waybill', true);
  4953. $category = $this->input->post('category', true);
  4954. $size = $this->input->post('size', true);
  4955. $grade = $this->input->post('grade', true);
  4956. $color = $this->input->post('color', true);
  4957. $lowe = $this->input->post('lowe', true);
  4958. $state = $this->input->post('state', true);
  4959. $label = $this->input->post('label', true);
  4960. $timetk = $this->input->post('timetkk', true);
  4961. $timetj = $this->input->post('timetjj', true);
  4962. $timetk = strtotime($timetk);
  4963. $timetj = strtotime($timetj);
  4964. $where = "dbtime > 0";
  4965. if ($timetk && $timetj) {
  4966. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  4967. }
  4968. if ($sku) {
  4969. $where .= " and sku = '$sku'";
  4970. }
  4971. if ($warehouse) {
  4972. $where .= " and warehouse = '$warehouse'";
  4973. if ($warehouse == 12) {
  4974. $w = 'specialstock';
  4975. } else {
  4976. $w = 'whlabel';
  4977. }
  4978. }
  4979. if ($purchase) {
  4980. $where .= " and purchase = '$purchase'";
  4981. }
  4982. if ($category) {
  4983. $where .= " and features like '%-$category-%'";
  4984. }
  4985. if ($size) {
  4986. $where .= " and features like '%-$size-%'";
  4987. }
  4988. if ($grade) {
  4989. $where .= " and features like '%-$grade-%'";
  4990. }
  4991. if ($color) {
  4992. $where .= " and features like '%-$color-%'";
  4993. }
  4994. if ($lowe) {
  4995. $where .= " and features like '%-$lowe-%'";
  4996. }
  4997. if ($state != '') {
  4998. $where .= " and state = '$state'";
  4999. }
  5000. //数据排序
  5001. $order_str = "dbtime desc";
  5002. if (empty($page)) {
  5003. $start = 0;
  5004. $perpage = 1;
  5005. } else {
  5006. $start = ($page - 1) * $perpage;
  5007. }
  5008. //取得信息列表
  5009. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5010. foreach ($info_list as $key => $value) {
  5011. $warehouse = $this->$w->read($value['warehouse']);
  5012. $info_list[$key]['warehouse'] = $warehouse['title'];
  5013. $purchase = $this->purchase->read($value['purchase']);
  5014. $info_list[$key]['purchase'] = $purchase['title'];
  5015. if ($value['enter'] != 0) {
  5016. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5017. } else {
  5018. $info_list[$key]['enter'] = "";
  5019. }
  5020. if ($value['dbtime'] != 0) {
  5021. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5022. } else {
  5023. $info_list[$key]['dbtime'] = "";
  5024. }
  5025. if ($value['state'] == 0) {
  5026. $info_list[$key]['state'] = "在库";
  5027. } else if ($value['state'] == 1) {
  5028. $info_list[$key]['state'] = "出库";
  5029. } else if ($value['state'] == 2) {
  5030. $info_list[$key]['state'] = "退库";
  5031. } else if ($value['state'] == 3) {
  5032. $info_list[$key]['state'] = "调拨中";
  5033. } else if ($value['state'] == 4) {
  5034. $info_list[$key]['state'] = "再加工";
  5035. } else if ($value['state'] == 5) {
  5036. $info_list[$key]['state'] = "维修中";
  5037. } else if ($value['state'] == 6) {
  5038. $info_list[$key]['state'] = "盘亏";
  5039. } else if ($value['state'] == 7) {
  5040. $info_list[$key]['state'] = "更换标签";
  5041. } else if ($value['state'] == 8) {
  5042. $info_list[$key]['state'] = "其它";
  5043. } else if ($value['state'] == 9) {
  5044. $info_list[$key]['state'] = "预设";
  5045. }
  5046. }
  5047. $total = $this->whlabel->find_count($where);
  5048. $pagenum = ceil($total / $perpage);
  5049. $over = $total - ($start + $perpage);
  5050. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5051. echo json_encode($rows);
  5052. exit;
  5053. }
  5054. if (isset($post['outsku'])) {
  5055. $time = time();
  5056. $cz = $this->input->post('cz', true);
  5057. $label = $this->input->post('outsku', true);
  5058. $sl = $this->input->post('sl', true);
  5059. $num = $this->input->post('num', true);
  5060. //$warehouse = $this->input->post('warehouse',true);
  5061. if (!$sl) {
  5062. $sl = 1;
  5063. }
  5064. if (!$warehouse) {
  5065. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5066. exit;
  5067. }
  5068. $dblabel = $this->whlabellabel->get_label($label);
  5069. if ($dblabel) {
  5070. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5071. if (count($data) < 1) {
  5072. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5073. exit;
  5074. }
  5075. if (count($data) < $num) {
  5076. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5077. exit;
  5078. }
  5079. for ($i = 0; $i < $sl; $i++) {
  5080. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5081. }
  5082. echo json_encode(array('success' => true));
  5083. exit;
  5084. } else {
  5085. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5086. exit;
  5087. }
  5088. }
  5089. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5090. $this->_Template('whlabel_db', $this->data);
  5091. }
  5092. public function _dbrk()
  5093. {
  5094. $post = $this->input->post(NULL, TRUE);
  5095. if (isset($post['page'])) {
  5096. $page = $this->input->post('page', true);
  5097. $perpage = $this->input->post('perpage', true);
  5098. $sku = $this->input->post('sku', true);
  5099. $number = $this->input->post('number', true);
  5100. $warehouse = $this->input->post('warehouse', true);
  5101. $purchase = $this->input->post('purchase', true);
  5102. $orderinfo = $this->input->post('orderinfo', true);
  5103. $waybill = $this->input->post('waybill', true);
  5104. $category = $this->input->post('category', true);
  5105. $size = $this->input->post('size', true);
  5106. $grade = $this->input->post('grade', true);
  5107. $color = $this->input->post('color', true);
  5108. $lowe = $this->input->post('lowe', true);
  5109. $state = $this->input->post('state', true);
  5110. $label = $this->input->post('label', true);
  5111. $ctime = $this->input->post('ctime', true);
  5112. $timetk = $this->input->post('timetkk', true);
  5113. $timetj = $this->input->post('timetjj', true);
  5114. $timetk = strtotime($timetk);
  5115. $timetj = strtotime($timetj);
  5116. $where = "dbtime > 0";
  5117. if ($timetk && $timetj) {
  5118. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5119. }
  5120. if ($sku) {
  5121. $where .= " and sku = '$sku'";
  5122. }
  5123. if ($warehouse) {
  5124. $where .= " and warehouse = '$warehouse'";
  5125. }
  5126. if ($purchase) {
  5127. $where .= " and purchase = '$purchase'";
  5128. }
  5129. if ($category) {
  5130. $where .= " and features like '%-$category-%'";
  5131. }
  5132. if ($size) {
  5133. $where .= " and features like '%-$size-%'";
  5134. }
  5135. if ($grade) {
  5136. $where .= " and features like '%-$grade-%'";
  5137. }
  5138. if ($color) {
  5139. $where .= " and features like '%-$color-%'";
  5140. }
  5141. if ($lowe) {
  5142. $where .= " and features like '%-$lowe-%'";
  5143. }
  5144. if ($state != '') {
  5145. $where .= " and state = '$state'";
  5146. }
  5147. //数据排序
  5148. $order_str = "dbtime desc";
  5149. if (empty($page)) {
  5150. $start = 0;
  5151. $perpage = 1;
  5152. } else {
  5153. $start = ($page - 1) * $perpage;
  5154. }
  5155. //取得信息列表
  5156. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5157. foreach ($info_list as $key => $value) {
  5158. $warehouse = $this->warehouse->read($value['warehouse']);
  5159. $info_list[$key]['warehouse'] = $warehouse['title'];
  5160. $purchase = $this->purchase->read($value['purchase']);
  5161. $info_list[$key]['purchase'] = $purchase['title'];
  5162. if ($value['enter'] != 0) {
  5163. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5164. } else {
  5165. $info_list[$key]['enter'] = "";
  5166. }
  5167. if ($value['dbtime'] != 0) {
  5168. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5169. } else {
  5170. $info_list[$key]['dbtime'] = "";
  5171. }
  5172. if ($value['state'] == 0) {
  5173. $info_list[$key]['state'] = "在库";
  5174. } else if ($value['state'] == 1) {
  5175. $info_list[$key]['state'] = "出库";
  5176. } else if ($value['state'] == 2) {
  5177. $info_list[$key]['state'] = "退库";
  5178. } else if ($value['state'] == 3) {
  5179. $info_list[$key]['state'] = "调拨中";
  5180. } else if ($value['state'] == 4) {
  5181. $info_list[$key]['state'] = "再加工";
  5182. } else if ($value['state'] == 5) {
  5183. $info_list[$key]['state'] = "维修中";
  5184. } else if ($value['state'] == 6) {
  5185. $info_list[$key]['state'] = "盘亏";
  5186. } else if ($value['state'] == 7) {
  5187. $info_list[$key]['state'] = "更换标签";
  5188. } else if ($value['state'] == 8) {
  5189. $info_list[$key]['state'] = "其它";
  5190. } else if ($value['state'] == 9) {
  5191. $info_list[$key]['state'] = "预设";
  5192. }
  5193. }
  5194. $total = $this->whlabel->find_count($where);
  5195. $pagenum = ceil($total / $perpage);
  5196. $over = $total - ($start + $perpage);
  5197. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5198. echo json_encode($rows);
  5199. exit;
  5200. }
  5201. if (isset($post['rsku'])) {
  5202. $cz = $this->input->post('cz', true);
  5203. $label = $this->input->post('rsku', true);
  5204. $sl = $this->input->post('sl', true);
  5205. $warehouse = $this->input->post('warehouse', true);
  5206. if (!$sl) {
  5207. $sl = 1;
  5208. }
  5209. if (!$warehouse) {
  5210. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5211. exit;
  5212. }
  5213. $dblabel = $this->whlabellabel->get_label($label);
  5214. if ($dblabel) {
  5215. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5216. if (count($data) < 1) {
  5217. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5218. exit;
  5219. }
  5220. if ($sl > count($data)) {
  5221. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5222. exit;
  5223. }
  5224. $time = time();
  5225. for ($i = 0; $i < $sl; $i++) {
  5226. $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']);
  5227. }
  5228. echo json_encode(array('success' => true));
  5229. exit;
  5230. } else {
  5231. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5232. exit;
  5233. }
  5234. }
  5235. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5236. $this->_Template('whlabel_dbrk', $this->data);
  5237. }
  5238. public function _whlabelczdc()
  5239. {
  5240. if (isset($_GET['excel'])) {
  5241. //数据排序
  5242. $order_str = "id desc";
  5243. if (empty($page)) {
  5244. $start = 0;
  5245. $perpage = 1;
  5246. } else {
  5247. $start = ($page - 1) * $perpage;
  5248. }
  5249. $state = $this->input->get('state', true);
  5250. $sku = $this->input->get('sku', true);
  5251. $ctime = $this->input->get('ctime', true);
  5252. $category = $this->input->get('category', true);
  5253. $size = $this->input->get('size', true);
  5254. $grade = $this->input->get('grade', true);
  5255. $color = $this->input->get('color', true);
  5256. $lowe = $this->input->get('lowe', true);
  5257. $timetk = $this->input->get('timetkk', true);
  5258. $timetj = $this->input->get('timetjj', true);
  5259. $timetk = strtotime($timetk);
  5260. $timetj = strtotime($timetj);
  5261. $where = "dbtime > 0";
  5262. if ($timetk && $timetj) {
  5263. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5264. }
  5265. if ($category) {
  5266. $where .= " and features like '%-$category-%'";
  5267. }
  5268. if ($size) {
  5269. $where .= " and features like '%-$size-%'";
  5270. }
  5271. if ($grade) {
  5272. $where .= " and features like '%-$grade-%'";
  5273. }
  5274. if ($color) {
  5275. $where .= " and features like '%-$color-%'";
  5276. }
  5277. if ($lowe) {
  5278. $where .= " and features like '%-$lowe-%'";
  5279. }
  5280. //取得信息列表
  5281. $info_list = $this->whlabel->find_all($where, '*');
  5282. $rows = array();
  5283. $list = array();
  5284. foreach ($info_list as $key => $value) {
  5285. $rows[$value['sku']] = $value; //所有数据sku
  5286. }
  5287. foreach ($rows as $value) {
  5288. $warehouse = $this->warehouse->read($value['warehouse']);
  5289. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5290. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5291. if ($value['orderinfo'] == 0) {
  5292. $info_list[$key]['orderinfo'] = "";
  5293. }
  5294. if ($value['waybill'] == 0) {
  5295. $info_list[$key]['waybill'] = "";
  5296. }
  5297. if ($value['state'] == 0) {
  5298. $value['state'] = "在库";
  5299. } else if ($value['state'] == 3) {
  5300. $value['state'] = "调拨中";
  5301. }
  5302. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5303. }
  5304. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5305. $titlename = "<table border=1>
  5306. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5307. <tr align='center'>
  5308. <td>SKU</td>
  5309. <td>产品</td>
  5310. <td>调拨数量</td>
  5311. <td>入库数量</td>
  5312. </tr>
  5313. </table>";
  5314. $filename = $title . ".xls";
  5315. $tail = "";
  5316. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5317. }
  5318. }
  5319. public function _print($arg_array)
  5320. {
  5321. if (isset($_SESSION['api'])) {
  5322. $user = $this->user->get_api($_SESSION['api']);
  5323. $usp = $user;
  5324. $fgshop = "";
  5325. $sid = "";
  5326. $wid = "";
  5327. $wtype = "";
  5328. $usersp = explode('|', trim($user['shop'], '|'));
  5329. $userwh = explode('|', trim($user['warehouse'], '|'));
  5330. foreach ($usersp as $value) {
  5331. $fgshop .= " shop = " . $value . " or";
  5332. $sid .= " id = " . $value . " or";
  5333. }
  5334. foreach ($userwh as $value) {
  5335. $wid .= " id = " . $value . " or";
  5336. $wtype .= " type = " . $value . " or";
  5337. }
  5338. }
  5339. $post = $this->input->post(NULL, TRUE);
  5340. if (isset($post['tmsku'])) {
  5341. $tmsku = $this->input->post('tmsku', true);
  5342. if (is_numeric($tmsku)) {
  5343. $yyh = $this->whlabellabel->get_label($tmsku);
  5344. } else {
  5345. $yyh = $this->whlabellabel->get_sku($tmsku);
  5346. }
  5347. if ($yyh) {
  5348. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5349. exit;
  5350. } else {
  5351. echo json_encode(array('success' => false));
  5352. exit;
  5353. }
  5354. }
  5355. $classid = $this->classid->sku();
  5356. $pm = $classid;
  5357. $scsku = $classid;
  5358. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5359. if (isset($post['warehouse'])) {
  5360. if ($post['warehouse']) {
  5361. $list = array();
  5362. $num = "";
  5363. $title = "";
  5364. $features = "";
  5365. $order = 0;
  5366. $post['shop'] = '';
  5367. $brand = $this->input->post('brand', true);
  5368. if ($brand != '0,') {
  5369. $b = $this->brand->read(rtrim($brand, ','));
  5370. if ($b) {
  5371. $post['shop'] = str_replace('|', ',', $b['shop']);
  5372. }
  5373. }
  5374. $post['details'] = $this->input->post('details', true); //打印数量
  5375. $xbqnum = $this->input->post('xbqnum', true);
  5376. $post['purchase'] = $this->input->post('purchase', true);
  5377. $post['warehouse'] = $this->input->post('warehouse', true);
  5378. $post['purchase'] = $this->input->post('purchase', true);
  5379. $post['retreatwarehouse'] = $post['warehouse'];
  5380. $post['cpbz'] = $this->input->post('cpbz', true);
  5381. $post['state'] = 9;
  5382. $category = $this->input->post('category', true);
  5383. $list['category'] = $category;
  5384. $list['hairtype'] = $this->input->post('hairtype', true);
  5385. $list['grade'] = $this->input->post('grade', true);
  5386. $size = $this->input->post('size', true);
  5387. $list['size'] = rtrim($size, ',');
  5388. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5389. $list['extension'] = $this->input->post('extension', true);
  5390. if ($category == 1297) {
  5391. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5392. }
  5393. if ($category == 1702) {
  5394. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5395. $list['syother'] = $this->input->post('syother', true);
  5396. }
  5397. if ($category == 133) {
  5398. $list['fittype'] = $this->input->post('fittype', true);
  5399. $list['acother'] = $this->input->post('acother', true);
  5400. }
  5401. $list['color'] = $this->input->post('color', true);
  5402. $list['lowe'] = $this->input->post('lowe', true);
  5403. if ($category == 127) {
  5404. $list['type'] = $this->input->post('type', true);
  5405. $list['headroad'] = $this->input->post('headroad', true);
  5406. $list['density'] = $this->input->post('density', true);
  5407. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5408. $list['lacesize'] = $this->input->post('lacesize', true);
  5409. }
  5410. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5411. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5412. }
  5413. if ($category == 128) {
  5414. $list['lacetype'] = $this->input->post('lacetype', true);
  5415. $list['haircap'] = $this->input->post('haircap', true);
  5416. $list['density'] = $this->input->post('density', true);
  5417. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5418. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5419. $list['wigother'] = $this->input->post('wigother', true);
  5420. $list['wigother1'] = $this->input->post('wigother1', true);
  5421. $list['wigother2'] = $this->input->post('wigother2', true);
  5422. }
  5423. if ($category == 129) {
  5424. $list['wide'] = $this->input->post('wide', true);
  5425. }
  5426. if ($category == 131) {
  5427. $list['gifttype'] = $this->input->post('gifttype', true);
  5428. $list['giftother'] = $this->input->post('giftother', true);
  5429. }
  5430. if ($category == 134) {
  5431. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5432. }
  5433. if ($category == 1297) {
  5434. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5435. $list['sywigother'] = $this->input->post('sywigother', true);
  5436. }
  5437. if ($category == 130 || $category == 133 || $category == 1702) {
  5438. $list['items'] = $this->input->post('items', true);
  5439. $list['weight'] = $this->input->post('weight', true);
  5440. }
  5441. if ($category == 1702) {
  5442. $list['syhairther'] = $this->input->post('syhairther', true);
  5443. }
  5444. foreach ($list as $k => $v) {
  5445. if ($v != 0) {
  5446. $num .= $v;
  5447. $features .= $v . '-';
  5448. $post[$k] = $v;
  5449. $typeclass = $this->typeclass->read($v);
  5450. if (isset($pm[$typeclass['classid']])) {
  5451. if (stripos($typeclass['zh'], '|') !== false) {
  5452. $exzh = explode('|', $typeclass['zh']);
  5453. $pm[$typeclass['classid']] = $exzh[0];
  5454. } else {
  5455. $pm[$typeclass['classid']] = $typeclass['zh'];
  5456. }
  5457. }
  5458. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5459. if ($k != 'size') {
  5460. $title .= $typeclass['title'] . " ";
  5461. }
  5462. }
  5463. }
  5464. $typeclass = $this->typeclass->read($list['size']);
  5465. $title .= $typeclass['title'];
  5466. $time = time();
  5467. $post['title'] = rtrim($title, ' ');
  5468. $post['number'] = $num;
  5469. $post['features'] = '-' . $features;
  5470. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5471. $featurespp = explode('-', trim($featurespp, '-'));
  5472. if (isset($featurespp[5])) {
  5473. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5474. } else {
  5475. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5476. }
  5477. $post['enter'] = $time;
  5478. $post['time'] = $time; //操作时间
  5479. $scsku = implode("-", $scsku);
  5480. $zh = implode(" ", $pm);
  5481. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5482. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5483. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5484. $post['sku'] = $bqsku;
  5485. $label = time() . rand(0, 9);
  5486. $post['label'] = $label;
  5487. $cpid = $this->whlabellabel->find_count();
  5488. $post['cpid'] = $cpid + 1;
  5489. $cpid = $post['cpid'];
  5490. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5491. //if($whlabelbarcode)
  5492. //{
  5493. //$post['label'] = $whlabelbarcode['label'];
  5494. //if(!$this->whlabellabel->insert($post))
  5495. //{
  5496. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5497. //}
  5498. //}
  5499. //else
  5500. //{
  5501. $this->db->trans_begin();
  5502. $this->whlabellabel->insert($post);
  5503. //$this->whlabelbarcode->insert($post);
  5504. if ($this->db->trans_status() === TRUE) {
  5505. $this->db->trans_commit();
  5506. } else {
  5507. $this->db->trans_rollback();
  5508. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5509. exit;
  5510. }
  5511. //}
  5512. $warehouse_name = "";
  5513. $warehouse = $post['warehouse'];
  5514. if($warehouse == 12){
  5515. $warehouse_name = "特殊库存库";
  5516. }
  5517. // if($warehouse == 13){
  5518. // $warehouse_name = "许昌仓";
  5519. // }
  5520. // if($warehouse == 5){
  5521. // $warehouse_name = "美国店";
  5522. // }
  5523. // if($warehouse == 16){
  5524. // $warehouse_name = "定制头套仓";
  5525. // }
  5526. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5527. if(!empty($warehouse_name)){
  5528. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5529. }
  5530. $purchase = $this->purchase->read($post['purchase']);
  5531. 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));
  5532. exit; //特殊仓目前不需要仓库选项
  5533. }
  5534. }
  5535. if (isset($_SESSION['api'])) {
  5536. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5537. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5538. $this->data['wlshop'] = $wlshop;
  5539. $this->data['warehouse'] = $warehouse;
  5540. }
  5541. $whlabelwz = $this->whlabelwz->find_all();
  5542. $this->data['whlabelwz'] = $whlabelwz;
  5543. $this->_Template('whlabel_print', $this->data);
  5544. }
  5545. public function _usaprint($arg_array)
  5546. {
  5547. if (isset($_SESSION['api'])) {
  5548. $user = $this->user->get_api($_SESSION['api']);
  5549. $usp = $user;
  5550. $fgshop = "";
  5551. $sid = "";
  5552. $wid = "";
  5553. $wtype = "";
  5554. $usersp = explode('|', trim($user['shop'], '|'));
  5555. $userwh = explode('|', trim($user['warehouse'], '|'));
  5556. foreach ($usersp as $value) {
  5557. $fgshop .= " shop = " . $value . " or";
  5558. $sid .= " id = " . $value . " or";
  5559. }
  5560. foreach ($userwh as $value) {
  5561. $wid .= " id = " . $value . " or";
  5562. $wtype .= " type = " . $value . " or";
  5563. }
  5564. }
  5565. $post = $this->input->post(NULL, TRUE);
  5566. if (isset($post['tmsku'])) {
  5567. $tmsku = $this->input->post('tmsku', true);
  5568. if (is_numeric($tmsku)) {
  5569. $yyh = $this->whlabellabel->get_label($tmsku);
  5570. } else {
  5571. $yyh = $this->whlabellabel->get_sku($tmsku);
  5572. }
  5573. if ($yyh) {
  5574. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5575. exit;
  5576. } else {
  5577. echo json_encode(array('success' => false));
  5578. exit;
  5579. }
  5580. }
  5581. $classid = $this->classid->sku();
  5582. $pm = $classid;
  5583. $scsku = $classid;
  5584. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5585. if (isset($post['warehouse'])) {
  5586. if ($post['warehouse']) {
  5587. $list = array();
  5588. $num = "";
  5589. $title = "";
  5590. $features = "";
  5591. $order = 0;
  5592. $post['shop'] = '';
  5593. $brand = $this->input->post('brand', true);
  5594. if ($brand != '0,') {
  5595. $b = $this->brand->read(rtrim($brand, ','));
  5596. if ($b) {
  5597. $post['shop'] = str_replace('|', ',', $b['shop']);
  5598. }
  5599. }
  5600. $post['details'] = $this->input->post('details', true); //打印数量
  5601. $xbqnum = $this->input->post('xbqnum', true);
  5602. $post['purchase'] = $this->input->post('purchase', true);
  5603. $post['warehouse'] = $this->input->post('warehouse', true);
  5604. $post['purchase'] = $this->input->post('purchase', true);
  5605. $post['retreatwarehouse'] = $post['warehouse'];
  5606. $post['cpbz'] = $this->input->post('cpbz', true);
  5607. $post['state'] = 9;
  5608. $category = $this->input->post('category', true);
  5609. $list['category'] = $category;
  5610. $list['hairtype'] = $this->input->post('hairtype', true);
  5611. $list['grade'] = $this->input->post('grade', true);
  5612. $size = $this->input->post('size', true);
  5613. $list['size'] = rtrim($size, ',');
  5614. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5615. $list['extension'] = $this->input->post('extension', true);
  5616. if ($category == 1297) {
  5617. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5618. }
  5619. if ($category == 1702) {
  5620. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5621. $list['syother'] = $this->input->post('syother', true);
  5622. }
  5623. if ($category == 133) {
  5624. $list['fittype'] = $this->input->post('fittype', true);
  5625. $list['acother'] = $this->input->post('acother', true);
  5626. }
  5627. $list['color'] = $this->input->post('color', true);
  5628. $list['lowe'] = $this->input->post('lowe', true);
  5629. if ($category == 127) {
  5630. $list['type'] = $this->input->post('type', true);
  5631. $list['headroad'] = $this->input->post('headroad', true);
  5632. $list['density'] = $this->input->post('density', true);
  5633. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5634. $list['lacesize'] = $this->input->post('lacesize', true);
  5635. }
  5636. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5637. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5638. }
  5639. if ($category == 128) {
  5640. $list['lacetype'] = $this->input->post('lacetype', true);
  5641. $list['haircap'] = $this->input->post('haircap', true);
  5642. $list['density'] = $this->input->post('density', true);
  5643. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5644. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5645. $list['wigother'] = $this->input->post('wigother', true);
  5646. $list['wigother1'] = $this->input->post('wigother1', true);
  5647. $list['wigother2'] = $this->input->post('wigother2', true);
  5648. }
  5649. if ($category == 129) {
  5650. $list['wide'] = $this->input->post('wide', true);
  5651. }
  5652. if ($category == 131) {
  5653. $list['gifttype'] = $this->input->post('gifttype', true);
  5654. $list['giftother'] = $this->input->post('giftother', true);
  5655. }
  5656. if ($category == 134) {
  5657. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5658. }
  5659. if ($category == 1297) {
  5660. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5661. $list['sywigother'] = $this->input->post('sywigother', true);
  5662. }
  5663. if ($category == 130 || $category == 133 || $category == 1702) {
  5664. $list['items'] = $this->input->post('items', true);
  5665. $list['weight'] = $this->input->post('weight', true);
  5666. }
  5667. if ($category == 1702) {
  5668. $list['syhairther'] = $this->input->post('syhairther', true);
  5669. }
  5670. foreach ($list as $k => $v) {
  5671. if ($v != 0) {
  5672. $num .= $v;
  5673. $features .= $v . '-';
  5674. $post[$k] = $v;
  5675. $typeclass = $this->typeclass->read($v);
  5676. if (isset($pm[$typeclass['classid']])) {
  5677. if (stripos($typeclass['zh'], '|') !== false) {
  5678. $exzh = explode('|', $typeclass['zh']);
  5679. $pm[$typeclass['classid']] = $exzh[0];
  5680. } else {
  5681. $pm[$typeclass['classid']] = $typeclass['zh'];
  5682. }
  5683. }
  5684. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5685. if ($k != 'size') {
  5686. $title .= $typeclass['title'] . " ";
  5687. }
  5688. }
  5689. }
  5690. $typeclass = $this->typeclass->read($list['size']);
  5691. $title .= $typeclass['title'];
  5692. $time = time();
  5693. $post['title'] = rtrim($title, ' ');
  5694. $post['number'] = $num;
  5695. $post['features'] = '-' . $features;
  5696. $fp = $this->whlabel->get_features($post['features']);
  5697. if (!$fp) {
  5698. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5699. exit;
  5700. }
  5701. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5702. $featurespp = explode('-', trim($featurespp, '-'));
  5703. if (isset($featurespp[5])) {
  5704. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5705. } else {
  5706. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5707. }
  5708. $post['enter'] = $time;
  5709. $post['time'] = $time; //操作时间
  5710. $scsku = implode("-", $scsku);
  5711. $zh = implode(" ", $pm);
  5712. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5713. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5714. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5715. $post['sku'] = $fp['sku'];
  5716. $post['label'] = $fp['sku'];
  5717. $cpid = $this->whlabellabel->find_count();
  5718. $post['cpid'] = $cpid + 1;
  5719. $cpid = $post['cpid'];
  5720. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5721. //if($whlabelbarcode)
  5722. //{
  5723. //$post['label'] = $whlabelbarcode['label'];
  5724. //if(!$this->whlabellabel->insert($post))
  5725. //{
  5726. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5727. //}
  5728. //}
  5729. //else
  5730. //{
  5731. $this->db->trans_begin();
  5732. $this->whlabellabel->insert($post);
  5733. //$this->whlabelbarcode->insert($post);
  5734. if ($this->db->trans_status() === TRUE) {
  5735. $this->db->trans_commit();
  5736. } else {
  5737. $this->db->trans_rollback();
  5738. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5739. exit;
  5740. }
  5741. //}
  5742. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5743. $purchase = $this->purchase->read($post['purchase']);
  5744. 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));
  5745. exit; //特殊仓目前不需要仓库选项
  5746. }
  5747. }
  5748. if (isset($_SESSION['api'])) {
  5749. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5750. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5751. $this->data['wlshop'] = $wlshop;
  5752. $this->data['warehouse'] = $warehouse;
  5753. }
  5754. $whlabelwz = $this->whlabelwz->find_all();
  5755. $this->data['whlabelwz'] = $whlabelwz;
  5756. $this->_Template('whlabel_usaprint', $this->data);
  5757. }
  5758. public function _printrk($arg_array)
  5759. {
  5760. $prc = array();
  5761. $purchase = $this->purchase->find_all();
  5762. foreach ($purchase as $k => $v) {
  5763. $prc[$v['id']] = $v['title'];
  5764. }
  5765. $post = $this->input->post(NULL, TRUE);
  5766. if (isset($post['page'])) {
  5767. $page = $this->input->post('page', true);
  5768. $perpage = $this->input->post('perpage', true);
  5769. $sku = $this->input->post('sku', true);
  5770. $bs = $this->input->post('bs', true);
  5771. $number = $this->input->post('number', true);
  5772. $warehouse = $this->input->post('warehouse', true);
  5773. $purchase = $this->input->post('purchase', true);
  5774. $orderinfo = $this->input->post('orderinfo', true);
  5775. $waybill = $this->input->post('waybill', true);
  5776. $category = $this->input->post('category', true);
  5777. $size = $this->input->post('size', true);
  5778. $grade = $this->input->post('grade', true);
  5779. $color = $this->input->post('color', true);
  5780. $lowe = $this->input->post('lowe', true);
  5781. $state = $this->input->post('state', true);
  5782. $label = $this->input->post('label', true);
  5783. $timetk = $this->input->post('ktime', true);
  5784. $timetj = $this->input->post('jtime', true);
  5785. $timetk = strtotime($timetk);
  5786. $timetj = strtotime($timetj);
  5787. $where = "1=1 ";
  5788. if ($timetk && $timetj) {
  5789. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5790. }
  5791. if ($sku) {
  5792. $where .= " and sku = '$sku'";
  5793. }
  5794. if ($bs != '') {
  5795. $where .= " and bs = '$bs'";
  5796. }
  5797. if ($number) {
  5798. $where .= " and number = '$number'";
  5799. }
  5800. if ($warehouse) {
  5801. $where .= " and warehouse = '$warehouse'";
  5802. }
  5803. if ($purchase) {
  5804. $where .= " and purchase = '$purchase'";
  5805. }
  5806. if ($orderinfo) {
  5807. $where .= " and orderinfo = '$orderinfo'";
  5808. }
  5809. if ($waybill) {
  5810. $where .= " and waybill = '$waybill'";
  5811. }
  5812. if ($category) {
  5813. $where .= " and features like '%-$category-%'";
  5814. }
  5815. if ($size) {
  5816. $where .= " and features like '%-$size-%'";
  5817. }
  5818. if ($grade) {
  5819. $where .= " and features like '%-$grade-%'";
  5820. }
  5821. if ($color) {
  5822. $where .= " and features like '%-$color-%'";
  5823. }
  5824. if ($lowe) {
  5825. $where .= " and features like '%-$lowe-%'";
  5826. }
  5827. if ($label) {
  5828. $where .= " and label = '$label'";
  5829. }
  5830. if ($state || $state == 0) {
  5831. $where .= " and state = '$state'";
  5832. }
  5833. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5834. //数据排序
  5835. $order_str = "enter desc";
  5836. if (empty($page)) {
  5837. $start = 0;
  5838. $perpage = 1;
  5839. } else {
  5840. $start = ($page - 1) * $perpage;
  5841. }
  5842. //取得信息列表
  5843. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5844. foreach ($info_list as $key => $value) {
  5845. $warehouse = $this->warehouse->read($value['warehouse']);
  5846. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5847. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5848. if ($value['state'] == 0) {
  5849. $info_list[$key]['state'] = "在库";
  5850. } else if ($value['state'] == 1) {
  5851. $info_list[$key]['state'] = "出库";
  5852. } else if ($value['state'] == 2) {
  5853. $info_list[$key]['state'] = "退库";
  5854. } else if ($value['state'] == 3) {
  5855. $info_list[$key]['state'] = "调拨中";
  5856. } else if ($value['state'] == 4) {
  5857. $info_list[$key]['state'] = "再加工";
  5858. } else if ($value['state'] == 5) {
  5859. $info_list[$key]['state'] = "维修中";
  5860. } else if ($value['state'] == 6) {
  5861. $info_list[$key]['state'] = "盘亏";
  5862. } else if ($value['state'] == 7) {
  5863. $info_list[$key]['state'] = "更换标签";
  5864. } else if ($value['state'] == 8) {
  5865. $info_list[$key]['state'] = "其它";
  5866. } else if ($value['state'] == 9) {
  5867. $info_list[$key]['state'] = "预设";
  5868. } else if ($value['state'] == 10) {
  5869. $info_list[$key]['state'] = "美店零售";
  5870. }
  5871. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5872. }
  5873. $total = $this->$ck->find_count($where);
  5874. $pagenum = ceil($total / $perpage);
  5875. $over = $total - ($start + $perpage);
  5876. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5877. echo json_encode($rows);
  5878. exit;
  5879. }
  5880. if (isset($post['tmsku'])) {
  5881. $time = time();
  5882. $tmsku = $this->input->post('tmsku', true);
  5883. //$post['shop'] = $this->input->post('shop',true);
  5884. $num = $this->input->post('num', true);
  5885. $rktype = $this->input->post('rktype', true);
  5886. if ($num > 200) {
  5887. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5888. exit;
  5889. }
  5890. if (!$rktype) {
  5891. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5892. }
  5893. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  5894. /**
  5895. $wz = array();
  5896. foreach ($rk as $key=>$value)
  5897. {
  5898. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  5899. }
  5900. if(count($wz) > 1)
  5901. {
  5902. $wz = array_values($wz);
  5903. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  5904. }
  5905. **/
  5906. if (isset($rk[0]['purchase'])) {
  5907. $rk = $rk[0];
  5908. $j = 0;
  5909. $post['purchase'] = $rk['purchase'];
  5910. $post['warehouse'] = $rk['warehouse'];
  5911. $post['retreatwarehouse'] = $rk['warehouse'];
  5912. $post['sku'] = $rk['sku'];
  5913. $post['number'] = $rk['number'];
  5914. $post['features'] = $rk['features'];
  5915. $post['title'] = $rk['title'];
  5916. $post['enter'] = $time;
  5917. $post['time'] = $time;
  5918. $post['bs'] = 1;
  5919. $post['shop'] = $rk['shop'];
  5920. $post['details'] = $rk['details'];
  5921. $post['cpid'] = $rk['cpid'];
  5922. $post['cpbz'] = $rk['cpbz'];
  5923. //$post['rktype'] = $rktype;
  5924. $warehouse = $this->warehouse->read($rk['warehouse']);
  5925. if ($warehouse['bdck'] == '') {
  5926. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  5927. exit;
  5928. } else {
  5929. $bdck = $warehouse['bdck'];
  5930. }
  5931. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  5932. if (isset($pdwz['details'])) {
  5933. if ($pdwz['details'] != $post['details']) {
  5934. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  5935. exit;
  5936. }
  5937. }
  5938. $post['featurespp'] = $rk['featurespp'];
  5939. if ($post['warehouse'] == '5') {
  5940. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5941. if ($yza) {
  5942. if ($post['features'] != $yza[0]['features']) {
  5943. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  5944. exit;
  5945. }
  5946. }
  5947. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5948. if ($yzb) {
  5949. if ($post['sku'] != $yzb[0]['sku']) {
  5950. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  5951. exit;
  5952. }
  5953. }
  5954. }
  5955. for ($i = 0; $i < $num; $i++) {
  5956. $post['label'] = time() . rand(100, 999) . $i;
  5957. if ($this->$bdck->insert($post)) {
  5958. $j++;
  5959. }
  5960. }
  5961. /**
  5962. if($post['warehouse'] != 12)
  5963. {
  5964. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  5965. }
  5966. **/
  5967. if ($j == $num) {
  5968. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  5969. exit;
  5970. } else {
  5971. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  5972. exit;
  5973. }
  5974. } else {
  5975. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  5976. exit;
  5977. }
  5978. }
  5979. $this->_Template('whlabel_printrk', $this->data);
  5980. }
  5981. public function _printxzrk($arg_array)
  5982. {
  5983. $post = $this->input->post(NULL, TRUE);
  5984. if (isset($post['wzid'])) {
  5985. $time = time();
  5986. $id = $this->input->post('wzid', true);
  5987. //$post['shop'] = $this->input->post('shop',true);
  5988. $num = 1;
  5989. $rk = $this->whlabellabel->read($id);
  5990. if (isset($rk['purchase'])) {
  5991. $x = 0;
  5992. $post['purchase'] = $rk['purchase'];
  5993. $post['warehouse'] = $rk['warehouse'];
  5994. $post['retreatwarehouse'] = $rk['warehouse'];
  5995. $post['sku'] = $rk['sku'];
  5996. $post['number'] = $rk['number'];
  5997. $post['features'] = $rk['features'];
  5998. $post['title'] = $rk['title'];
  5999. $post['enter'] = $time;
  6000. $post['time'] = $time;
  6001. $post['bs'] = 1;
  6002. $post['shop'] = $rk['shop'];
  6003. $post['details'] = $rk['details'];
  6004. $post['cpid'] = $rk['cpid'];
  6005. $post['cpbz'] = $rk['cpbz'];
  6006. $warehouse = $this->warehouse->read($rk['warehouse']);
  6007. if ($warehouse['bdck'] == '') {
  6008. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6009. exit;
  6010. } else {
  6011. $bdck = $warehouse['bdck'];
  6012. }
  6013. $post['featurespp'] = $rk['featurespp'];
  6014. $this->db->trans_begin();
  6015. for ($i = 0; $i < $num; $i++) {
  6016. $post['label'] = time() . rand(100, 999) . $i;
  6017. $this->$bdck->insert($post);
  6018. }
  6019. /**
  6020. if($post['warehouse'] != 12)
  6021. {
  6022. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6023. }
  6024. **/
  6025. if ($this->db->trans_status() === TRUE) {
  6026. $this->db->trans_commit();
  6027. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6028. exit;
  6029. } else {
  6030. $this->db->trans_rollback();
  6031. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6032. exit;
  6033. }
  6034. } else {
  6035. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6036. exit;
  6037. }
  6038. }
  6039. }
  6040. public function _printck($arg_array)
  6041. {
  6042. $prc = array();
  6043. $purchase = $this->purchase->find_all();
  6044. foreach ($purchase as $k => $v) {
  6045. $prc[$v['id']] = $v['title'];
  6046. }
  6047. $post = $this->input->post(NULL, TRUE);
  6048. if (isset($post['page'])) {
  6049. $page = $this->input->post('page', true);
  6050. $perpage = $this->input->post('perpage', true);
  6051. $sku = $this->input->post('sku', true);
  6052. $bs = $this->input->post('bs', true);
  6053. $number = $this->input->post('number', true);
  6054. $warehouse = $this->input->post('warehouse', true);
  6055. $purchase = $this->input->post('purchase', true);
  6056. $orderinfo = $this->input->post('orderinfo', true);
  6057. $waybill = $this->input->post('waybill', true);
  6058. $category = $this->input->post('category', true);
  6059. $size = $this->input->post('size', true);
  6060. $grade = $this->input->post('grade', true);
  6061. $color = $this->input->post('color', true);
  6062. $lowe = $this->input->post('lowe', true);
  6063. $state = $this->input->post('state', true);
  6064. $label = $this->input->post('label', true);
  6065. $timetk = $this->input->post('ktime', true);
  6066. $timetj = $this->input->post('jtime', true);
  6067. $timetk = strtotime($timetk);
  6068. $timetj = strtotime($timetj);
  6069. $where = "state=1 ";
  6070. if ($timetk && $timetj) {
  6071. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6072. }
  6073. if ($sku) {
  6074. $where .= " and sku = '$sku'";
  6075. }
  6076. if ($bs != '') {
  6077. $where .= " and bs = '$bs'";
  6078. }
  6079. if ($number) {
  6080. $where .= " and number = '$number'";
  6081. }
  6082. if ($warehouse) {
  6083. $where .= " and warehouse = '$warehouse'";
  6084. }
  6085. if ($purchase) {
  6086. $where .= " and purchase = '$purchase'";
  6087. }
  6088. if ($orderinfo) {
  6089. $where .= " and orderinfo = '$orderinfo'";
  6090. }
  6091. if ($waybill) {
  6092. $where .= " and waybill = '$waybill'";
  6093. }
  6094. if ($category) {
  6095. $where .= " and features like '%-$category-%'";
  6096. }
  6097. if ($size) {
  6098. $where .= " and features like '%-$size-%'";
  6099. }
  6100. if ($grade) {
  6101. $where .= " and features like '%-$grade-%'";
  6102. }
  6103. if ($color) {
  6104. $where .= " and features like '%-$color-%'";
  6105. }
  6106. if ($lowe) {
  6107. $where .= " and features like '%-$lowe-%'";
  6108. }
  6109. if ($label) {
  6110. $where .= " and label = '$label'";
  6111. }
  6112. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6113. //数据排序
  6114. $order_str = "outk desc";
  6115. if (empty($page)) {
  6116. $start = 0;
  6117. $perpage = 1;
  6118. } else {
  6119. $start = ($page - 1) * $perpage;
  6120. }
  6121. //取得信息列表
  6122. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6123. foreach ($info_list as $key => $value) {
  6124. $warehouse = $this->warehouse->read($value['warehouse']);
  6125. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6126. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6127. if ($value['state'] == 0) {
  6128. $info_list[$key]['state'] = "在库";
  6129. } else if ($value['state'] == 1) {
  6130. $info_list[$key]['state'] = "出库";
  6131. } else if ($value['state'] == 2) {
  6132. $info_list[$key]['state'] = "退库";
  6133. } else if ($value['state'] == 3) {
  6134. $info_list[$key]['state'] = "调拨中";
  6135. } else if ($value['state'] == 4) {
  6136. $info_list[$key]['state'] = "再加工";
  6137. } else if ($value['state'] == 5) {
  6138. $info_list[$key]['state'] = "维修中";
  6139. } else if ($value['state'] == 6) {
  6140. $info_list[$key]['state'] = "盘亏";
  6141. } else if ($value['state'] == 7) {
  6142. $info_list[$key]['state'] = "更换标签";
  6143. } else if ($value['state'] == 8) {
  6144. $info_list[$key]['state'] = "其它";
  6145. } else if ($value['state'] == 9) {
  6146. $info_list[$key]['state'] = "预设";
  6147. } else if ($value['state'] == 10) {
  6148. $info_list[$key]['state'] = "美店零售";
  6149. }
  6150. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6151. }
  6152. $total = $this->$ck->find_count($where);
  6153. $pagenum = ceil($total / $perpage);
  6154. $over = $total - ($start + $perpage);
  6155. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6156. echo json_encode($rows);
  6157. exit;
  6158. }
  6159. if (isset($post['tmsku'])) {
  6160. $time = time();
  6161. $tmsku = $this->input->post('tmsku', true);
  6162. //$post['shop'] = $this->input->post('shop',true);
  6163. $num = $this->input->post('num', true);
  6164. $cktype = $this->input->post('cktype', true);
  6165. $label = $this->whlabellabel->get_label($tmsku);
  6166. if (!$cktype) {
  6167. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6168. }
  6169. if (!isset($label['warehouse'])) {
  6170. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6171. exit;
  6172. }
  6173. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6174. if (stripos($label['features'], '-126-') !== false) {
  6175. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6176. } else {
  6177. $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 = ''");
  6178. }
  6179. $j = 0;
  6180. if (count($ck) >= $num) {
  6181. for ($i = 0; $i < $num; $i++) {
  6182. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6183. {
  6184. $j++;
  6185. }
  6186. }
  6187. if ($j == $num) {
  6188. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6189. exit;
  6190. } else {
  6191. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6192. exit;
  6193. }
  6194. } else {
  6195. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6196. exit;
  6197. }
  6198. }
  6199. if(isset($_SESSION['api']))
  6200. {
  6201. $user = $this->user->get_api($_SESSION['api']);
  6202. if(in_array($user['power'],[1,27])){
  6203. $vip = 1;
  6204. }
  6205. }
  6206. else
  6207. {
  6208. $vip = 0;
  6209. header('Location: /');exit;
  6210. }
  6211. $this->data['vip'] = $vip;
  6212. $this->_Template('whlabel_printck', $this->data);
  6213. }
  6214. public function _printexcel()
  6215. {
  6216. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6217. $config['upload_path'] = '.' . $dir;
  6218. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6219. $config['allowed_types'] = 'xls|xlsx|csv';
  6220. $config['max_size'] = 10240;
  6221. $this->load->library('upload', $config);
  6222. $this->upload->initialize($config);
  6223. if ($this->upload->do_upload('userfile')) {
  6224. $full_path = $dir . $this->upload->data('file_name');
  6225. $fileName = '.' . $full_path;
  6226. if (!file_exists($fileName)) {
  6227. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6228. exit;
  6229. } else {
  6230. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6231. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6232. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6233. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6234. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6235. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6236. ++$column; //如果列数大于26行
  6237. $list = array();
  6238. for ($i = 2; $i <= $row; $i++) // 行数循环
  6239. {
  6240. $data = array();
  6241. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6242. {
  6243. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6244. }
  6245. $list[] = $data;
  6246. }
  6247. }
  6248. $ed = array();
  6249. $i = 0;
  6250. $j = 0;
  6251. $dcdata = array();
  6252. $yc = '';
  6253. $cmf_arr = array_column($list, '1');
  6254. array_multisort($cmf_arr, SORT_ASC, $list);
  6255. foreach ($list as $key => $value) {
  6256. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6257. if ($typeclass) {
  6258. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6259. } else {
  6260. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6261. $i++;
  6262. continue;
  6263. }
  6264. }
  6265. if ($i > 0) {
  6266. $yc = $i . '条异常';
  6267. }
  6268. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6269. exit;
  6270. }
  6271. }
  6272. public function _uck()
  6273. {
  6274. if (isset($_GET['excel'])) {
  6275. $tc = array();
  6276. $typeclass = $this->typeclass->find_all();
  6277. foreach ($typeclass as $v) {
  6278. $tc[$v['id']] = $v['zh'];
  6279. }
  6280. $data = array();
  6281. $t = array();
  6282. $rq = '';
  6283. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6284. $ts = $ts / (24 * 3600);
  6285. for ($i = 0; $i < $ts; $i++) {
  6286. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6287. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6288. }
  6289. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6290. foreach ($info_list as $k => $v) {
  6291. $features = explode('-', trim($v['features'], '-'));
  6292. if (!isset($features[3]) || !isset($features[4])) {
  6293. continue;
  6294. }
  6295. $data[$k][0] = $tc[$features[0]]; //类型
  6296. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6297. $data[$k][2] = $tc[$features[4]]; //曲度
  6298. $data[$k][3] = '';
  6299. if (isset($data[$k][1])) {
  6300. $data[$k][3] .= $data[$k][1];
  6301. }
  6302. if (isset($data[$k][2])) {
  6303. $data[$k][3] .= $data[$k][2];
  6304. }
  6305. if (isset($features[5])) {
  6306. $data[$k][3] .= $tc[$features[5]];
  6307. }
  6308. if (isset($features[2])) {
  6309. $data[$k][3] .= $tc[$features[2]];
  6310. }
  6311. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6312. $data[$k][4] = $v['sku'];
  6313. $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())) . '))'); //月初库存
  6314. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6315. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6316. $ztrq = '';
  6317. $ztsl = '';
  6318. if (count($zt) > 0) {
  6319. foreach ($zt as $vv) {
  6320. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6321. $ztsl .= $vv['num'] . '<br>';
  6322. }
  6323. }
  6324. $data[$k][] = trim($ztsl, '<br>');
  6325. $data[$k][] = trim($ztrq, '<br>');
  6326. $byck = 0;
  6327. foreach ($t as $vv) {
  6328. $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));
  6329. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6330. $byck += $sl;
  6331. }
  6332. $data[$k][] = ($byck > 0) ? $byck : '';
  6333. }
  6334. $title = "详情 " . date("Y-m-d", time());
  6335. $titlename = "<table border=1>
  6336. <tr align='center'>
  6337. <td>类别</td>
  6338. <td>颜色</td>
  6339. <td>曲度</td>
  6340. <td>名称</td>
  6341. <td>SKU</td>
  6342. <td>月初库存</td>
  6343. <td>剩余库存</td>
  6344. <td>在途数量</td>
  6345. <td>预达日期</td>" .
  6346. $rq
  6347. . "<td>本月出库</td></tr>
  6348. </table>";
  6349. $filename = $title . ".xls";
  6350. $tail = "";
  6351. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6352. }
  6353. }
  6354. public function _whlabelexcelzh()
  6355. {
  6356. if (isset($_GET['excel'])) {
  6357. $where = "sku != 'Preset'";
  6358. //数据排序
  6359. $order_str = "id desc";
  6360. if (empty($page)) {
  6361. $start = 0;
  6362. $perpage = 1;
  6363. } else {
  6364. $start = ($page - 1) * $perpage;
  6365. }
  6366. $category = $this->input->get('category', true);
  6367. $warehouse = $this->input->get('warehouse', true);
  6368. $excelid = $this->input->get('sid', true);
  6369. if ($category) {
  6370. $where .= " and features like '%-$category-%'";
  6371. }
  6372. if ($warehouse) {
  6373. $where .= " and warehouse = '$warehouse'";
  6374. }
  6375. $xzid = '';
  6376. if ($excelid) {
  6377. $excelid = explode(',', trim($excelid, ','));
  6378. foreach ($excelid as $key => $value) {
  6379. $xzid .= " id = " . $value . " or";
  6380. }
  6381. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6382. }
  6383. //取得信息列表
  6384. /**
  6385. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6386. $rows = array();$list = array();
  6387. foreach ($info_list as $key=>$value)
  6388. {
  6389. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6390. }
  6391. **/
  6392. $list = array();
  6393. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6394. foreach ($rows as $key => $value) {
  6395. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6396. $zh = '';
  6397. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6398. foreach ($zt as $v) {
  6399. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6400. }
  6401. $zt = array_sum(array_column($zt, 'num'));
  6402. $number = $value['number'];
  6403. $ftime = time() - 15 * 24 * 3600;
  6404. $warehouse = $this->warehouse->read($value['warehouse']);
  6405. $rows[$key]['warehouse'] = $warehouse['title'];
  6406. $rows[$key]['number'] = $c;
  6407. $rows[$key]['features'] = $zh;
  6408. $rows[$key]['hb'] = $c + $zt;
  6409. }
  6410. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6411. $titlename = "<table border=1>
  6412. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6413. <tr align='center'>
  6414. <td>仓库</td>
  6415. <td>SKU</td>
  6416. <td>产品</td>
  6417. <td>库存数量</td>
  6418. <td>在途数量及预达日期</td>
  6419. <td>在途+库存数量</td>
  6420. </tr>
  6421. </table>";
  6422. $filename = $title . ".xls";
  6423. $tail = "";
  6424. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6425. }
  6426. if (isset($_GET['excel'])) {
  6427. $warehouse = $this->input->get('warehouse', true);
  6428. $sku = $this->input->get('sku', true);
  6429. $cz = $this->input->get('cz', true);
  6430. $text = $this->input->post('text', true);
  6431. $xztime = $this->input->get('xztime', true);
  6432. $timetk = $this->input->get('timetk', true);
  6433. $timetj = $this->input->get('timetj', true);
  6434. $timetk = strtotime($timetk);
  6435. $timetj = strtotime($timetj);
  6436. $where = "time = '0' ";
  6437. if ($warehouse) {
  6438. $where .= " and warehouse = '$warehouse'";
  6439. }
  6440. if ($sku) {
  6441. $where .= " and sku = '$sku'";
  6442. }
  6443. if ($text) {
  6444. $where .= " and text like '%$text%'";
  6445. }
  6446. if ($cz != '') {
  6447. $where .= " and cz = '$cz'";
  6448. }
  6449. if ($timetk && $timetj) {
  6450. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6451. }
  6452. //数据排序
  6453. $order_str = $xztime . " desc";
  6454. //取得信息列表
  6455. $zh = array();
  6456. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6457. foreach ($info_list as $v) {
  6458. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6459. $warehouse = $this->warehouse->read($v['warehouse']);
  6460. $v['warehouse'] = $warehouse['title'];
  6461. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6462. $v['stime'] = date('Y-m-d', $v['stime']);
  6463. if (isset($zh[$v['features']])) {
  6464. $zh[$v['features']]['num'] += $v['num'];
  6465. } else {
  6466. $zh[$v['features']] = $v;
  6467. }
  6468. $zh[$v['features']]['features'] = $c;
  6469. }
  6470. $title = "在途数据" . date('Y-m-d', time());
  6471. $titlename = "<table border=1>
  6472. <tr align='center'>
  6473. <td>仓库</td>
  6474. <td>SKU</td>
  6475. <td>名称</td>
  6476. <td>在途数量</td>
  6477. <td>库存数量</td>
  6478. <td>添加在途日期</td>
  6479. <td>预达日期</td>
  6480. <td>备注</td>
  6481. </tr>
  6482. </table>";
  6483. $filename = $title . ".xls";
  6484. $tail = "";
  6485. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6486. }
  6487. }
  6488. public function _fc()
  6489. {
  6490. $vip = 0;
  6491. if (isset($_SESSION['api'])) {
  6492. $user = $this->user->get_api($_SESSION['api']);
  6493. if ($user['vip'] == 1) {
  6494. $vip = 1;
  6495. }
  6496. } else {
  6497. header('Location: /');
  6498. exit;
  6499. }
  6500. $post = $this->input->post(NULL, TRUE);
  6501. if (isset($post['page'])) {
  6502. $page = $this->input->post('page', true);
  6503. $perpage = $this->input->post('perpage', true);
  6504. $category = $this->input->post('category', true);
  6505. $size = $this->input->post('size', true);
  6506. $grade = $this->input->post('grade', true);
  6507. $color = $this->input->post('color', true);
  6508. $lowe = $this->input->post('lowe', true);
  6509. $sku = $this->input->post('sku');
  6510. $title = $this->input->post('title');
  6511. $warehouse = $this->input->post('warehouse', true);
  6512. $usa = $this->input->post('usa', true);
  6513. $purchase = $this->input->post('purchase', true);
  6514. $lacetype = $this->input->post('lacetype', true);
  6515. $haircap = $this->input->post('haircap', true);
  6516. $density = $this->input->post('density', true);
  6517. $details = $this->input->post('details', true);
  6518. $state = $this->input->post('state', true);
  6519. $ktime = $this->input->post('ktime', true);
  6520. $jtime = $this->input->post('jtime', true);
  6521. $ktime = strtotime($ktime);
  6522. $jtime = strtotime($jtime);
  6523. $where = "state = '11'";
  6524. $gj = "";
  6525. $ck = "";
  6526. if ($lacetype) {
  6527. $where .= " and features like '%-$lacetype-%'";
  6528. }
  6529. if ($category) {
  6530. $where .= " and features like '%-$category-%'";
  6531. }
  6532. if ($size) {
  6533. $where .= " and features like '%-$size-%'";
  6534. }
  6535. if ($grade) {
  6536. $where .= " and features like '%-$grade-%'";
  6537. }
  6538. if ($color) {
  6539. $where .= " and features like '%-$color-%'";
  6540. }
  6541. if ($lowe) {
  6542. $where .= " and features like '%-$lowe-%'";
  6543. }
  6544. if ($haircap) {
  6545. $where .= " and features like '%-$haircap-%'";
  6546. }
  6547. if ($density) {
  6548. $where .= " and features like '%-$density-%'";
  6549. }
  6550. if ($usa) {
  6551. if (!$warehouse) {
  6552. $where .= " and (warehouse = '5' or warehouse = '8')";
  6553. }
  6554. }
  6555. if ($warehouse) {
  6556. $where .= " and warehouse = '$warehouse'";
  6557. }
  6558. if ($details) {
  6559. $where .= " and details = '$details'";
  6560. }
  6561. if ($purchase) {
  6562. $where .= " and purchase = '$purchase'";
  6563. }
  6564. if ($state) {
  6565. $where .= " and state = '$state'";
  6566. }
  6567. if ($ktime && $jtime) {
  6568. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6569. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6570. }
  6571. //数据排序
  6572. $order_str = "id desc";
  6573. if (empty($page)) {
  6574. $start = 0;
  6575. $perpage = 1;
  6576. } else {
  6577. $start = ($page - 1) * $perpage;
  6578. }
  6579. if ($sku) {
  6580. $sku = trim($sku, ' ');
  6581. $sku = trim($sku, ' ');
  6582. $where .= " and sku like '%$sku%'";
  6583. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6584. } else if ($title) {
  6585. $title = trim($title, ' ');
  6586. $title = trim($title, ' ');
  6587. $where .= " and title like '%$title%'";
  6588. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6589. } else {
  6590. //$where .= " and time > '$ktime' and time < '$jtime'";
  6591. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6592. }
  6593. //取得信息列表
  6594. $rows = array();
  6595. $list = array();
  6596. foreach ($info_list as $key => $value) {
  6597. $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'] . '"');
  6598. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6599. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6600. $warehouse = $this->warehouse->read($value['warehouse']);
  6601. $info_list[$key]['warehouse'] = $warehouse['title'];
  6602. $info_list[$key]['number'] = $g;
  6603. $info_list[$key]['features'] = $x;
  6604. $info_list[$key]['x'] = $s;
  6605. }
  6606. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6607. $pagenum = ceil($total / $perpage);
  6608. $over = $total - ($start + $perpage);
  6609. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6610. echo json_encode($rows);
  6611. exit;
  6612. }
  6613. $this->data['vip'] = $vip;
  6614. $this->_Template('whlabel_fc', $this->data);
  6615. }
  6616. public function _fcmb()
  6617. {
  6618. $where = "sku != 'Preset'";
  6619. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6620. foreach ($rows as $k => $v) {
  6621. $warehouse = $this->warehouse->read($v['warehouse']);
  6622. $rows[$k]['warehouse'] = $warehouse['title'];
  6623. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6624. $rows[$k]['t'] = '';
  6625. $rows[$k]['n'] = '';
  6626. }
  6627. $title = "封货产品数据导入模板";
  6628. $titlename = "<table border=1>
  6629. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6630. <tr align='center'>
  6631. <td>仓库</td>
  6632. <td>SKU</td>
  6633. <td>产品</td>
  6634. <td>封存产品总数量</td>
  6635. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6636. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6637. </tr>
  6638. </table>";
  6639. $filename = $title . ".xls";
  6640. $tail = "";
  6641. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6642. }
  6643. public function _fcexcel()
  6644. {
  6645. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6646. $config['upload_path'] = '.' . $dir;
  6647. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6648. $config['allowed_types'] = 'xls|xlsx|csv';
  6649. $config['max_size'] = 10240;
  6650. $this->load->library('upload', $config);
  6651. $this->upload->initialize($config);
  6652. if ($this->upload->do_upload('userfile')) {
  6653. $full_path = $dir . $this->upload->data('file_name');
  6654. $fileName = '.' . $full_path;
  6655. if (!file_exists($fileName)) {
  6656. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6657. exit;
  6658. } else {
  6659. libxml_use_internal_errors(true);
  6660. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6661. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6662. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6663. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6664. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6665. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6666. ++$column; //如果列数大于26行
  6667. $list = array();
  6668. for ($i = 2; $i <= $row; $i++) // 行数循环
  6669. {
  6670. $data = array();
  6671. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6672. {
  6673. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6674. }
  6675. $list[] = $data;
  6676. }
  6677. }
  6678. $i = 0;
  6679. $j = 0;
  6680. $ed = array();
  6681. foreach ($list as $key => $value) {
  6682. $time = time();
  6683. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6684. continue;
  6685. }
  6686. $warehouse = $this->warehouse->get_title($value['0']);
  6687. $sku = $value['1'];
  6688. $type = $value['4']; //调整方式0扣减1删除
  6689. $num = $value['5']; //调整数量
  6690. //$text = $value['4'];//扣减说明
  6691. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6692. if (!$d) //如果没有这个SKU
  6693. {
  6694. $ed[] = array($sku . '-库存中不存在此SKU');
  6695. $j++;
  6696. continue;
  6697. }
  6698. if (!isset($warehouse['id'])) {
  6699. $ed[] = array($sku . '-仓库名错误!');
  6700. $j++;
  6701. continue;
  6702. }
  6703. if ($type == 1 || $type == 2) //扣减库存
  6704. {
  6705. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6706. if (count($data) < abs($num)) {
  6707. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6708. $j++;
  6709. continue;
  6710. }
  6711. if ($type == 1) //转入库存
  6712. {
  6713. for ($i = 0; $i < abs($num); $i++) {
  6714. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6715. }
  6716. } else if ($type == 2) //删除
  6717. {
  6718. for ($i = 0; $i < abs($num); $i++) {
  6719. $this->whlabel->remove($data[$i]['id']);
  6720. }
  6721. }
  6722. } else if ($type == 0) //增加库存
  6723. {
  6724. $post['sku'] = $d['sku'];
  6725. $post['shop'] = '';
  6726. $post['warehouse'] = $warehouse['id'];
  6727. $post['purchase'] = $d['purchase'];
  6728. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6729. $post['state'] = 11;
  6730. $post['title'] = $d['title'];
  6731. $post['number'] = $d['number'];
  6732. $post['features'] = $d['features'];
  6733. $post['enter'] = $time;
  6734. $post['time'] = $time; //操作时间
  6735. for ($i = 0; $i < $num; $i++) {
  6736. $post['label'] = time() . rand(100, 999) . $i;
  6737. $this->whlabel->insert($post);
  6738. }
  6739. }
  6740. sleep(1); //防止入库时间一样,需要延迟1秒
  6741. }
  6742. if ($j > 0) {
  6743. $tt = date('Ymd', time());
  6744. $title = '库存导入错误信息-' . $tt;
  6745. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6746. $tail = "\n";
  6747. $filename = $title . ".xls";
  6748. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6749. $dir = '/data/excel/' . $time . '/';
  6750. $file_name = 'error_' . $time . rand(1000, 9999);
  6751. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6752. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6753. fwrite($myfile, $ecl);
  6754. fclose($myfile);
  6755. $error = $dir . $file_name . '.xls';
  6756. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6757. exit;
  6758. } else {
  6759. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6760. exit;
  6761. }
  6762. }
  6763. }
  6764. public function _fcjxc($arg_array)
  6765. {
  6766. if (isset($_GET['excel'])) {
  6767. $category = $this->input->get('category', true);
  6768. $size = $this->input->get('size', true);
  6769. $grade = $this->input->get('grade', true);
  6770. $color = $this->input->get('color', true);
  6771. $lowe = $this->input->get('lowe', true);
  6772. $sku = $this->input->get('sku');
  6773. $title = $this->input->get('title');
  6774. $warehouse = $arg_array[0];
  6775. $usa = $this->input->get('usa', true);
  6776. $purchase = $this->input->get('purchase', true);
  6777. $lacetype = $this->input->get('lacetype', true);
  6778. $haircap = $this->input->get('haircap', true);
  6779. $density = $this->input->get('density', true);
  6780. $title = $this->input->get('title', true);
  6781. $state = $this->input->get('state', true);
  6782. $ktime = $this->input->get('ktime', true);
  6783. $jtime = $this->input->get('jtime', true);
  6784. $where = "state=11";
  6785. $gj = "";
  6786. $ck = "";
  6787. if ($lacetype) {
  6788. $where .= " and features like '%-$lacetype-%'";
  6789. }
  6790. if ($category) {
  6791. $where .= " and features like '%-$category-%'";
  6792. }
  6793. if ($size) {
  6794. $where .= " and features like '%-$size-%'";
  6795. }
  6796. if ($grade) {
  6797. $where .= " and features like '%-$grade-%'";
  6798. }
  6799. if ($color) {
  6800. $where .= " and features like '%-$color-%'";
  6801. }
  6802. if ($lowe) {
  6803. $where .= " and features like '%-$lowe-%'";
  6804. }
  6805. if ($haircap) {
  6806. $where .= " and features like '%-$haircap-%'";
  6807. }
  6808. if ($density) {
  6809. $where .= " and features like '%-$density-%'";
  6810. }
  6811. if ($usa) {
  6812. if (!$warehouse) {
  6813. $where .= " and (warehouse = '5' or warehouse = '8')";
  6814. }
  6815. }
  6816. if ($warehouse) {
  6817. $where .= " and warehouse = '$warehouse'";
  6818. }
  6819. if ($purchase) {
  6820. $where .= " and purchase = '$purchase'";
  6821. }
  6822. if ($state) {
  6823. $where .= " and state = '$state'";
  6824. }
  6825. $order_str = "id desc";
  6826. if ($sku) {
  6827. $sku = trim($sku, ' ');
  6828. $sku = trim($sku, ' ');
  6829. $where .= " and sku like '%$sku%'";
  6830. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6831. } else if ($title) {
  6832. $title = trim($title, ' ');
  6833. $title = trim($title, ' ');
  6834. $where .= " and title like '%$title%'";
  6835. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6836. } else {
  6837. //$where .= " and time > '$ktime' and time < '$jtime'";
  6838. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6839. }
  6840. //取得信息列表
  6841. $rows = array();
  6842. $list = array();
  6843. foreach ($info_list as $key => $value) {
  6844. $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'] . '"');
  6845. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6846. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6847. $rows[$key] = $value;
  6848. $warehouse = $this->warehouse->read($value['warehouse']);
  6849. $rows[$key]['warehouse'] = $warehouse['title'];
  6850. $rows[$key]['features'] = $g;
  6851. $rows[$key]['a'] = $x;
  6852. $rows[$key]['b'] = $s;
  6853. }
  6854. $title = "总统计表";
  6855. $titlename = "<table border=1>
  6856. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6857. <tr align='center'>
  6858. <td>仓库</td>
  6859. <td>SKU</td>
  6860. <td>产品名称</td>
  6861. <td>录入总量</td>
  6862. <td>取出总量</td>
  6863. <td>剩余总量</td>
  6864. </tr>
  6865. </table>";
  6866. $filename = $title . ".xls";
  6867. $tail = "";
  6868. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6869. }
  6870. $vip = 0;
  6871. if (isset($_SESSION['api'])) {
  6872. $user = $this->user->get_api($_SESSION['api']);
  6873. if ($user['vip'] == 1) {
  6874. $vip = 1;
  6875. }
  6876. } else {
  6877. header('Location: /');
  6878. exit;
  6879. }
  6880. $post = $this->input->post(NULL, TRUE);
  6881. if (isset($post['page'])) {
  6882. $page = $this->input->post('page', true);
  6883. $perpage = $this->input->post('perpage', true);
  6884. $category = $this->input->post('category', true);
  6885. $size = $this->input->post('size', true);
  6886. $grade = $this->input->post('grade', true);
  6887. $color = $this->input->post('color', true);
  6888. $lowe = $this->input->post('lowe', true);
  6889. $sku = $this->input->post('sku');
  6890. $title = $this->input->post('title');
  6891. $warehouse = $arg_array[0];
  6892. $usa = $this->input->post('usa', true);
  6893. $purchase = $this->input->post('purchase', true);
  6894. $lacetype = $this->input->post('lacetype', true);
  6895. $haircap = $this->input->post('haircap', true);
  6896. $density = $this->input->post('density', true);
  6897. $title = $this->input->post('title', true);
  6898. $state = $this->input->post('state', true);
  6899. $ktime = $this->input->post('ktime', true);
  6900. $jtime = $this->input->post('jtime', true);
  6901. $ktime = strtotime($ktime);
  6902. $jtime = strtotime($jtime);
  6903. $where = "state=11";
  6904. $gj = "";
  6905. $ck = "";
  6906. if ($lacetype) {
  6907. $where .= " and features like '%-$lacetype-%'";
  6908. }
  6909. if ($category) {
  6910. $where .= " and features like '%-$category-%'";
  6911. }
  6912. if ($size) {
  6913. $where .= " and features like '%-$size-%'";
  6914. }
  6915. if ($grade) {
  6916. $where .= " and features like '%-$grade-%'";
  6917. }
  6918. if ($color) {
  6919. $where .= " and features like '%-$color-%'";
  6920. }
  6921. if ($lowe) {
  6922. $where .= " and features like '%-$lowe-%'";
  6923. }
  6924. if ($haircap) {
  6925. $where .= " and features like '%-$haircap-%'";
  6926. }
  6927. if ($density) {
  6928. $where .= " and features like '%-$density-%'";
  6929. }
  6930. if ($usa) {
  6931. if (!$warehouse) {
  6932. $where .= " and (warehouse = '5' or warehouse = '8')";
  6933. }
  6934. }
  6935. if ($warehouse) {
  6936. $where .= " and warehouse = '$warehouse'";
  6937. }
  6938. if ($purchase) {
  6939. $where .= " and purchase = '$purchase'";
  6940. }
  6941. if ($state) {
  6942. $where .= " and state = '$state'";
  6943. }
  6944. if ($ktime && $jtime) {
  6945. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6946. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6947. }
  6948. //数据排序
  6949. $order_str = "id desc";
  6950. $xs = 0;
  6951. $rows = array();
  6952. $list = array();
  6953. if (empty($page)) {
  6954. $start = 0;
  6955. $perpage = 1;
  6956. } else {
  6957. $start = ($page - 1) * $perpage;
  6958. }
  6959. if ($sku || $title) {
  6960. if ($title) {
  6961. $title = trim($title, ' ');
  6962. $title = trim($title, ' ');
  6963. $where .= " and title like '%$title%'";
  6964. } else {
  6965. $sku = trim($sku, ' ');
  6966. $sku = trim($sku, ' ');
  6967. $where .= " and sku like '%$sku%'";
  6968. }
  6969. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6970. foreach ($info_list as $key => $value) {
  6971. $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'] . '"');
  6972. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6973. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6974. $rows[$key] = $value;
  6975. $warehouse = $this->warehouse->read($value['warehouse']);
  6976. $rows[$key]['warehouse'] = $warehouse['title'];
  6977. $rows[$key]['features'] = $g;
  6978. $rows[$key]['a'] = $x;
  6979. $rows[$key]['b'] = $s;
  6980. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6981. $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天销量
  6982. $yj = $c / ($xl / 30);
  6983. if ($yj < 7) {
  6984. $rows[$key]['y'] = round($yj) . '天销量';
  6985. } else {
  6986. $rows[$key]['y'] = '正常';
  6987. }
  6988. }
  6989. } else {
  6990. //$where .= " and time > '$ktime' and time < '$jtime'";
  6991. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6992. foreach ($info_list as $key => $value) {
  6993. $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'] . '"');
  6994. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6995. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6996. $zs[$key] = $value;
  6997. $warehouse = $this->warehouse->read($value['warehouse']);
  6998. $zs[$key]['warehouse'] = $warehouse['title'];
  6999. $zs[$key]['features'] = $g;
  7000. $zs[$key]['a'] = $x;
  7001. $zs[$key]['b'] = $s;
  7002. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7003. $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天销量
  7004. $yj = $c / ($xl / 30);
  7005. if ($yj < 7) {
  7006. $zs[$key]['y'] = round($yj) . '天销量';
  7007. $rows[$key] = $zs[$key];
  7008. }
  7009. }
  7010. }
  7011. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7012. $pagenum = ceil($total / $perpage);
  7013. $over = $total - ($start + $perpage);
  7014. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7015. echo json_encode($rows);
  7016. exit;
  7017. }
  7018. $this->data['arg_array'] = $arg_array[0];
  7019. $this->_Template('whlabel_fcjxc', $this->data);
  7020. }
  7021. public function _0kcdel()
  7022. {
  7023. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7024. $config['upload_path'] = '.' . $dir;
  7025. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7026. $config['allowed_types'] = 'xls|xlsx|csv';
  7027. $config['max_size'] = 10240;
  7028. $this->load->library('upload', $config);
  7029. $this->upload->initialize($config);
  7030. if ($this->upload->do_upload('userfile')) {
  7031. $full_path = $dir . $this->upload->data('file_name');
  7032. $fileName = '.' . $full_path;
  7033. if (!file_exists($fileName)) {
  7034. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7035. exit;
  7036. } else {
  7037. require_once "./data/excel/PHPExcel/IOFactory.php";
  7038. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7039. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7040. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7041. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7042. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7043. ++$column; //如果列数大于26行
  7044. $list = array();
  7045. for ($i = 2; $i <= $row; $i++) // 行数循环
  7046. {
  7047. $data = array();
  7048. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7049. {
  7050. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7051. }
  7052. $list[] = $data;
  7053. }
  7054. }
  7055. $i = 0;
  7056. $j = 0;
  7057. $ed = array();
  7058. foreach ($list as $key => $value) {
  7059. $time = time();
  7060. if ($value['0'] == "" || $value['1'] == "") {
  7061. continue;
  7062. }
  7063. $warehouse = $this->warehouse->get_title($value['0']);
  7064. $sku = $value['1'];
  7065. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7066. if (!$d) //如果没有这个SKU
  7067. {
  7068. $ed[] = array($sku . '-库存中不存在此SKU');
  7069. $j++;
  7070. continue;
  7071. }
  7072. if (!isset($warehouse['id'])) {
  7073. $ed[] = array($sku . '-仓库名错误!');
  7074. $j++;
  7075. continue;
  7076. }
  7077. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7078. if ($z < 1) {
  7079. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7080. foreach ($z as $v) {
  7081. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7082. if (count($zt) > 0) {
  7083. $ed[] = array($sku . '-有在途库存无法删除!');
  7084. $j++;
  7085. continue;
  7086. }
  7087. $this->whlabel->remove($v['id']);
  7088. }
  7089. } else {
  7090. $ed[] = array($sku . '-非0库存!');
  7091. $j++;
  7092. continue;
  7093. }
  7094. }
  7095. if ($j > 0) {
  7096. $tt = date('Ymd', time());
  7097. $title = '删除0库存错误信息-' . $tt;
  7098. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7099. $tail = "\n";
  7100. $filename = $title . ".xls";
  7101. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7102. $dir = '/data/excel/' . $time . '/';
  7103. $file_name = 'error_' . $time . rand(1000, 9999);
  7104. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7105. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7106. fwrite($myfile, $ecl);
  7107. fclose($myfile);
  7108. $error = $dir . $file_name . '.xls';
  7109. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7110. exit;
  7111. } else {
  7112. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7113. exit;
  7114. }
  7115. }
  7116. }
  7117. public function _gbhtype()
  7118. {
  7119. $post = $this->input->post(NULL, TRUE);
  7120. if (isset($post['s'])) {
  7121. $n = $this->input->post('n');
  7122. $d = $this->input->post('s');
  7123. if (!$d) {
  7124. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7125. exit;
  7126. }
  7127. $d = explode(',', trim($d, ','));
  7128. $t = $this->whlabel_type->read($n);
  7129. //循环删除记录
  7130. foreach ($d as $v) {
  7131. $u = $this->whlabel->read($v);
  7132. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7133. foreach ($data as $val) {
  7134. $this->whlabel->save(array('type' => $n), $val['id']);
  7135. }
  7136. }
  7137. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7138. }
  7139. }
  7140. //出库、退库导出
  7141. public function _dccrtype()
  7142. {
  7143. $classid = $this->classid->sku();
  7144. $pm = $classid;
  7145. $typeclass = array();
  7146. $tc = $this->typeclass->find_all();
  7147. foreach ($tc as $v) {
  7148. $typeclass[$v['id']] = $v;
  7149. }
  7150. $prc = array();
  7151. $purchase = $this->purchase->find_all();
  7152. foreach ($purchase as $k => $v) {
  7153. $prc[$v['id']] = $v['title'];
  7154. }
  7155. if (isset($_GET['sid'])) {
  7156. $wh = array();
  7157. $w = $this->warehouse->find_all('1=1', 'id,title');
  7158. foreach ($w as $v) {
  7159. $wh[$v['id']] = $v['title'];
  7160. }
  7161. $type = $this->input->get('excel', true);
  7162. $category = $this->input->get('category', true);
  7163. $size = $this->input->get('size', true);
  7164. $grade = $this->input->get('grade', true);
  7165. $color = $this->input->get('color', true);
  7166. $lowe = $this->input->get('lowe', true);
  7167. $sku = $this->input->get('sku', true);
  7168. $warehouse = $this->input->get('warehouse', true);
  7169. $lacetype = $this->input->get('lacetype', true);
  7170. $lacecolor = $this->input->get('lacecolor', true);
  7171. $density = $this->input->get('density', true);
  7172. $haircap = $this->input->get('haircap', true);
  7173. $purchase = $this->input->get('purchase', true);
  7174. $title = $this->input->get('title', true);
  7175. $state = $this->input->get('state', true);
  7176. $sid = $this->input->get('sid', true);
  7177. $ktime = $this->input->get('ktime', true);
  7178. $jtime = $this->input->get('jtime', true);
  7179. $ktime = strtotime($ktime);
  7180. $jtime = strtotime($jtime);
  7181. $where = "1=1";
  7182. $gj = "";
  7183. $ck = "";
  7184. if ($category) {
  7185. $where .= " and features like '%-$category-%'";
  7186. }
  7187. if ($size) {
  7188. $where .= " and features like '%-$size-%'";
  7189. }
  7190. if ($grade) {
  7191. $where .= " and features like '%-$grade-%'";
  7192. }
  7193. if ($color) {
  7194. $where .= " and features like '%-$color-%'";
  7195. }
  7196. if ($lowe) {
  7197. $where .= " and features like '%-$lowe-%'";
  7198. }
  7199. if ($warehouse) {
  7200. $where .= " and warehouse = '$warehouse'";
  7201. }
  7202. if ($purchase) {
  7203. $where .= " and purchase = '$purchase'";
  7204. }
  7205. if ($state) {
  7206. $where .= " and state = '$state'";
  7207. }
  7208. if ($lacetype) {
  7209. $where .= " and features like '%-$lacetype-%'";
  7210. }
  7211. if ($lacecolor) {
  7212. $where .= " and features like '%-$lacecolor-%'";
  7213. }
  7214. if ($density) {
  7215. $where .= " and features like '%-$density-%'";
  7216. }
  7217. if ($haircap) {
  7218. $where .= " and features like '%-$haircap-%'";
  7219. }
  7220. if ($title) {
  7221. $title = trim($title, ' ');
  7222. $title = trim($title, ' ');
  7223. $where .= " and title like '%$title%'";
  7224. }
  7225. if ($sku) {
  7226. $sku = trim($sku, ' ');
  7227. $sku = trim($sku, ' ');
  7228. $where .= " and sku like '%$sku%'";
  7229. }
  7230. if ($ktime && $jtime) {
  7231. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7232. }
  7233. $sidwhere = '';
  7234. if ($sid) {
  7235. $sd = "";
  7236. $s = explode(',', trim($sid, ','));
  7237. foreach ($s as $value) {
  7238. $sd .= " id = " . $value . " or";
  7239. }
  7240. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7241. }
  7242. //数据排序
  7243. $order_str = "time desc";
  7244. if (empty($page)) {
  7245. $start = 0;
  7246. $perpage = 1;
  7247. } else {
  7248. $start = ($page - 1) * $perpage;
  7249. }
  7250. $wh = array();
  7251. $w = $this->warehouse->find_all('1=1', 'id,title');
  7252. foreach ($w as $v) {
  7253. $wh[$v['id']] = $v['title'];
  7254. }
  7255. $wt = array();
  7256. $whlabel_type = $this->whlabel_type->find_all();
  7257. foreach ($whlabel_type as $v) {
  7258. $wt[$v['id']] = $v['title'];
  7259. }
  7260. $classid = $this->classid->sku();
  7261. $list = array();
  7262. $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');
  7263. foreach ($rows_r as $key => $value) {
  7264. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7265. $pm = $classid;
  7266. $jm = $classid;
  7267. $rows_r[$key]['enter'] = '入库';
  7268. $rows_r[$key]['time'] = $value['enter'];
  7269. if ($value['rktype'] == 1) {
  7270. $rows_r[$key]['rktype'] = '采购入库';
  7271. } else if ($value['rktype'] == 2) {
  7272. $rows_r[$key]['rktype'] = '盘盈调整';
  7273. } else if ($value['rktype'] == 3) {
  7274. $rows_r[$key]['rktype'] = '其他调整入库';
  7275. } else if ($value['rktype'] == 4) {
  7276. $rows_r[$key]['rktype'] = '其他调整入库';
  7277. } else if ($value['rktype'] == 5) {
  7278. $rows_r[$key]['rktype'] = '退库入库';
  7279. } else if ($value['rktype'] == 6) {
  7280. $rows_r[$key]['rktype'] = '退货可用入库';
  7281. } else if ($value['rktype'] == 7) {
  7282. $rows_r[$key]['rktype'] = '形态转换入库';
  7283. } else {
  7284. $rows_r[$key]['rktype'] = '';
  7285. }
  7286. $features = explode('-', trim($value['features'], '-'));
  7287. foreach ($features as $v) {
  7288. if (isset($typeclass[$v])) {
  7289. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7290. $pm[$typeclass[$v]['classid']] = $zh[0];
  7291. }
  7292. if (isset($typeclass[$v])) {
  7293. if (isset($jm[$typeclass[$v]['classid']])) {
  7294. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7295. }
  7296. }
  7297. }
  7298. $zh = implode(" ", $pm);
  7299. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7300. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7301. $rows_r[$key]['zh'] = $zh;
  7302. $jm = array_filter($jm);
  7303. $rows_r[$key]['features'] = implode("-", $jm);
  7304. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7305. }
  7306. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout');
  7307. foreach ($rows_c as $key => $value) {
  7308. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7309. $pm = $classid;
  7310. $jm = $classid;
  7311. $rows_c[$key]['time'] = $value['outk'];
  7312. $rows_c[$key]['outk'] = '出库';
  7313. if ($value['cktype'] == 1) {
  7314. $rows_c[$key]['cktype'] = '销售出库';
  7315. } else if ($value['cktype'] == 2) {
  7316. $rows_c[$key]['cktype'] = '销售美国出库';
  7317. } else if ($value['cktype'] == 3) {
  7318. $rows_c[$key]['cktype'] = '盘亏调整';
  7319. } else if ($value['cktype'] == 4) {
  7320. $rows_c[$key]['cktype'] = '其他调整出库';
  7321. } else if ($value['cktype'] == 5) {
  7322. $rows_c[$key]['cktype'] = '形态转换出库';
  7323. } else {
  7324. $rows_c[$key]['cktype'] = '';
  7325. }
  7326. $features = explode('-', trim($value['features'], '-'));
  7327. foreach ($features as $v) {
  7328. if (isset($typeclass[$v])) {
  7329. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7330. $pm[$typeclass[$v]['classid']] = $zh[0];
  7331. }
  7332. if (isset($typeclass[$v])) {
  7333. if (isset($jm[$typeclass[$v]['classid']])) {
  7334. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7335. }
  7336. }
  7337. }
  7338. $zh = implode(" ", $pm);
  7339. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7340. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7341. $rows_c[$key]['zh'] = $zh;
  7342. $jm = array_filter($jm);
  7343. $rows_c[$key]['features'] = implode("-", $jm);
  7344. $rows_c[$key]['number'] = 1;
  7345. }
  7346. $merged = $rows_r;
  7347. foreach ($rows_c as $key => $value) {
  7348. if (isset($merged[$key])) {
  7349. $merged[] = $value;
  7350. } else {
  7351. $merged[$key] = $value;
  7352. }
  7353. }
  7354. usort($merged, function ($a, $b) {
  7355. return $a['time'] - $b['time'];
  7356. });
  7357. foreach ($merged as $key => $value) {
  7358. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7359. }
  7360. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7361. $titlename = "<table border=1>
  7362. <tr align='center'>
  7363. <td>仓库</td>
  7364. <td>SKU</td>
  7365. <td>商品名称</td>
  7366. <td>仓库品名</td>
  7367. <td>料号</td>
  7368. <td>时间</td>
  7369. <td>操作</td>
  7370. <td>类型</td>
  7371. <td>数量</td>
  7372. <td>备注</td>
  7373. </tr>
  7374. </table>";
  7375. $filename = $title . ".xlsx";
  7376. $tail = "";
  7377. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7378. }
  7379. }
  7380. }