Whlabel.php 258 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->load->library('session');
  8. $this->load->_model('Model_whlabel', 'whlabel');
  9. $this->load->_model('Model_warehouse', 'warehouse');
  10. $this->load->_model('Model_purchase', 'purchase');
  11. $this->load->_model('Model_excel', 'excel');
  12. $this->load->_model('Model_fullorder', 'fullorder');
  13. $this->load->_model('Model_fullordertt', 'fullordertt');
  14. $this->load->_model('Model_fullorderamz', 'fullorderamz');
  15. $this->load->_model('Model_fullorder_smt', 'fullorder_smt');
  16. $this->load->_model('Model_fullordersmt', 'fullordersmt');
  17. $this->load->_model('Model_express', 'express');
  18. $this->load->_model('Model_shop', 'shop');
  19. $this->load->_model('Model_typeclass', 'typeclass');
  20. $this->load->_model('Model_country', 'country');
  21. $this->load->_model('Model_warehouse', 'warehouse');
  22. $this->load->_model('Model_kdniao', 'kdniao');
  23. $this->load->_model('Model_notice', 'notice');
  24. $this->load->_model('Model_dhl', 'dhl');
  25. $this->load->_model('Model_shop', 'shop');
  26. $this->load->_model('Model_fullorderexcel', 'fullorderexcel');
  27. $this->load->_model('Model_ljg', 'ljg');
  28. $this->load->_model('Model_usps', 'usps');
  29. $this->load->_model('Model_specialstock', 'specialstock');
  30. $this->load->_model('Model_whlabellabel', 'whlabellabel');
  31. $this->load->_model('Model_whlabelwz', 'whlabelwz');
  32. $this->load->_model('Model_whlabelbarcode', 'whlabelbarcode');
  33. $this->load->_model('Model_whlabeltransport', 'whlabeltransport');
  34. $this->load->_model('Model_orderurl', 'orderurl');
  35. $this->load->_model('Model_brand', 'brand');
  36. $this->load->_model('Model_classid', 'classid');
  37. $this->load->_model('Model_apiyy', 'apiyy');
  38. $this->load->_model('Model_power', 'power');
  39. $this->load->_model('Model_whlabel_type', 'whlabel_type');
  40. $this->load->_model('Model_company', 'company');
  41. $this->load->_model('Model_whlabel_list', 'whlabel_list');
  42. $this->load->_model("Model_logic_whlabel", "logic_whlabel");
  43. $this->load->_model("Model_logic_order","logic_order");
  44. }
  45. //定义方法的调用规则 获取URI第二段值
  46. public function _remap($arg, $arg_array)
  47. {
  48. if ($arg == 'existence') //在库标签
  49. {
  50. $this->_existence();
  51. } else if ($arg == 'cpbqdc') //在库标签
  52. {
  53. $this->_cpbqdc();
  54. } else if ($arg == 'type') //进销存浏览
  55. {
  56. $this->_type();
  57. } else if ($arg == 'typedy') //进销存浏览店员页面
  58. {
  59. $this->_typedy($arg_array);
  60. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  61. {
  62. $this->_typedy_ck($arg_array);
  63. } else if ($arg == 'typeck') {
  64. $this->_typeck($arg_array);
  65. } else if ($arg == 'whlabeckdc') {
  66. $this->_whlabeckdc($arg_array);
  67. } else if ($arg == 'usatype') //美仓进销存浏览
  68. {
  69. $this->_usatype();
  70. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  71. {
  72. $this->_usatypeapp();
  73. } else if ($arg == 'enteradd') //入库操作
  74. {
  75. $this->_enteradd();
  76. } else if ($arg == 'enteredit') //修改
  77. {
  78. $this->_enteredit($arg_array);
  79. } else if ($arg == 'enter') //入库浏览
  80. {
  81. $this->_enter();
  82. } else if ($arg == 'out') //出库浏览
  83. {
  84. $this->_out();
  85. } else if ($arg == 'label') //出库标签浏览
  86. {
  87. $this->_label();
  88. } else if ($arg == 'outorder') //独立站出库订单
  89. {
  90. $this->_outorder();
  91. } else if ($arg == 'soutorder') //速卖通出库订单
  92. {
  93. $this->_soutorder();
  94. } else if ($arg == 'toutorder') //TT出库订单
  95. {
  96. $this->_toutorder();
  97. }else if ($arg == 'aoutorder') //amz出库订单
  98. {
  99. $this->_aoutorder();
  100. } else if ($arg == 'retreat') //退库订单
  101. {
  102. $this->_retreat();
  103. } else if ($arg == 'retreatlk') //退库订单
  104. {
  105. $this->_retreatlk();
  106. } else if ($arg == 'change') //更换标签
  107. {
  108. $this->_change();
  109. } else if ($arg == 'del') //删除
  110. {
  111. $this->_del();
  112. } else if ($arg == 'exceljxc') //进销存信息导出
  113. {
  114. $this->_exceljxc();
  115. } else if ($arg == 'excelr') //入库信息导出
  116. {
  117. $this->_excelr();
  118. } else if ($arg == 'excelct') //出库、退库信息导出
  119. {
  120. $this->_excelct();
  121. } else if ($arg == 'dccrtype') //根据出入库类型导出
  122. {
  123. $this->_dccrtype();
  124. } else if ($arg == 'excelcr') //出库、退库信息导出
  125. {
  126. $this->_excelcr();
  127. } else if ($arg == 'kcyz') //库存验证
  128. {
  129. $this->_kcyz();
  130. } else if ($arg == 'kj') //库存扣减
  131. {
  132. $this->_kj($arg_array);
  133. } else if ($arg == 'presetout') //预设库存导入
  134. {
  135. $this->_presetout($arg_array);
  136. } else if ($arg == 'presetedit') //预设库存导入
  137. {
  138. $this->_presetedit($arg_array);
  139. } else if ($arg == 'summary') //汇总导出
  140. {
  141. $this->_summary($arg_array);
  142. } else if ($arg == 'manifest') //usps发货清单
  143. {
  144. $this->_manifest();
  145. } else if ($arg == 'abnormal') //占单异常
  146. {
  147. $this->_abnormal();
  148. } else if ($arg == 'error') //0库存SKU
  149. {
  150. $this->_error();
  151. } else if ($arg == 'errorexcel') //0库存SKU导出
  152. {
  153. $this->_errorexcel();
  154. } else if ($arg == 'db') {
  155. $this->_db();
  156. } else if ($arg == 'dbrk') {
  157. $this->_dbrk();
  158. } else if ($arg == 'whlabelczdc') {
  159. $this->_whlabelczdc();
  160. } else if ($arg == 'print') {
  161. $this->_print($arg_array);
  162. } else if ($arg == 'usaprint') {
  163. $this->_usaprint($arg_array);
  164. } else if ($arg == 'printck') {
  165. $this->_printck($arg_array);
  166. } else if ($arg == 'printrk') {
  167. $this->_printrk($arg_array);
  168. } else if ($arg == 'printxzrk') {
  169. $this->_printxzrk($arg_array);
  170. } else if ($arg == 'printexcel') {
  171. $this->_printexcel($arg_array);
  172. } else if ($arg == 'uck') {
  173. $this->_uck();
  174. } else if ($arg == 'whlabelexcelzh') {
  175. $this->_whlabelexcelzh();
  176. } else if ($arg == 'fc') {
  177. $this->_fc();
  178. } else if ($arg == 'fcmb') {
  179. $this->_fcmb();
  180. } else if ($arg == 'fcexcel') {
  181. $this->_fcexcel();
  182. } else if ($arg == 'fcjxc') {
  183. $this->_fcjxc($arg_array);
  184. } else if ($arg == '0kcdel') {
  185. $this->_0kcdel(); //导表删除0库存
  186. } else if ($arg == 'gbhtype') {
  187. $this->_gbhtype(); //更改备货状态
  188. } else {
  189. $this->_index();
  190. }
  191. }
  192. //管理
  193. public function _index()
  194. {
  195. $post = $this->input->post(NULL, TRUE);
  196. if (isset($post['page'])) {
  197. $page = $this->input->post('page', true);
  198. $perpage = $this->input->post('perpage', true);
  199. $sku = $this->input->post('sku', true);
  200. $number = $this->input->post('number', true);
  201. $warehouse = $this->input->post('warehouse', true);
  202. $purchase = $this->input->post('purchase', true);
  203. $orderinfo = $this->input->post('orderinfo', true);
  204. $waybill = $this->input->post('waybill', true);
  205. $category = $this->input->post('category', true);
  206. $size = $this->input->post('size', true);
  207. $grade = $this->input->post('grade', true);
  208. $color = $this->input->post('color', true);
  209. $lowe = $this->input->post('lowe', true);
  210. $state = $this->input->post('state', true);
  211. $label = $this->input->post('label', true);
  212. $timetk = $this->input->post('timetkk', true);
  213. $timetj = $this->input->post('timetjj', true);
  214. $timetk = strtotime($timetk);
  215. $timetj = strtotime($timetj);
  216. $where = "1=1 ";
  217. if ($timetk && $timetj) {
  218. $where .= " and time > '$timetk' and time < '$timetj'";
  219. }
  220. if ($sku) {
  221. $where .= " and sku = '$sku'";
  222. }
  223. if ($number) {
  224. $where .= " and number = '$number'";
  225. }
  226. if ($warehouse) {
  227. $where .= " and warehouse = '$warehouse'";
  228. }
  229. if ($purchase) {
  230. $where .= " and purchase = '$purchase'";
  231. }
  232. if ($orderinfo) {
  233. $where .= " and orderinfo = '$orderinfo'";
  234. }
  235. if ($waybill) {
  236. $where .= " and waybill = '$waybill'";
  237. }
  238. if ($category) {
  239. $where .= " and features like '%-$category-%'";
  240. }
  241. if ($size) {
  242. $where .= " and features like '%-$size-%'";
  243. }
  244. if ($grade) {
  245. $where .= " and features like '%-$grade-%'";
  246. }
  247. if ($color) {
  248. $where .= " and features like '%-$color-%'";
  249. }
  250. if ($lowe) {
  251. $where .= " and features like '%-$lowe-%'";
  252. }
  253. if ($label) {
  254. $where .= " and label = '$label'";
  255. }
  256. if ($state != '') {
  257. $where .= " and state = '$state'";
  258. }
  259. //数据排序
  260. $order_str = "time desc";
  261. if (empty($page)) {
  262. $start = 0;
  263. $perpage = 1;
  264. } else {
  265. $start = ($page - 1) * $perpage;
  266. }
  267. //取得信息列表
  268. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,label,printing,enter,warehouse,outk,orderinfo,waybill,text,time', $order_str, $start, $perpage);
  269. foreach ($info_list as $key => $value) {
  270. $warehouse = $this->warehouse->read($value['warehouse']);
  271. $info_list[$key]['warehouse'] = $warehouse['title'];
  272. $purchase = $this->purchase->read($value['purchase']);
  273. $info_list[$key]['purchase'] = $purchase['title'];
  274. if ($value['enter'] != 0) {
  275. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  276. } else {
  277. $info_list[$key]['enter'] = "";
  278. }
  279. if ($value['outk'] != 0) {
  280. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  281. } else {
  282. $info_list[$key]['outk'] = "";
  283. }
  284. if ($value['printing'] != 0) {
  285. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  286. } else {
  287. $info_list[$key]['printing'] = "";
  288. }
  289. if ($value['orderinfo'] == 0) {
  290. $info_list[$key]['orderinfo'] = "";
  291. }
  292. if ($value['waybill'] == 0) {
  293. $info_list[$key]['waybill'] = "";
  294. }
  295. if ($value['state'] == 0) {
  296. $info_list[$key]['state'] = "在库";
  297. } else if ($value['state'] == 1) {
  298. $info_list[$key]['state'] = "出库";
  299. } else if ($value['state'] == 2) {
  300. $info_list[$key]['state'] = "退库";
  301. } else if ($value['state'] == 3) {
  302. $info_list[$key]['state'] = "调拨中";
  303. } else if ($value['state'] == 4) {
  304. $info_list[$key]['state'] = "再加工";
  305. } else if ($value['state'] == 5) {
  306. $info_list[$key]['state'] = "维修中";
  307. } else if ($value['state'] == 6) {
  308. $info_list[$key]['state'] = "盘亏";
  309. } else if ($value['state'] == 7) {
  310. $info_list[$key]['state'] = "更换标签";
  311. } else if ($value['state'] == 8) {
  312. $info_list[$key]['state'] = "其它";
  313. } else if ($value['state'] == 9) {
  314. $info_list[$key]['state'] = "预设";
  315. } else if ($value['state'] == 10) {
  316. $info_list[$key]['state'] = "美店零售";
  317. }
  318. if ($value['text'] == "") {
  319. $info_list[$key]['text'] = "";
  320. }
  321. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  322. }
  323. $total = $this->whlabel->find_count($where);
  324. $pagenum = ceil($total / $perpage);
  325. $over = $total - ($start + $perpage);
  326. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  327. echo json_encode($rows);
  328. exit;
  329. }
  330. if (isset($post['outsku'])) {
  331. $cz = $this->input->post('cz', true);
  332. if ($cz == '1') {
  333. $sku = $this->input->post('outsku', true);
  334. if ($sku) {
  335. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  336. if (count($data) < 1) {
  337. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  338. exit;
  339. }
  340. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 1), $data[0]['id']);
  341. echo json_encode(array('success' => true));
  342. exit;
  343. }
  344. } else {
  345. $sku = $this->input->post('outsku', true);
  346. if ($sku) {
  347. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  348. if (count($data) < 1) {
  349. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  350. exit;
  351. }
  352. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  353. echo json_encode(array('success' => true));
  354. exit;
  355. }
  356. }
  357. }
  358. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  359. $this->_Template('whlabel', $this->data);
  360. }
  361. //在库标签
  362. public function _existence()
  363. {
  364. $post = $this->input->post(NULL, TRUE);
  365. if (isset($post['s'])) {
  366. $id_arr = $this->input->post('s');
  367. $id_arr = explode(',', $id_arr);
  368. if (!$id_arr) {
  369. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  370. exit;
  371. }
  372. //循环删除记录
  373. foreach ($id_arr as $v) {
  374. $sid = $this->whlabel->read($v);
  375. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  376. if ($count > 0) {
  377. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  378. exit;
  379. }
  380. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  381. if (count($zt) > 0) {
  382. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  383. exit;
  384. }
  385. $this->whlabel->remove($v);
  386. }
  387. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  388. exit;
  389. }
  390. if (isset($post['page'])) {
  391. $page = $this->input->post('page', true);
  392. $perpage = $this->input->post('perpage', true);
  393. $warehouse = $this->input->post('warehouse', true);
  394. $label = $this->input->post('label', true);
  395. $where = "1=1 and state = 0";
  396. if ($warehouse) {
  397. $where .= " and warehouse = '$warehouse'";
  398. }
  399. if ($label) {
  400. $where .= " and label = '$label'";
  401. }
  402. //数据排序
  403. $order_str = "time asc";
  404. if (empty($page)) {
  405. $start = 0;
  406. $perpage = 1;
  407. } else {
  408. $start = ($page - 1) * $perpage;
  409. }
  410. //取得信息列表
  411. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  412. foreach ($info_list as $key => $value) {
  413. if ($value['enter'] != 0) {
  414. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  415. } else {
  416. $info_list[$key]['enter'] = "";
  417. }
  418. if ($value['printing'] != 0) {
  419. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  420. } else {
  421. $info_list[$key]['printing'] = "";
  422. }
  423. }
  424. $total = $this->whlabel->find_count($where);
  425. $pagenum = ceil($total / $perpage);
  426. $over = $total - ($start + $perpage);
  427. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  428. echo json_encode($rows);
  429. exit;
  430. }
  431. $this->_Template('whlabel_existence', $this->data);
  432. }
  433. //进销存浏览
  434. public function _typedy($arg_array)
  435. {
  436. $prc = array();
  437. $purchase = $this->purchase->find_all();
  438. foreach ($purchase as $k => $v) {
  439. $prc[$v['id']] = $v['title'];
  440. }
  441. $post = $this->input->post(NULL, TRUE);
  442. if (isset($post['page'])) {
  443. $page = $this->input->post('page', true);
  444. $perpage = $this->input->post('perpage', true);
  445. $category = $this->input->post('category', true);
  446. $size = $this->input->post('size', true);
  447. $grade = $this->input->post('grade', true);
  448. $color = $this->input->post('color', true);
  449. $lowe = $this->input->post('lowe', true);
  450. $sku = $this->input->post('sku');
  451. $title = $this->input->post('title');
  452. $warehouse = $this->input->post('warehouse', true);
  453. $usa = $this->input->post('usa', true);
  454. $purchase = $this->input->post('purchase', true);
  455. $lacetype = $this->input->post('lacetype', true);
  456. $haircap = $this->input->post('haircap', true);
  457. $density = $this->input->post('density', true);
  458. $details = $this->input->post('details', true);
  459. $state = $this->input->post('state', true);
  460. $lacecolor = $this->input->post('lacecolor', true);
  461. $hairnumber = $this->input->post('hairnumber', true);
  462. $cklx = $this->input->post('cklx', true);
  463. $ktime = $this->input->post('ktime', true);
  464. $jtime = $this->input->post('jtime', true);
  465. $sm = $this->input->post('sm', true);
  466. $cpbz = $this->input->post('cpbz', true);
  467. $type = $this->input->post('type', true);
  468. $ktime = strtotime($ktime);
  469. $jtime = strtotime($jtime);
  470. $where = "1=1";
  471. $gj = "";
  472. $ck = "";
  473. if ($usa) {
  474. if (!$warehouse) {
  475. $where .= " and (warehouse = '5' or warehouse = '8')";
  476. }
  477. }
  478. if ($warehouse) {
  479. $where .= " and warehouse = '$warehouse'";
  480. }
  481. if ($details) {
  482. $where .= " and details = '$details'";
  483. }
  484. if ($purchase) {
  485. $where .= " and purchase = '$purchase'";
  486. }
  487. if ($state) {
  488. $where .= " and state = '$state'";
  489. }
  490. if ($lacetype) {
  491. $where .= " and features like '%-$lacetype-%'";
  492. }
  493. if ($category) {
  494. $where .= " and features like '%-$category-%'";
  495. }
  496. if ($size) {
  497. $where .= " and features like '%-$size-%'";
  498. }
  499. if ($grade) {
  500. $where .= " and features like '%-$grade-%'";
  501. }
  502. if ($color) {
  503. $where .= " and features like '%-$color-%'";
  504. }
  505. if ($lowe) {
  506. $where .= " and features like '%-$lowe-%'";
  507. }
  508. if ($haircap) {
  509. $where .= " and features like '%-$haircap-%'";
  510. }
  511. if ($density) {
  512. $where .= " and features like '%-$density-%'";
  513. }
  514. if ($lacecolor) {
  515. $where .= " and features like '%-$lacecolor-%'";
  516. }
  517. if($sm){
  518. $where .= " and sm like '%".$sm."%'";
  519. }
  520. if($cpbz){
  521. $where .= " and cpbz like '%".$cpbz."%'";
  522. }
  523. if($type){
  524. $where .= " and type = ".$type."";
  525. }
  526. if (!empty($hairnumber)) {
  527. $where .= " and features like '%-128-%' ";
  528. if ($hairnumber < 0) {
  529. $class_list = $this->typeclass->find_all('classid = 43');
  530. foreach ($class_list as $v) {
  531. $where .= " and features not like '%-" . $v['id'] . "-%'";
  532. }
  533. } else {
  534. $where .= " and features like '%-$hairnumber-%'";
  535. }
  536. }
  537. $where_add = '';
  538. if ($cklx) {
  539. $shop = $this->shop->read($cklx);
  540. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  541. }
  542. if ($ktime && $jtime) {
  543. $gj = " and enter > '$ktime' and enter < '$jtime'";
  544. $ck = " and outk > '$ktime' and outk < '$jtime'";
  545. }
  546. //数据排序
  547. $order_str = "id desc";
  548. if (empty($page)) {
  549. $start = 0;
  550. $perpage = 1;
  551. } else {
  552. $start = ($page - 1) * $perpage;
  553. }
  554. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  555. if ($sku) {
  556. $sku = trim($sku, ' ');
  557. $sku = trim($sku, ' ');
  558. $where .= " and sku like '%$sku%'";
  559. $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);
  560. } else if ($title) {
  561. $title = trim($title, ' ');
  562. $title = trim($title, ' ');
  563. $where .= " and title like '%$title%'";
  564. $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);
  565. } else {
  566. //$where .= " and time > '$ktime' and time < '$jtime'";
  567. $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);
  568. }
  569. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  570. foreach ($info_list as $k => $v) {
  571. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  572. unset($info_list[$k]['pm']);
  573. unset($info_list[$k]['jm']);
  574. unset($info_list[$k]['bm']);
  575. }
  576. //取得信息列表
  577. $rows = array();
  578. $list = array();
  579. foreach ($info_list as $key => $value) {
  580. $warehouse = $this->warehouse->read($value['warehouse']);
  581. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  582. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  583. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  584. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  585. $info_list[$key]['label'] = $value['sm'];
  586. $number = $value['number'];
  587. $ftime = time() - 15 * 24 * 3600;
  588. $info_list[$key]['warehouse'] = $warehouse['title'];
  589. $info_list[$key]['features'] = count($c);
  590. $z = count($z); //查看订单号
  591. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  592. $ztdata = '';
  593. if (count($zt) > 0) {
  594. foreach ($zt as $vv) {
  595. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  596. }
  597. }
  598. $info_list[$key]['number'] = $ztdata;
  599. $info_list[$key]['sm'] = $z;
  600. $details = array();
  601. $cpid = array();
  602. foreach ($c as $k => $v) {
  603. $details[$v['details']] = $v['details'];
  604. if ($v['cpid'] != 0) {
  605. $cpid[$v['cpid']] = $v['cpid'];
  606. }
  607. }
  608. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  609. if ($value['shop'] != '') {
  610. $shop = explode(',', trim($value['shop'], ','));
  611. $shop = $this->shop->read($shop[0]);
  612. $info_list[$key]['shop'] = $shop['shopname'];
  613. }
  614. }
  615. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  616. $pagenum = ceil($total / $perpage);
  617. $over = $total - ($start + $perpage);
  618. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  619. echo json_encode($rows);
  620. exit;
  621. }
  622. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  623. $this->_Template('whlabel_typedy', $this->data);
  624. }
  625. //进销存浏览
  626. public function _typedy_ck($arg_array)
  627. {
  628. $prc = array();
  629. $purchase = $this->purchase->find_all();
  630. foreach ($purchase as $k => $v) {
  631. $prc[$v['id']] = $v['title'];
  632. }
  633. $post = $this->input->post(NULL, TRUE);
  634. if (isset($post['page'])) {
  635. $page = $this->input->post('page', true);
  636. $perpage = $this->input->post('perpage', true);
  637. $category = $this->input->post('category', true);
  638. $size = $this->input->post('size', true);
  639. $grade = $this->input->post('grade', true);
  640. $color = $this->input->post('color', true);
  641. $lowe = $this->input->post('lowe', true);
  642. $sku = $this->input->post('sku');
  643. $title = $this->input->post('title');
  644. $warehouse = $this->input->post('warehouse', true);
  645. $usa = $this->input->post('usa', true);
  646. $purchase = $this->input->post('purchase', true);
  647. $lacetype = $this->input->post('lacetype', true);
  648. $haircap = $this->input->post('haircap', true);
  649. $density = $this->input->post('density', true);
  650. $details = $this->input->post('details', true);
  651. $state = $this->input->post('state', true);
  652. $lacecolor = $this->input->post('lacecolor', true);
  653. $cklx = $this->input->post('cklx', true);
  654. $ktime = $this->input->post('ktime', true);
  655. $jtime = $this->input->post('jtime', true);
  656. $ktime = strtotime($ktime);
  657. $jtime = strtotime($jtime);
  658. $where = "1=1";
  659. $gj = "";
  660. $ck = "";
  661. if ($lacetype) {
  662. $where .= " and features like '%-$lacetype-%'";
  663. }
  664. if ($category) {
  665. $where .= " and features like '%-$category-%'";
  666. }
  667. if ($size) {
  668. $where .= " and features like '%-$size-%'";
  669. }
  670. if ($grade) {
  671. $where .= " and features like '%-$grade-%'";
  672. }
  673. if ($color) {
  674. $where .= " and features like '%-$color-%'";
  675. }
  676. if ($lowe) {
  677. $where .= " and features like '%-$lowe-%'";
  678. }
  679. if ($haircap) {
  680. $where .= " and features like '%-$haircap-%'";
  681. }
  682. if ($density) {
  683. $where .= " and features like '%-$density-%'";
  684. }
  685. if ($lacecolor) {
  686. $where .= " and features like '%-$lacecolor-%'";
  687. }
  688. if ($usa) {
  689. if (!$warehouse) {
  690. $where .= " and (warehouse = '5' or warehouse = '8')";
  691. }
  692. }
  693. if ($warehouse) {
  694. $where .= " and warehouse = '$warehouse'";
  695. }
  696. if ($details) {
  697. $where .= " and details = '$details'";
  698. }
  699. if ($purchase) {
  700. $where .= " and purchase = '$purchase'";
  701. }
  702. if ($state) {
  703. $where .= " and state = '$state'";
  704. }
  705. $where_add = '';
  706. if ($cklx) {
  707. $shop = $this->shop->read($cklx);
  708. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  709. }
  710. if ($ktime && $jtime) {
  711. $gj = " and enter > '$ktime' and enter < '$jtime'";
  712. $ck = " and outk > '$ktime' and outk < '$jtime'";
  713. }
  714. //数据排序
  715. $order_str = "id desc";
  716. if (empty($page)) {
  717. $start = 0;
  718. $perpage = 1;
  719. } else {
  720. $start = ($page - 1) * $perpage;
  721. }
  722. if ($sku) {
  723. $sku = trim($sku, ' ');
  724. $sku = trim($sku, ' ');
  725. $where .= " and sku like '%$sku%'";
  726. $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);
  727. } else if ($title) {
  728. $title = trim($title, ' ');
  729. $title = trim($title, ' ');
  730. $where .= " and title like '%$title%'";
  731. $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);
  732. } else {
  733. //$where .= " and time > '$ktime' and time < '$jtime'";
  734. $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);
  735. }
  736. //取得信息列表
  737. $rows = array();
  738. $list = array();
  739. foreach ($info_list as $key => $value) {
  740. $warehouse = $this->warehouse->read($value['warehouse']);
  741. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  742. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  743. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  744. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  745. $ftime = time() - 15 * 24 * 3600;
  746. $info_list[$key]['warehouse'] = $warehouse['title'];
  747. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  748. //$z = count($z);//查看订单号
  749. //$info_list[$key]['zd'] = $z;
  750. $details = array();
  751. $cpid = array();
  752. foreach ($c as $k => $v) {
  753. $details[$v['details']] = $v['details'];
  754. if ($v['cpid'] != 0) {
  755. $cpid[$v['cpid']] = $v['cpid'];
  756. }
  757. }
  758. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  759. if ($value['shop'] != '') {
  760. $shop = explode(',', trim($value['shop'], ','));
  761. $shop = $this->shop->read($shop[0]);
  762. $info_list[$key]['shop'] = $shop['shopname'];
  763. }
  764. }
  765. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  766. $pagenum = ceil($total / $perpage);
  767. $over = $total - ($start + $perpage);
  768. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  769. echo json_encode($rows);
  770. exit;
  771. }
  772. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  773. $this->_Template('whlabel_typedy_ck', $this->data);
  774. }
  775. public function _typeck($arg_array)
  776. {
  777. $prc = array();
  778. $purchase = $this->purchase->find_all();
  779. foreach ($purchase as $k => $v) {
  780. $prc[$v['id']] = $v['title'];
  781. }
  782. $post = $this->input->post(NULL, TRUE);
  783. if (isset($post['page'])) {
  784. $page = $this->input->post('page', true);
  785. $perpage = $this->input->post('perpage', true);
  786. $category = $this->input->post('category', true);
  787. $size = $this->input->post('size', true);
  788. $grade = $this->input->post('grade', true);
  789. $color = $this->input->post('color', true);
  790. $lacecolor = $this->input->post('lacecolor', true);
  791. $lowe = $this->input->post('lowe', true);
  792. $sku = $this->input->post('sku');
  793. $title = $this->input->post('title');
  794. $warehouse = 13;
  795. $usa = $this->input->post('usa', true);
  796. $purchase = $this->input->post('purchase', true);
  797. $lacetype = $this->input->post('lacetype', true);
  798. $haircap = $this->input->post('haircap', true);
  799. $density = $this->input->post('density', true);
  800. $details = $this->input->post('details', true);
  801. $state = $this->input->post('state', true);
  802. $ktime = $this->input->post('ktime', true);
  803. $jtime = $this->input->post('jtime', true);
  804. $ktime = strtotime($ktime);
  805. $jtime = strtotime($jtime);
  806. $where = "1=1";
  807. $gj = "";
  808. $ck = "";
  809. if ($lacetype) {
  810. $where .= " and features like '%-$lacetype-%'";
  811. }
  812. if ($category) {
  813. $where .= " and features like '%-$category-%'";
  814. }
  815. if ($size) {
  816. $where .= " and features like '%-$size-%'";
  817. }
  818. if ($grade) {
  819. $where .= " and features like '%-$grade-%'";
  820. }
  821. if ($color) {
  822. $where .= " and features like '%-$color-%'";
  823. }
  824. if ($lacecolor) {
  825. $where .= " and features like '%-$lacecolor-%'";
  826. }
  827. if ($lowe) {
  828. $where .= " and features like '%-$lowe-%'";
  829. }
  830. if ($haircap) {
  831. $where .= " and features like '%-$haircap-%'";
  832. }
  833. if ($density) {
  834. $where .= " and features like '%-$density-%'";
  835. }
  836. if ($warehouse) {
  837. $where .= " and warehouse = '$warehouse'";
  838. }
  839. if ($details) {
  840. $where .= " and details = '$details'";
  841. }
  842. if ($purchase) {
  843. $where .= " and purchase = '$purchase'";
  844. }
  845. if ($state) {
  846. $where .= " and state = '$state'";
  847. }
  848. if ($ktime && $jtime) {
  849. $gj = " and enter > '$ktime' and enter < '$jtime'";
  850. $ck = " and outk > '$ktime' and outk < '$jtime'";
  851. }
  852. //数据排序
  853. $order_str = "id desc";
  854. if (empty($page)) {
  855. $start = 0;
  856. $perpage = 1;
  857. } else {
  858. $start = ($page - 1) * $perpage;
  859. }
  860. if ($sku) {
  861. $sku = trim($sku, ' ');
  862. $sku = trim($sku, ' ');
  863. $where .= " and sku like '%$sku%'";
  864. } else if ($title) {
  865. $title = trim($title, ' ');
  866. $title = trim($title, ' ');
  867. $where .= " and title like '%$title%'";
  868. }
  869. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  870. //取得信息列表
  871. $t = array();
  872. $typeclass = $this->typeclass->find_all();
  873. foreach ($typeclass as $v) {
  874. $t[$v['id']] = $v;
  875. }
  876. $rows = array();
  877. $list = array();
  878. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  879. foreach ($info_list as $key => $value) {
  880. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  881. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  882. $warehouse = $this->warehouse->read($value['warehouse']);
  883. $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');
  884. $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'] . '"');
  885. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  886. $number = $value['number'];
  887. $ftime = time() - 15 * 24 * 3600;
  888. $z = count($z); //查看订单号
  889. $info_list[$key]['warehouse'] = $warehouse['title'];
  890. $info_list[$key]['features'] = count($c);
  891. $info_list[$key]['number'] = $z;
  892. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  893. $details = array();
  894. $cpid = array();
  895. foreach ($c as $k => $v) {
  896. $details[$v['details']] = $v['details'];
  897. if ($v['cpid'] != 0) {
  898. $cpid[$v['cpid']] = $v['cpid'];
  899. }
  900. }
  901. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  902. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  903. unset($info_list[$key]['pm']);
  904. unset($info_list[$key]['jm']);
  905. unset($info_list[$key]['bm']);
  906. }
  907. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  908. $pagenum = ceil($total / $perpage);
  909. $over = $total - ($start + $perpage);
  910. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  911. echo json_encode($rows);
  912. exit;
  913. }
  914. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  915. $this->_Template('whlabel_typeck', $this->data);
  916. }
  917. //进销存导出
  918. public function _whlabeckdc()
  919. {
  920. $prc = array();
  921. $purchase = $this->purchase->find_all();
  922. foreach ($purchase as $k => $v) {
  923. $prc[$v['id']] = $v['title'];
  924. }
  925. if (isset($_GET['excel'])) {
  926. $where = "sku != 'Preset'";
  927. //数据排序
  928. $order_str = "id desc";
  929. if (empty($page)) {
  930. $start = 0;
  931. $perpage = 1;
  932. } else {
  933. $start = ($page - 1) * $perpage;
  934. }
  935. $category = $this->input->get('category', true);
  936. $color = $this->input->get('color', true);
  937. $lowe = $this->input->get('lowe', true);
  938. $lacetype = $this->input->get('lacetype', true);
  939. $size = $this->input->get('size', true);
  940. $density = $this->input->get('density', true);
  941. $haircap = $this->input->get('haircap', true);
  942. $sku = $this->input->get('sku', true);
  943. $details = $this->input->get('details', true);
  944. $warehouse = 13;
  945. $excelid = $this->input->get('sid', true);
  946. if ($category) {
  947. $where .= " and features like '%-$category-%'";
  948. }
  949. if ($color) {
  950. $where .= " and features like '%-$color-%'";
  951. }
  952. if ($lowe) {
  953. $where .= " and features like '%-$lowe-%'";
  954. }
  955. if ($lacetype) {
  956. $where .= " and features like '%-$lacetype-%'";
  957. }
  958. if ($size) {
  959. $where .= " and features like '%-$size-%'";
  960. }
  961. if ($density) {
  962. $where .= " and features like '%-$density-%'";
  963. }
  964. if ($haircap) {
  965. $where .= " and features like '%-$haircap-%'";
  966. }
  967. if ($warehouse) {
  968. $where .= " and warehouse = '$warehouse'";
  969. }
  970. if ($sku) {
  971. $where .= " and sku like '%$sku%'";
  972. }
  973. if ($details) {
  974. $where .= " and details = '$details'";
  975. }
  976. $xzid = '';
  977. if ($excelid) {
  978. $excelid = explode(',', trim($excelid, ','));
  979. foreach ($excelid as $key => $value) {
  980. $xzid .= " id = " . $value . " or";
  981. }
  982. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  983. }
  984. //取得信息列表
  985. /**
  986. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  987. $rows = array();$list = array();
  988. foreach ($info_list as $key=>$value)
  989. {
  990. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  991. }
  992. **/
  993. $wh = array();
  994. $w = $this->warehouse->find_all('1=1', 'id,title');
  995. foreach ($w as $v) {
  996. $wh[$v['id']] = $v['title'];
  997. }
  998. $tc = array();
  999. $tcdata = array();
  1000. $list = array();
  1001. $classid = $this->classid->sku();
  1002. $tcall = $this->typeclass->find_all();
  1003. $typeclass = array();
  1004. foreach ($tcall as $v)
  1005. {
  1006. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1007. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1008. }
  1009. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1010. foreach ($rows as $key => $value) {
  1011. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1012. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1013. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1014. $rows[$key]['cpbz'] = $u9_info['bm'];
  1015. $rows[$key]['cs'] = $u9_info['jm'];
  1016. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1017. $details = array();
  1018. $cpid = array();
  1019. $cpbz = array();
  1020. $c = 0;
  1021. $g = 0;
  1022. $x = 0;
  1023. $t = 0;
  1024. $s = 0;
  1025. $q = 0;
  1026. foreach ($sd as $k => $v) {
  1027. if ($v['state'] == 0) {
  1028. $c++;
  1029. }
  1030. if ($v['state'] != 9) {
  1031. $g++;
  1032. }
  1033. if ($v['state'] == 1) {
  1034. $x++;
  1035. }
  1036. if ($v['state'] == 2) {
  1037. $t++;
  1038. }
  1039. if ($v['state'] == 8) {
  1040. $s++;
  1041. }
  1042. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1043. $q++;
  1044. }
  1045. $details[$v['details']] = $v['details'];
  1046. if ($v['cpid'] != 0) {
  1047. $cpid[$v['cpid']] = $v['cpid'];
  1048. }
  1049. if ($v['cpbz'] != '') {
  1050. $cpbz[$v['cpbz']] = $v['cpbz'];
  1051. }
  1052. }
  1053. $rows[$key]['details'] = implode("、", $details);
  1054. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1055. $number = $value['number'];
  1056. $ftime = time() - 15 * 24 * 3600;
  1057. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1058. $rows[$key]['number'] = $g;
  1059. $rows[$key]['features'] = $c;
  1060. $rows[$key]['x'] = $x;
  1061. $rows[$key]['t'] = $t;
  1062. $rows[$key]['s'] = $s;
  1063. $rows[$key]['q'] = $q;
  1064. $rows[$key]['wzsl'] = count($details);
  1065. }
  1066. $title = "进销存统计表" . date('Y-m-d', time());
  1067. $titlename = "<table border=1>
  1068. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1069. <tr align='center'>
  1070. <td>仓库</td>
  1071. <td>供应商</td>
  1072. <td>位置</td>
  1073. <td>库存编码</td>
  1074. <td>SKU</td>
  1075. <td>用友编码</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. </tr>
  1087. </table>";
  1088. $filename = $title . ".xls";
  1089. $tail = "";
  1090. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1091. }
  1092. }
  1093. public function _type()
  1094. {
  1095. $vip = 0;
  1096. if (isset($_SESSION['api'])) {
  1097. $user = $this->user->get_api($_SESSION['api']);
  1098. $fgshop = "";
  1099. $sid = "";
  1100. $usersp = explode('|', trim($user['shop'], '|'));
  1101. foreach ($usersp as $value) {
  1102. $fgshop .= " shop = " . $value . " or";
  1103. $sid .= " id = " . $value . " or";
  1104. }
  1105. if ($user['vip'] == 1) {
  1106. $vip = 1;
  1107. }
  1108. } else {
  1109. header('Location: /');
  1110. exit;
  1111. }
  1112. $prc = array();
  1113. $purchase = $this->purchase->find_all();
  1114. foreach ($purchase as $k => $v) {
  1115. $prc[$v['id']] = $v['title'];
  1116. }
  1117. $company = array();
  1118. $ct = $this->company->find_all();
  1119. foreach ($ct as $k => $v) {
  1120. $company[$v['id']] = $v['title'];
  1121. }
  1122. $sp = array();
  1123. $s = $this->shop->find_all('1=1', 'id,shopname');
  1124. foreach ($s as $v) {
  1125. $sp[$v['id']] = $v['shopname'];
  1126. }
  1127. $wh = array();
  1128. $w = $this->warehouse->find_all('1=1', 'id,title');
  1129. foreach ($w as $v) {
  1130. $wh[$v['id']] = $v['title'];
  1131. }
  1132. $post = $this->input->post(NULL, TRUE);
  1133. if (isset($post['page'])) {
  1134. $page = $this->input->post('page', true);
  1135. $perpage = $this->input->post('perpage', true);
  1136. $category = $this->input->post('category', true);
  1137. $size = $this->input->post('size', true);
  1138. $grade = $this->input->post('grade', true);
  1139. $color = $this->input->post('color', true);
  1140. $lowe = $this->input->post('lowe', true);
  1141. $sku = $this->input->post('sku');
  1142. $title = $this->input->post('title');
  1143. $warehouse = $this->input->post('warehouse', true);
  1144. $usa = $this->input->post('usa', true);
  1145. $purchase = $this->input->post('purchase', true);
  1146. $lacetype = $this->input->post('lacetype', true);
  1147. $haircap = $this->input->post('haircap', true);
  1148. $density = $this->input->post('density', true);
  1149. $details = $this->input->post('details', true);
  1150. $state = $this->input->post('state', true);
  1151. $shop = $this->input->post('shop', true);
  1152. $lacecolor = $this->input->post('lacecolor', true);
  1153. $hairnumber = $this->input->post('hairnumber', true);
  1154. $type = $this->input->post('type', true);
  1155. $ktime = $this->input->post('ktime', true);
  1156. $jtime = $this->input->post('jtime', true);
  1157. $ktime = strtotime($ktime);
  1158. $jtime = strtotime($jtime);
  1159. $cpbz = $this->input->post('cpbz', true);
  1160. $sm = $this->input->post('sm', true);
  1161. $where = "1=1";
  1162. $gj = "";
  1163. $ck = "";
  1164. if ($usa) {
  1165. if (!$warehouse) {
  1166. $where .= " and (warehouse = '5' or warehouse = '8')";
  1167. }
  1168. }
  1169. if ($warehouse) {
  1170. $where .= " and warehouse = '$warehouse'";
  1171. }
  1172. if ($details) {
  1173. $where .= " and details = '$details'";
  1174. }
  1175. if ($purchase) {
  1176. $where .= " and purchase = '$purchase'";
  1177. }
  1178. if ($state) {
  1179. $where .= " and state = '$state'";
  1180. }
  1181. if ($shop) {
  1182. $where .= " and shop like '%$shop%'";
  1183. }
  1184. if ($type) {
  1185. $where .= " and type = '$type'";
  1186. }
  1187. if ($ktime && $jtime) {
  1188. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1189. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1190. }
  1191. if ($cpbz) {
  1192. $where .= " and cpbz like '%$cpbz%' ";
  1193. }
  1194. if ($sm) {
  1195. $where .= " and sm like '%$sm%' ";
  1196. }
  1197. if ($lacecolor) {
  1198. $where .= " and features like '%-$lacecolor-%'";
  1199. }
  1200. if ($lacetype) {
  1201. $where .= " and features like '%-$lacetype-%'";
  1202. }
  1203. if ($category) {
  1204. $where .= " and features like '%-$category-%'";
  1205. }
  1206. if ($size) {
  1207. $where .= " and features like '%-$size-%'";
  1208. }
  1209. if ($grade) {
  1210. $where .= " and features like '%-$grade-%'";
  1211. }
  1212. if ($color) {
  1213. $where .= " and features like '%-$color-%'";
  1214. }
  1215. if ($lowe) {
  1216. $where .= " and features like '%-$lowe-%'";
  1217. }
  1218. if ($haircap) {
  1219. $where .= " and features like '%-$haircap-%'";
  1220. }
  1221. if ($density) {
  1222. $where .= " and features like '%-$density-%'";
  1223. }
  1224. if (!empty($hairnumber)) {
  1225. $where .= " and features like '%-128-%' ";
  1226. if ($hairnumber < 0) {
  1227. $class_list = $this->typeclass->find_all('classid = 43');
  1228. foreach ($class_list as $v) {
  1229. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1230. }
  1231. } else {
  1232. $where .= " and features like '%-$hairnumber-%'";
  1233. }
  1234. }
  1235. //数据排序
  1236. $order_str = "id desc";
  1237. if (empty($page)) {
  1238. $start = 0;
  1239. $perpage = 1;
  1240. } else {
  1241. $start = ($page - 1) * $perpage;
  1242. }
  1243. $fjnr = '';
  1244. if ($sku) {
  1245. $sku = trim($sku, ' ');
  1246. $sku = trim($sku, ' ');
  1247. $fjnr .= " and sku like '%$sku%'";
  1248. }
  1249. if ($title) {
  1250. $title = trim($title, ' ');
  1251. $title = trim($title, ' ');
  1252. $fjnr .= " and title like '%$title%'";
  1253. }
  1254. $wt = array();
  1255. $whlabel_type = $this->whlabel_type->find_all();
  1256. foreach ($whlabel_type as $v) {
  1257. $wt[$v['id']] = $v['title'];
  1258. }
  1259. //$where .= " and time > '$ktime' and time < '$jtime'";
  1260. $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
  1261. //取得信息列表
  1262. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1263. $rows = array();
  1264. $list = array();
  1265. foreach ($info_list as $key => $value) {
  1266. if (isset($wt[$value['type']])) {
  1267. $info_list[$key]['type'] = $wt[$value['type']];
  1268. } else {
  1269. $info_list[$key]['type'] = '未设置';
  1270. }
  1271. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1272. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1273. $ztdata = '';
  1274. if (count($zt) > 0) {
  1275. foreach ($zt as $vv) {
  1276. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1277. }
  1278. }
  1279. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1280. $cdata = array_filter($qbdata, function ($item) {
  1281. return $item['state'] < 1;
  1282. });
  1283. $c = array_sum(array_column($cdata, 'jnum'));
  1284. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1285. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1286. });
  1287. $g = array_sum(array_column($gdata, 'jnum'));
  1288. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1289. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1290. });
  1291. $x = array_sum(array_column($xdata, 'jnum'));
  1292. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1293. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1294. });
  1295. $t = array_sum(array_column($tdata, 'jnum'));
  1296. $zdata = array_filter($qbdata, function ($item) {
  1297. return $item['zd'] != "" && $item['state'] < 1;
  1298. });
  1299. $z = array_sum(array_column($zdata, 'jnum'));
  1300. $zdata = array_filter($qbdata, function ($item) {
  1301. return $item['zd'] != "" && $item['state'] < 1;
  1302. });
  1303. $z = array_sum(array_column($zdata, 'jnum'));
  1304. //$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');
  1305. //$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'].'"');
  1306. //$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'].'"');
  1307. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1308. //$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'].'"');
  1309. $details = array();
  1310. $cpid = array();
  1311. $od = array();
  1312. $odid = '';
  1313. $companytitle = '';
  1314. foreach ($qbdata as $v) {
  1315. if ($v['zd'] != "" && $v['state'] < 1) {
  1316. if (!isset($od[$v['zd']])) {
  1317. $od[$v['zd']] = 1; //所有数据sku
  1318. } else {
  1319. $od[$v['zd']] = $od[$v['zd']] + 1;
  1320. }
  1321. }
  1322. if ($v['state'] < 1) {
  1323. $details[$v['details']] = $v['details'];
  1324. if ($v['cpid'] != 0) {
  1325. $cpid[$v['cpid']] = $v['cpid'];
  1326. }
  1327. }
  1328. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1329. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1330. }
  1331. }
  1332. foreach ($od as $k => $vv) {
  1333. $odid .= $k . '数量' . $vv;
  1334. }
  1335. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1336. $info_list[$key]['label'] = $value['sm'];
  1337. $number = $value['number'];
  1338. $ftime = time() - 15 * 24 * 3600;
  1339. $z = $z . '(' . $odid . ')'; //查看订单号
  1340. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1341. $info_list[$key]['features'] = $c;
  1342. $info_list[$key]['number'] = $ztdata;
  1343. $info_list[$key]['sm'] = $g;
  1344. $info_list[$key]['x'] = $x;
  1345. $info_list[$key]['t'] = $t;
  1346. $info_list[$key]['z'] = $z;
  1347. /**
  1348. foreach ($cdata as $k=>$v)
  1349. {
  1350. $details[$v['details']] = $v['details'];
  1351. if($v['cpid'] != 0)
  1352. {
  1353. $cpid[$v['cpid']] = $v['cpid'];
  1354. }
  1355. }
  1356. **/
  1357. $info_list[$key]['shop'] = '';
  1358. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1359. if ($value['shop'] != '') {
  1360. $shop = explode(',', trim($value['shop'], ','));
  1361. $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1362. }
  1363. $info_list[$key]['shop'] .= $companytitle;
  1364. /**
  1365. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1366. if(isset($companytitle[0]))
  1367. {
  1368. foreach ($companytitle as $k=>$v)
  1369. {
  1370. if($v['companytitle'] != '')
  1371. {
  1372. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1373. }
  1374. }
  1375. }
  1376. **/
  1377. }
  1378. $final_all_list = [];
  1379. foreach ($info_list as $k => $v) {
  1380. $final_all_list[] = [
  1381. 'id' => $v['id'],
  1382. "warehouse" => $v["warehouse"],
  1383. "purchase" => $v["purchase"],
  1384. "sku" => $v["sku"],
  1385. "title" => $v["title"] . "<br/>" . $v["pm"],
  1386. "details" => $v["details"],
  1387. "shop" => $v["shop"],
  1388. "cpbz" => $v["cpbz"],
  1389. 'label' => $v['label'],
  1390. "type" => $v["type"],
  1391. "features" => $v["features"],
  1392. "number" => $v["number"],
  1393. "sm" => $v["sm"],
  1394. "x" => $v["x"],
  1395. "t" => $v["t"],
  1396. "z" => $v["z"]
  1397. ];
  1398. }
  1399. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1400. $pagenum = ceil($total / $perpage);
  1401. $over = $total - ($start + $perpage);
  1402. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1403. echo json_encode($rows);
  1404. exit;
  1405. }
  1406. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1407. $this->data['shop'] = $wlshop;
  1408. $this->data['vip'] = $vip;
  1409. $this->_Template('whlabel_type', $this->data);
  1410. }
  1411. //美仓进销存浏览
  1412. public function _usatype()
  1413. {
  1414. if (isset($_SESSION['api'])) {
  1415. $user = $this->user->get_api($_SESSION['api']);
  1416. $usp = $user;
  1417. $fgshop = "";
  1418. $sid = "";
  1419. $wid = "";
  1420. $wtype = "";
  1421. $userwh = explode('|', trim($user['warehouse'], '|'));
  1422. foreach ($userwh as $value) {
  1423. $wid .= " id = " . $value . " or";
  1424. $wtype .= " type = " . $value . " or";
  1425. }
  1426. }
  1427. $prc = array();
  1428. $purchase = $this->purchase->find_all();
  1429. foreach ($purchase as $k => $v) {
  1430. $prc[$v['id']] = $v['title'];
  1431. }
  1432. $post = $this->input->post(NULL, TRUE);
  1433. if (isset($post['page'])) {
  1434. $page = $this->input->post('page', true);
  1435. $perpage = $this->input->post('perpage', true);
  1436. $category = $this->input->post('category', true);
  1437. $size = $this->input->post('size', true);
  1438. $grade = $this->input->post('grade', true);
  1439. $color = $this->input->post('color', true);
  1440. $lowe = $this->input->post('lowe', true);
  1441. $sku = $this->input->post('sku');
  1442. $title = $this->input->post('title');
  1443. $warehouse = $this->input->post('warehouse', true);
  1444. $usa = $this->input->post('usa', true);
  1445. $purchase = $this->input->post('purchase', true);
  1446. $lacetype = $this->input->post('lacetype', true);
  1447. $haircap = $this->input->post('haircap', true);
  1448. $density = $this->input->post('density', true);
  1449. $details = $this->input->post('details', true);
  1450. $state = $this->input->post('state', true);
  1451. $lacecolor = $this->input->post('lacecolor', true);
  1452. $cklx = $this->input->post('cklx', true);
  1453. $ktime = $this->input->post('ktime', true);
  1454. $jtime = $this->input->post('jtime', true);
  1455. $ktime = strtotime($ktime);
  1456. $jtime = strtotime($jtime);
  1457. $where = "1=1";
  1458. $gj = "";
  1459. $ck = "";
  1460. if ($lacetype) {
  1461. $where .= " and features like '%-$lacetype-%'";
  1462. }
  1463. if ($category) {
  1464. $where .= " and features like '%-$category-%'";
  1465. }
  1466. if ($size) {
  1467. $where .= " and features like '%-$size-%'";
  1468. }
  1469. if ($grade) {
  1470. $where .= " and features like '%-$grade-%'";
  1471. }
  1472. if ($color) {
  1473. $where .= " and features like '%-$color-%'";
  1474. }
  1475. if ($lowe) {
  1476. $where .= " and features like '%-$lowe-%'";
  1477. }
  1478. if ($haircap) {
  1479. $where .= " and features like '%-$haircap-%'";
  1480. }
  1481. if ($density) {
  1482. $where .= " and features like '%-$density-%'";
  1483. }
  1484. if ($lacecolor) {
  1485. $where .= " and features like '%-$lacecolor-%'";
  1486. }
  1487. if ($usa) {
  1488. if (!$warehouse) {
  1489. $where .= " and (warehouse = '5' or warehouse = '8')";
  1490. }
  1491. }
  1492. if ($warehouse) {
  1493. $where .= " and warehouse = '$warehouse'";
  1494. }
  1495. if ($details) {
  1496. $where .= " and details = '$details'";
  1497. }
  1498. if ($purchase) {
  1499. $where .= " and purchase = '$purchase'";
  1500. }
  1501. if ($state) {
  1502. $where .= " and state = '$state'";
  1503. }
  1504. $where_add = '';
  1505. if ($cklx) {
  1506. $shop = $this->shop->read($cklx);
  1507. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1508. }
  1509. if ($ktime && $jtime) {
  1510. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1511. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1512. }
  1513. //数据排序
  1514. $order_str = "id desc";
  1515. if (empty($page)) {
  1516. $start = 0;
  1517. $perpage = 1;
  1518. } else {
  1519. $start = ($page - 1) * $perpage;
  1520. }
  1521. if ($sku) {
  1522. $sku = trim($sku, ' ');
  1523. $sku = trim($sku, ' ');
  1524. $where .= " and sku like '%$sku%'";
  1525. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1526. } else if ($title) {
  1527. $title = trim($title, ' ');
  1528. $title = trim($title, ' ');
  1529. $where .= " and title like '%$title%'";
  1530. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1531. } else {
  1532. //$where .= " and time > '$ktime' and time < '$jtime'";
  1533. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1534. }
  1535. //取得信息列表
  1536. $rows = array();
  1537. $list = array();
  1538. foreach ($info_list as $key => $value) {
  1539. $warehouse = $this->warehouse->read($value['warehouse']);
  1540. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1541. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1542. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1543. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1544. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1545. $od = array();
  1546. $odid = '';
  1547. foreach ($z as $v) {
  1548. if (!isset($od[$v['zd']])) {
  1549. $od[$v['zd']] = 1; //所有数据sku
  1550. } else {
  1551. $od[$v['zd']] = $od[$v['zd']] + 1;
  1552. }
  1553. }
  1554. foreach ($od as $k => $vv) {
  1555. $odid .= $k . '数量' . $vv . ' ';
  1556. }
  1557. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1558. $info_list[$key]['features'] = $c;
  1559. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1560. $ztdata = '';
  1561. if (count($zt) > 0) {
  1562. foreach ($zt as $vv) {
  1563. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1564. }
  1565. }
  1566. $info_list[$key]['warehouse'] = $ztdata;
  1567. $info_list[$key]['g'] = $g;
  1568. $info_list[$key]['x'] = $x;
  1569. $info_list[$key]['t'] = $t;
  1570. $info_list[$key]['z'] = $z;
  1571. }
  1572. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1573. $pagenum = ceil($total / $perpage);
  1574. $over = $total - ($start + $perpage);
  1575. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1576. echo json_encode($rows);
  1577. exit;
  1578. }
  1579. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1580. $this->data['warehouse'] = $warehouse;
  1581. $this->_Template('whlabel_typeusa', $this->data);
  1582. }
  1583. //美仓进销存浏览
  1584. public function _usatypeapp()
  1585. {
  1586. $post = $this->input->post(NULL, TRUE);
  1587. if (isset($post['page'])) {
  1588. $page = $this->input->post('page', true);
  1589. $perpage = $this->input->post('perpage', true);
  1590. $sku = $this->input->post('sku', true);
  1591. $warehouse = 5;
  1592. $title = $this->input->post('title', true);
  1593. $state = $this->input->post('state', true);
  1594. $ktime = $this->input->post('ktime', true);
  1595. $jtime = $this->input->post('jtime', true);
  1596. $ktime = strtotime($ktime);
  1597. $jtime = strtotime($jtime);
  1598. $where = "1=1";
  1599. $gj = "";
  1600. $ck = "";
  1601. if ($title) {
  1602. $st = explode(' ', trim($title, ' '));
  1603. foreach ($st as $v) {
  1604. $where .= " and title like '%$v%'";
  1605. }
  1606. }
  1607. if ($warehouse) {
  1608. $where .= " and warehouse = '$warehouse'";
  1609. }
  1610. if ($state) {
  1611. $where .= " and state = '$state'";
  1612. }
  1613. if ($sku) {
  1614. $where .= " and sku like '%$sku%'";
  1615. }
  1616. if ($ktime && $jtime) {
  1617. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1618. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1619. }
  1620. //数据排序
  1621. $order_str = "id desc";
  1622. if (empty($page)) {
  1623. $start = 0;
  1624. $perpage = 1;
  1625. } else {
  1626. $start = ($page - 1) * $perpage;
  1627. }
  1628. //取得信息列表
  1629. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1630. $rows = array();
  1631. $list = array();
  1632. foreach ($info_list as $key => $value) {
  1633. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1634. }
  1635. $rowsdq = array_slice($rows, $start, $perpage);
  1636. foreach ($rowsdq as $value) {
  1637. $warehouse = $this->warehouse->read($value['warehouse']);
  1638. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1639. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1640. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1641. $od = array();
  1642. $odid = '';
  1643. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1644. }
  1645. $total = count($rows);
  1646. $pagenum = ceil($total / $perpage);
  1647. $over = $total - ($start + $perpage);
  1648. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1649. echo json_encode($rows);
  1650. exit;
  1651. }
  1652. $this->_Template('phone/p_usatypeapp', $this->data);
  1653. }
  1654. //入库操作
  1655. public function _enteradd()
  1656. {
  1657. $dt = 0;
  1658. if (isset($_SESSION['api'])) {
  1659. $user = $this->user->get_api($_SESSION['api']);
  1660. $usp = $user;
  1661. $fgshop = "";
  1662. $sid = "";
  1663. $user = explode('|', trim($user['shop'], '|'));
  1664. foreach ($user as $value) {
  1665. $fgshop .= " shop = " . $value . " or";
  1666. $sid .= " id = " . $value . " or";
  1667. }
  1668. }
  1669. $tc = $this->typeclass->find_all();
  1670. $typeclass = array();
  1671. foreach ($tc as $v) {
  1672. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1673. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1674. }
  1675. $post = $this->input->post(NULL, TRUE);
  1676. if (isset($post['sku'])) {
  1677. $list = array();
  1678. $num = "";
  1679. $title = "";
  1680. $features = "";
  1681. $order = $this->input->post('order', true);
  1682. $shop = $this->input->post('shop', true);
  1683. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1684. $sku = $this->input->post('sku', true);
  1685. $post['sm'] = $this->input->post('sm', true);
  1686. $post['warehouse'] = $this->input->post('warehouse', true);
  1687. $post['purchase'] = $this->input->post('purchase', true);
  1688. $post['retreatwarehouse'] = $post['warehouse'];
  1689. $post['state'] = $this->input->post('state', true);
  1690. $post['rktype'] = $this->input->post('rktype', true);
  1691. $post['text'] = $this->input->post('text', true);
  1692. $category = $this->input->post('category', true);
  1693. $list['category'] = $category;
  1694. $list['hairtype'] = $this->input->post('hairtype', true);
  1695. $list['grade'] = $this->input->post('grade', true);
  1696. $size = $this->input->post('size', true);
  1697. $xzsku = $this->input->post('xzsku', true);
  1698. $list['size'] = rtrim($size, ',');
  1699. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1700. $list['extension'] = $this->input->post('extension', true);
  1701. if ($category == 1297) {
  1702. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1703. }
  1704. if ($category == 1702) {
  1705. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1706. $list['syother'] = $this->input->post('syother', true);
  1707. }
  1708. if ($category == 133) {
  1709. $list['fittype'] = $this->input->post('fittype', true);
  1710. $list['acother'] = $this->input->post('acother', true);
  1711. }
  1712. $list['color'] = $this->input->post('color', true);
  1713. $list['lowe'] = $this->input->post('lowe', true);
  1714. if (!$post['purchase']) {
  1715. $post['purchase'] = 1;
  1716. }
  1717. if ($category == 127) {
  1718. $list['type'] = $this->input->post('type', true);
  1719. $list['headroad'] = $this->input->post('headroad', true);
  1720. $list['density'] = $this->input->post('density', true);
  1721. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1722. $list['lacesize'] = $this->input->post('lacesize', true);
  1723. }
  1724. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1725. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1726. }
  1727. if ($category == 128) {
  1728. $list['lacetype'] = $this->input->post('lacetype', true);
  1729. $list['haircap'] = $this->input->post('haircap', true);
  1730. $list['density'] = $this->input->post('density', true);
  1731. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1732. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1733. $list['wigother'] = $this->input->post('wigother', true);
  1734. $list['wigother1'] = $this->input->post('wigother1', true);
  1735. $list['wigother2'] = $this->input->post('wigother2', true);
  1736. }
  1737. if ($category == 129) {
  1738. $list['wide'] = $this->input->post('wide', true);
  1739. }
  1740. if ($category == 131) {
  1741. $list['gifttype'] = $this->input->post('gifttype', true);
  1742. $list['giftother'] = $this->input->post('giftother', true);
  1743. }
  1744. if ($category == 134) {
  1745. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1746. }
  1747. if ($category == 1297) {
  1748. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1749. $list['sywigother'] = $this->input->post('sywigother', true);
  1750. }
  1751. if ($category == 130 || $category == 133 || $category == 1702) {
  1752. $list['items'] = $this->input->post('items', true);
  1753. $list['weight'] = $this->input->post('weight', true);
  1754. }
  1755. if ($category == 1702) {
  1756. $list['syhairther'] = $this->input->post('syhairther', true);
  1757. }
  1758. $classid = $this->classid->sku();
  1759. $scsku = $classid;
  1760. $pm = $classid;
  1761. foreach ($list as $k => $v) {
  1762. if ($v != 0) {
  1763. $num .= $v;
  1764. $features .= $v . '-';
  1765. $post[$k] = $v;
  1766. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1767. if ($k != 'size') {
  1768. $title .= $typeclass[$v]['title'] . " ";
  1769. }
  1770. if (isset($pm[$typeclass[$v]['classid']])) {
  1771. if ($typeclass[$v]['title'] == '9A') {
  1772. $pm[$typeclass[$v]['classid']] = '9A';
  1773. } else if ($typeclass[$v]['title'] == '10A') {
  1774. $pm[$typeclass[$v]['classid']] = '10A';
  1775. } else {
  1776. $clzh = $typeclass[$v]['zh'];
  1777. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1778. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1779. $clzh = $clzh[0];
  1780. }
  1781. $pm[$typeclass[$v]['classid']] = $clzh;
  1782. }
  1783. }
  1784. }
  1785. }
  1786. $zh = implode(" ", $pm);
  1787. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1788. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1789. if ($list['size']) {
  1790. $typeclass = $this->typeclass->read($list['size']);
  1791. $title .= $typeclass['title'];
  1792. }
  1793. $time = time();
  1794. if ($xzsku) {
  1795. $scsku = implode("-", $scsku);
  1796. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1797. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1798. $post['sku'] = trim($scsku, ' ');
  1799. } else {
  1800. $post['sku'] = $sku;
  1801. }
  1802. //$post['sku'] = trim($sku,' ');
  1803. $post['title'] = rtrim($title, ' ');
  1804. $post['number'] = $num;
  1805. $post['features'] = '-' . $features;
  1806. $post['enter'] = $time;
  1807. $post['time'] = $time; //操作时间
  1808. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1809. if ($yza) {
  1810. if ($post['features'] != $yza[0]['features']) {
  1811. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1812. exit;
  1813. }
  1814. }
  1815. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1816. if ($yzb) {
  1817. if ($post['sku'] != $yzb[0]['sku']) {
  1818. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1819. exit;
  1820. }
  1821. }
  1822. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1823. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1824. exit;
  1825. }
  1826. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1827. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1828. exit;
  1829. }
  1830. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1831. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1832. exit;
  1833. }
  1834. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1835. if (isset($yz[0]['type'])) {
  1836. $post['type'] = $yz[0]['type'];
  1837. }
  1838. if ($post['state'] == 9) //如果选择预设库存
  1839. {
  1840. $this->whlabel->insert($post);
  1841. } else {
  1842. /**
  1843. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1844. if($ljg == 1)
  1845. {
  1846. for($i=0;$i<$order;$i++)
  1847. {
  1848. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1849. $this->whlabel->insert($post);
  1850. }
  1851. }
  1852. **/
  1853. //if($post['warehouse'] == '5')
  1854. //{
  1855. //}
  1856. $yydata = $post;
  1857. $yydata['zh'] = $zh;
  1858. /**
  1859. $wl = $this->apiyy->get_cjlp($yydata);
  1860. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1861. {
  1862. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1863. }
  1864. if($wl['Data'][0]['m_isSucess'] != 1)
  1865. {
  1866. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1867. }
  1868. **/
  1869. for ($i = 0; $i < $order; $i++) {
  1870. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1871. $this->whlabel->insert($post);
  1872. }
  1873. }
  1874. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1875. exit;
  1876. }
  1877. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1878. $this->data['wlshop'] = $wlshop;
  1879. $this->_Template('whlabel_enteradd', $this->data);
  1880. }
  1881. //修改产品
  1882. public function _enteredit($arg_array)
  1883. {
  1884. $dt = 0;
  1885. if (isset($_SESSION['api'])) {
  1886. $user = $this->user->get_api($_SESSION['api']);
  1887. $usp = $user;
  1888. $fgshop = "";
  1889. $sid = "";
  1890. $user = explode('|', trim($user['shop'], '|'));
  1891. foreach ($user as $value) {
  1892. $fgshop .= " shop = " . $value . " or";
  1893. $sid .= " id = " . $value . " or";
  1894. }
  1895. }
  1896. $post = $this->input->post(NULL, TRUE);
  1897. if (isset($post['sku'])) {
  1898. $list = array();
  1899. $num = "";
  1900. $title = "";
  1901. $features = "";
  1902. $id = $this->input->post('id', true);
  1903. $order = $this->input->post('order', true);
  1904. $shop = $this->input->post('shop', true);
  1905. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1906. $post['sku'] = $this->input->post('sku', true);
  1907. $post['sm'] = $this->input->post('sm', true);
  1908. $post['warehouse'] = $this->input->post('warehouse', true);
  1909. $post['purchase'] = $this->input->post('purchase', true);
  1910. $post['retreatwarehouse'] = $post['warehouse'];
  1911. $category = $this->input->post('category', true);
  1912. $list['category'] = $category;
  1913. $list['hairtype'] = $this->input->post('hairtype', true);
  1914. $list['grade'] = $this->input->post('grade', true);
  1915. $size = $this->input->post('size', true);
  1916. $list['size'] = rtrim($size, ',');
  1917. $post['rktype'] = $this->input->post('rktype', true);
  1918. $post['text'] = $this->input->post('text', true);
  1919. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1920. $list['extension'] = $this->input->post('extension', true);
  1921. if ($category == 1297) {
  1922. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1923. }
  1924. if ($category == 1702) {
  1925. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1926. $list['syother'] = $this->input->post('syother', true);
  1927. }
  1928. if ($category == 133) {
  1929. $list['fittype'] = $this->input->post('fittype', true);
  1930. $list['acother'] = $this->input->post('acother', true);
  1931. }
  1932. $list['color'] = $this->input->post('color', true);
  1933. $list['lowe'] = $this->input->post('lowe', true);
  1934. if (!$post['purchase']) {
  1935. $post['purchase'] = 1;
  1936. }
  1937. if ($category == 127) {
  1938. $list['type'] = $this->input->post('type', true);
  1939. $list['headroad'] = $this->input->post('headroad', true);
  1940. $list['density'] = $this->input->post('density', true);
  1941. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1942. $list['lacesize'] = $this->input->post('lacesize', true);
  1943. }
  1944. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1945. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1946. }
  1947. if ($category == 128) {
  1948. $list['lacetype'] = $this->input->post('lacetype', true);
  1949. $list['haircap'] = $this->input->post('haircap', true);
  1950. $list['density'] = $this->input->post('density', true);
  1951. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1952. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1953. $list['wigother'] = $this->input->post('wigother', true);
  1954. $list['wigother1'] = $this->input->post('wigother1', true);
  1955. $list['wigother2'] = $this->input->post('wigother2', true);
  1956. }
  1957. if ($category == 129) {
  1958. $list['wide'] = $this->input->post('wide', true);
  1959. }
  1960. if ($category == 131) {
  1961. $list['gifttype'] = $this->input->post('gifttype', true);
  1962. $list['giftother'] = $this->input->post('giftother', true);
  1963. }
  1964. if ($category == 134) {
  1965. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1966. }
  1967. if ($category == 1297) {
  1968. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1969. $list['sywigother'] = $this->input->post('sywigother', true);
  1970. }
  1971. if ($category == 130 || $category == 133 || $category == 1702) {
  1972. $list['items'] = $this->input->post('items', true);
  1973. $list['weight'] = $this->input->post('weight', true);
  1974. }
  1975. if ($category == 1702) {
  1976. $list['syhairther'] = $this->input->post('syhairther', true);
  1977. }
  1978. foreach ($list as $k => $v) {
  1979. if ($v != 0) {
  1980. $num .= $v;
  1981. $features .= $v . '-';
  1982. $typeclass = $this->typeclass->read($v);
  1983. if ($k != 'size') {
  1984. $title .= $typeclass['title'] . " ";
  1985. }
  1986. }
  1987. }
  1988. $typeclass = $this->typeclass->read($list['size']);
  1989. $title .= $typeclass['title'];
  1990. $time = time();
  1991. $post['title'] = rtrim($title, ' ');
  1992. $post['number'] = $num;
  1993. $post['features'] = '-' . $features;
  1994. $post['time'] = $time; //操作时间
  1995. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1996. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1997. exit;
  1998. }
  1999. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2000. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2001. exit;
  2002. }
  2003. $uid = $this->whlabel->read($id);
  2004. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2005. if ($datanum > 0) {
  2006. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2007. exit;
  2008. }
  2009. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2010. {
  2011. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2012. if ($yza) {
  2013. if ($post['features'] != $yza[0]['features']) {
  2014. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2015. exit;
  2016. }
  2017. }
  2018. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2019. if ($yzb) {
  2020. if ($post['sku'] != $yzb[0]['sku']) {
  2021. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2022. exit;
  2023. }
  2024. }
  2025. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2026. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2027. exit;
  2028. }
  2029. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2030. foreach ($data as $v) {
  2031. $post['id'] = $v['id'];
  2032. $this->whlabel->save($post, $v['id']);
  2033. }
  2034. } else {
  2035. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2036. if ($data > 0) {
  2037. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2038. exit;
  2039. } else {
  2040. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2041. foreach ($data as $v) {
  2042. $post['id'] = $v['id'];
  2043. $this->whlabel->save($post, $v['id']);
  2044. }
  2045. }
  2046. }
  2047. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2048. exit;
  2049. }
  2050. $uid = $this->whlabel->read($arg_array[0]);
  2051. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2052. $this->data['enter'] = $uid;
  2053. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2054. $this->data['wlshop'] = $wlshop;
  2055. $this->_Template('whlabel_enteredit', $this->data);
  2056. }
  2057. //入库浏览
  2058. public function _enter()
  2059. {
  2060. $post = $this->input->post(NULL, TRUE);
  2061. if (isset($post['s'])) {
  2062. $id_arr = $this->input->post('s');
  2063. $id_arr = explode(',', $id_arr);
  2064. if (!$id_arr) {
  2065. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2066. exit;
  2067. }
  2068. //循环删除记录
  2069. foreach ($id_arr as $v) {
  2070. $sid = $this->whlabel->read($v);
  2071. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2072. if ($count > 0) {
  2073. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2074. exit;
  2075. }
  2076. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2077. foreach ($info_list as $va) {
  2078. $this->whlabel->remove($va['id']);
  2079. }
  2080. }
  2081. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2082. exit;
  2083. }
  2084. $sp = array();
  2085. $s = $this->shop->find_all('1=1', 'id,shopname');
  2086. foreach ($s as $v) {
  2087. $sp[$v['id']] = $v['shopname'];
  2088. }
  2089. $wh = array();
  2090. $w = $this->warehouse->find_all('1=1', 'id,title');
  2091. foreach ($w as $v) {
  2092. $wh[$v['id']] = $v['title'];
  2093. }
  2094. if (isset($post['page'])) {
  2095. $page = $this->input->post('page', true);
  2096. $perpage = $this->input->post('perpage', true);
  2097. $category = $this->input->post('category', true);
  2098. $size = $this->input->post('size', true);
  2099. $grade = $this->input->post('grade', true);
  2100. $color = $this->input->post('color', true);
  2101. $lowe = $this->input->post('lowe', true);
  2102. $sku = $this->input->post('sku', true);
  2103. $warehouse = $this->input->post('warehouse', true);
  2104. $purchase = $this->input->post('purchase', true);
  2105. $ktime = $this->input->post('ktime', true);
  2106. $jtime = $this->input->post('jtime', true);
  2107. $ktime = strtotime($ktime);
  2108. $jtime = strtotime($jtime);
  2109. $where = "1=1";
  2110. $gj = "";
  2111. $ck = "";
  2112. if ($category) {
  2113. $where .= " and features like '%-$category-%'";
  2114. }
  2115. if ($size) {
  2116. $where .= " and features like '%-$size-%'";
  2117. }
  2118. if ($grade) {
  2119. $where .= " and features like '%-$grade-%'";
  2120. }
  2121. if ($color) {
  2122. $where .= " and features like '%-$color-%'";
  2123. }
  2124. if ($lowe) {
  2125. $where .= " and features like '%-$lowe-%'";
  2126. }
  2127. if ($warehouse) {
  2128. $where .= " and warehouse = '$warehouse'";
  2129. }
  2130. if ($purchase) {
  2131. $where .= " and purchase = '$purchase'";
  2132. }
  2133. if ($sku) {
  2134. $where .= " and sku like '%$sku%'";
  2135. }
  2136. if ($ktime && $jtime) {
  2137. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2138. }
  2139. //数据排序
  2140. $order_str = "enter desc";
  2141. if (empty($page)) {
  2142. $start = 0;
  2143. $perpage = 1;
  2144. } else {
  2145. $start = ($page - 1) * $perpage;
  2146. }
  2147. //取得信息列表
  2148. $info_list = $this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2149. foreach ($info_list as $k => $v) {
  2150. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2151. if ($v['shop'] == '') {
  2152. $s = '通用';
  2153. } else {
  2154. $info_list[$k]['shop'] = '';
  2155. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2156. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2157. }
  2158. }
  2159. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2160. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2161. $info_list[$k]['g'] = $g;
  2162. }
  2163. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2164. $pagenum = ceil($total / $perpage);
  2165. $over = $total - ($start + $perpage);
  2166. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2167. echo json_encode($rows);
  2168. exit;
  2169. }
  2170. $this->_Template('whlabel_enter', $this->data);
  2171. }
  2172. //出库浏览
  2173. public function _out()
  2174. {
  2175. $post = $this->input->post(NULL, TRUE);
  2176. if (isset($post['page'])) {
  2177. $page = $this->input->post('page', true);
  2178. $perpage = $this->input->post('perpage', true);
  2179. $category = $this->input->post('category', true);
  2180. $size = $this->input->post('size', true);
  2181. $grade = $this->input->post('grade', true);
  2182. $color = $this->input->post('color', true);
  2183. $lowe = $this->input->post('lowe', true);
  2184. $sku = $this->input->post('sku', true);
  2185. $warehouse = $this->input->post('warehouse', true);
  2186. $purchase = $this->input->post('purchase', true);
  2187. $state = $this->input->post('state', true);
  2188. $ktime = $this->input->post('ktime', true);
  2189. $jtime = $this->input->post('jtime', true);
  2190. $ktime = strtotime($ktime);
  2191. $jtime = strtotime($jtime);
  2192. $where = "state=3";
  2193. $gj = "";
  2194. $ck = "";
  2195. if ($category) {
  2196. $where .= " and features like '%-$category-%'";
  2197. }
  2198. if ($size) {
  2199. $where .= " and features like '%-$size-%'";
  2200. }
  2201. if ($grade) {
  2202. $where .= " and features like '%-$grade-%'";
  2203. }
  2204. if ($color) {
  2205. $where .= " and features like '%-$color-%'";
  2206. }
  2207. if ($lowe) {
  2208. $where .= " and features like '%-$lowe-%'";
  2209. }
  2210. if ($state) {
  2211. $where .= " and state = '$state'";
  2212. }
  2213. if ($warehouse) {
  2214. $where .= " and warehouse = '$warehouse'";
  2215. }
  2216. if ($purchase) {
  2217. $where .= " and purchase = '$purchase'";
  2218. }
  2219. if ($sku) {
  2220. $where .= " and sku = '$sku'";
  2221. }
  2222. if ($ktime && $jtime) {
  2223. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2224. }
  2225. //数据排序
  2226. $order_str = "id desc";
  2227. if (empty($page)) {
  2228. $start = 0;
  2229. $perpage = 1;
  2230. } else {
  2231. $start = ($page - 1) * $perpage;
  2232. }
  2233. //取得信息列表
  2234. $info_list = $this->whlabel->find_all($where, 'sku');
  2235. $rows = array();
  2236. $list = array();
  2237. foreach ($info_list as $key => $value) {
  2238. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2239. }
  2240. $rows = array_unique($rows); //删除重复记录
  2241. foreach ($rows as $key => $value) {
  2242. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2243. $ck = $this->warehouse->read($data['warehouse']);
  2244. $warehouse = $ck['title'];
  2245. $gy = $this->purchase->read($data['purchase']);
  2246. $purchase = $gy['purchase'];
  2247. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2248. $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);
  2249. }
  2250. $total = count($list);
  2251. $pagenum = ceil($total / $perpage);
  2252. $over = $total - ($start + $perpage);
  2253. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2254. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2255. echo json_encode($rows);
  2256. exit;
  2257. }
  2258. $this->_Template('whlabel_out', $this->data);
  2259. }
  2260. //出库标签浏览
  2261. public function _label()
  2262. {
  2263. $post = $this->input->post(NULL, TRUE);
  2264. if (isset($post['page'])) {
  2265. $page = $this->input->post('page', true);
  2266. $perpage = $this->input->post('perpage', true);
  2267. $sku = $this->input->post('sku', true);
  2268. $warehouse = $this->input->post('warehouse', true);
  2269. $purchase = $this->input->post('purchase', true);
  2270. $orderinfo = $this->input->post('orderinfo', true);
  2271. $waybill = $this->input->post('waybill', true);
  2272. $category = $this->input->post('category', true);
  2273. $size = $this->input->post('size', true);
  2274. $grade = $this->input->post('grade', true);
  2275. $color = $this->input->post('color', true);
  2276. $lowe = $this->input->post('lowe', true);
  2277. $where = "state=1";
  2278. if ($sku) {
  2279. $where .= " and sku = '$sku'";
  2280. }
  2281. if ($warehouse) {
  2282. $where .= " and warehouse = '$warehouse'";
  2283. }
  2284. if ($purchase) {
  2285. $where .= " and purchase = '$purchase'";
  2286. }
  2287. if ($orderinfo) {
  2288. $where .= " and orderinfo = '$orderinfo'";
  2289. }
  2290. if ($waybill) {
  2291. $where .= " and waybill = '$waybill'";
  2292. }
  2293. if ($category) {
  2294. $where .= " and features like '%-$category-%'";
  2295. }
  2296. if ($size) {
  2297. $where .= " and features like '%-$size-%'";
  2298. }
  2299. if ($grade) {
  2300. $where .= " and features like '%-$grade-%'";
  2301. }
  2302. if ($color) {
  2303. $where .= " and features like '%-$color-%'";
  2304. }
  2305. if ($lowe) {
  2306. $where .= " and features like '%-$lowe-%'";
  2307. }
  2308. //数据排序
  2309. $order_str = "outk desc";
  2310. if (empty($page)) {
  2311. $start = 0;
  2312. $perpage = 1;
  2313. } else {
  2314. $start = ($page - 1) * $perpage;
  2315. }
  2316. //取得信息列表
  2317. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2318. foreach ($info_list as $key => $value) {
  2319. $warehouse = $this->warehouse->read($value['warehouse']);
  2320. $info_list[$key]['warehouse'] = $warehouse['title'];
  2321. $purchase = $this->purchase->read($value['purchase']);
  2322. $info_list[$key]['purchase'] = $purchase['title'];
  2323. if ($value['outk'] != 0) {
  2324. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2325. } else {
  2326. $info_list[$key]['outk'] = "";
  2327. }
  2328. if ($value['orderinfo'] == 0) {
  2329. $info_list[$key]['orderinfo'] = "";
  2330. }
  2331. if ($value['waybill'] == 0) {
  2332. $info_list[$key]['waybill'] = "";
  2333. }
  2334. }
  2335. $total = $this->whlabel->find_count($where);
  2336. $pagenum = ceil($total / $perpage);
  2337. $over = $total - ($start + $perpage);
  2338. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2339. echo json_encode($rows);
  2340. exit;
  2341. }
  2342. $this->_Template('whlabel_label', $this->data);
  2343. }
  2344. //独立站出库订单
  2345. public function _outorder()
  2346. {
  2347. if (isset($_SESSION['api'])) {
  2348. $user = $this->user->get_api($_SESSION['api']);
  2349. $usp = $user;
  2350. $fgshop = "";
  2351. $sid = "";
  2352. $user = explode('|', trim($user['shop'], '|'));
  2353. foreach ($user as $value) {
  2354. $fgshop .= " shop = " . $value . " or";
  2355. $sid .= " id = " . $value . " or";
  2356. }
  2357. } else {
  2358. echo "请重新登录";
  2359. }
  2360. $post = $this->input->post(NULL, TRUE);
  2361. if (isset($post['page'])) {
  2362. $page = $this->input->post('page', true);
  2363. $perpage = $this->input->post('perpage', true);
  2364. $warehouse = $this->input->post('warehouse', true);
  2365. $xztime = $this->input->post('xztime', true);
  2366. $timetk = $this->input->post('timetkk', true);
  2367. $timetj = $this->input->post('timetjj', true);
  2368. $shop = $this->input->post('shop', true);
  2369. $source = $this->input->post('source', true);
  2370. $orderinfo = $this->input->post('orderinfo', true);
  2371. $number = $this->input->post('number', true);
  2372. $sfxh = $this->input->post('sfxh', true);
  2373. $express = $this->input->post('express', true);
  2374. $waybill = $this->input->post('waybill', true);
  2375. $library = $this->input->post('library', true);
  2376. $country = $this->input->post('country', true);
  2377. $so = $this->input->post('so', true);
  2378. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2379. $print = $this->input->post('print', true);
  2380. $state = $this->input->post('state', true);
  2381. $orderurl = $this->input->post('orderurl', true);
  2382. $timetk = strtotime($timetk);
  2383. $timetj = strtotime($timetj);
  2384. /**
  2385. $sj = $this->input->post('sj',true);
  2386. if($sj)
  2387. {
  2388. $sj = $this->input->post('sj',true);
  2389. }
  2390. else
  2391. {
  2392. $sj = "fullorder";
  2393. }
  2394. **/
  2395. $sj = "fullorder";
  2396. $where = "1=1";
  2397. if ($warehouse) {
  2398. $where .= " and type = '$warehouse'";
  2399. }
  2400. if ($timetk && $timetj) {
  2401. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2402. }
  2403. if ($orderinfo) {
  2404. $where .= " and orderinfo = '$orderinfo'";
  2405. }
  2406. if ($number) {
  2407. $where .= " and number = '$number'";
  2408. }
  2409. if ($express) {
  2410. $where .= " and express = '$express'";
  2411. }
  2412. if ($waybill) {
  2413. $where .= " and waybill = '$waybill'";
  2414. }
  2415. if ($library) {
  2416. $where .= " and library = '$library'";
  2417. }
  2418. if ($print) {
  2419. $where .= " and print = '$print'";
  2420. }
  2421. if ($libraryconfirm) {
  2422. $where .= " and libraryconfirm = '$libraryconfirm'";
  2423. }
  2424. if ($state) {
  2425. $where .= " and state = '$state'";
  2426. }
  2427. if ($shop) {
  2428. $where .= " and shop = '$shop'";
  2429. }
  2430. if ($country) {
  2431. $where .= " and country = '$country'";
  2432. }
  2433. if ($sfxh != '') {
  2434. $where .= " and sfxh = '$sfxh'";
  2435. }
  2436. if ($so) {
  2437. $where .= " and shipremarks like '%$so%'";
  2438. }
  2439. if ($source) {
  2440. if ($source == '2d') {
  2441. $where .= " and source >= '2'";
  2442. } else {
  2443. $where .= " and source = '$source'";
  2444. }
  2445. }
  2446. if (isset($_SESSION['api'])) {
  2447. foreach ($user as $value) {
  2448. $fgshop .= " shop = " . $value . " or";
  2449. }
  2450. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2451. }
  2452. if ($orderurl) {
  2453. $url = $this->orderurl->read($orderurl);
  2454. $where .= " and link like '%" . $url['url'] . "%'";
  2455. }
  2456. //数据排序
  2457. $order_str = "librarytime desc";
  2458. if (empty($page)) {
  2459. $start = 0;
  2460. $perpage = 1;
  2461. } else {
  2462. $start = ($page - 1) * $perpage;
  2463. }
  2464. //取得信息列表
  2465. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2466. //格式化数据
  2467. foreach ($info_list as $key => $value) {
  2468. $shop = $this->shop->read($value['shop']);
  2469. $info_list[$key]['shop'] = $shop['shopname'];
  2470. $express = $this->express->read($value['express']);
  2471. $info_list[$key]['express'] = $express['servicename'];
  2472. $warehouse = $this->warehouse->read($value['type']);
  2473. $info_list[$key]['type'] = $warehouse['title'];
  2474. if ($value['librarytime'] == '0') {
  2475. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2476. } else {
  2477. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2478. }
  2479. }
  2480. $total = $this->$sj->find_count($where);
  2481. $pagenum = ceil($total / $perpage);
  2482. $over = $total - ($start + $perpage);
  2483. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2484. echo json_encode($rows);
  2485. exit;
  2486. }
  2487. $this->data['express'] = $this->express->find_all();
  2488. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2489. $this->data['wlshop'] = $wlshop;
  2490. $user = $this->user->get_api($_SESSION['api']);
  2491. $powerid = $this->power->read($user['power']);
  2492. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2493. $pid = '';
  2494. foreach ($powertext as $v) {
  2495. $pid .= " id = " . $v . " or";
  2496. }
  2497. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2498. $this->data['fullorderexcel'] = $fullorderexcel;
  2499. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2500. $this->data['orderurl'] = $orderurl;
  2501. $this->_Template('whlabel_outorder', $this->data);
  2502. }
  2503. //tt出库
  2504. public function _toutorder()
  2505. {
  2506. if (isset($_SESSION['api'])) {
  2507. $user = $this->user->get_api($_SESSION['api']);
  2508. $usp = $user;
  2509. $fgshop = "";
  2510. $sid = "";
  2511. $user = explode('|', trim($user['shop'], '|'));
  2512. foreach ($user as $value) {
  2513. $fgshop .= " shop = " . $value . " or";
  2514. $sid .= " id = " . $value . " or";
  2515. }
  2516. } else {
  2517. echo "请重新登录";
  2518. }
  2519. $post = $this->input->post(NULL, TRUE);
  2520. if (isset($post['page'])) {
  2521. $page = $this->input->post('page', true);
  2522. $perpage = $this->input->post('perpage', true);
  2523. $warehouse = $this->input->post('warehouse', true);
  2524. $xztime = $this->input->post('xztime', true);
  2525. $timetk = $this->input->post('timetkk', true);
  2526. $timetj = $this->input->post('timetjj', true);
  2527. $shop = $this->input->post('shop', true);
  2528. $source = $this->input->post('source', true);
  2529. $orderinfo = $this->input->post('orderinfo', true);
  2530. $number = $this->input->post('number', true);
  2531. $sfxh = $this->input->post('sfxh', true);
  2532. $express = $this->input->post('express', true);
  2533. $waybill = $this->input->post('waybill', true);
  2534. $library = $this->input->post('library', true);
  2535. $country = $this->input->post('country', true);
  2536. $so = $this->input->post('so', true);
  2537. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2538. $print = $this->input->post('print', true);
  2539. $state = $this->input->post('state', true);
  2540. $orderurl = $this->input->post('orderurl', true);
  2541. $timetk = strtotime($timetk);
  2542. $timetj = strtotime($timetj);
  2543. /**
  2544. $sj = $this->input->post('sj',true);
  2545. if($sj)
  2546. {
  2547. $sj = $this->input->post('sj',true);
  2548. }
  2549. else
  2550. {
  2551. $sj = "fullorder";
  2552. }
  2553. **/
  2554. $sj = "fullordertt";
  2555. $where = "1=1";
  2556. if ($warehouse) {
  2557. $where .= " and type = '$warehouse'";
  2558. }
  2559. if ($timetk && $timetj) {
  2560. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2561. }
  2562. if ($orderinfo) {
  2563. $where .= " and orderinfo = '$orderinfo'";
  2564. }
  2565. if ($number) {
  2566. $where .= " and number = '$number'";
  2567. }
  2568. if ($express) {
  2569. $where .= " and express = '$express'";
  2570. }
  2571. if ($waybill) {
  2572. $where .= " and waybill = '$waybill'";
  2573. }
  2574. if ($library) {
  2575. $where .= " and library = '$library'";
  2576. }
  2577. if ($print) {
  2578. $where .= " and print = '$print'";
  2579. }
  2580. if ($libraryconfirm) {
  2581. $where .= " and libraryconfirm = '$libraryconfirm'";
  2582. }
  2583. if ($state) {
  2584. $where .= " and state = '$state'";
  2585. }
  2586. if ($shop) {
  2587. $where .= " and shop = '$shop'";
  2588. }
  2589. if ($country) {
  2590. $where .= " and country = '$country'";
  2591. }
  2592. if ($sfxh != '') {
  2593. $where .= " and sfxh = '$sfxh'";
  2594. }
  2595. if ($so) {
  2596. $where .= " and shipremarks like '%$so%'";
  2597. }
  2598. if ($source) {
  2599. if ($source == '2d') {
  2600. $where .= " and source >= '2'";
  2601. } else {
  2602. $where .= " and source = '$source'";
  2603. }
  2604. }
  2605. if (isset($_SESSION['api'])) {
  2606. foreach ($user as $value) {
  2607. $fgshop .= " shop = " . $value . " or";
  2608. }
  2609. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2610. }
  2611. if ($orderurl) {
  2612. $url = $this->orderurl->read($orderurl);
  2613. $where .= " and link like '%" . $url['url'] . "%'";
  2614. }
  2615. //数据排序
  2616. $order_str = "librarytime desc";
  2617. if (empty($page)) {
  2618. $start = 0;
  2619. $perpage = 1;
  2620. } else {
  2621. $start = ($page - 1) * $perpage;
  2622. }
  2623. //取得信息列表
  2624. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2625. //格式化数据
  2626. foreach ($info_list as $key => $value) {
  2627. $shop = $this->shop->read($value['shop']);
  2628. $info_list[$key]['shop'] = $shop['shopname'];
  2629. $express = $this->express->read($value['express']);
  2630. $info_list[$key]['express'] = $express['servicename'];
  2631. $warehouse = $this->warehouse->read($value['type']);
  2632. $info_list[$key]['type'] = $warehouse['title'];
  2633. if ($value['librarytime'] == '0') {
  2634. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2635. } else {
  2636. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2637. }
  2638. }
  2639. $total = $this->$sj->find_count($where);
  2640. $pagenum = ceil($total / $perpage);
  2641. $over = $total - ($start + $perpage);
  2642. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2643. echo json_encode($rows);
  2644. exit;
  2645. }
  2646. $this->data['express'] = $this->express->find_all();
  2647. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2648. $this->data['wlshop'] = $wlshop;
  2649. $user = $this->user->get_api($_SESSION['api']);
  2650. $powerid = $this->power->read($user['power']);
  2651. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2652. $pid = '';
  2653. foreach ($powertext as $v) {
  2654. $pid .= " id = " . $v . " or";
  2655. }
  2656. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2657. $this->data['fullorderexcel'] = $fullorderexcel;
  2658. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2659. $this->data['orderurl'] = $orderurl;
  2660. $this->_Template('whlabel_toutorder', $this->data);
  2661. }
  2662. //tt出库
  2663. public function _aoutorder()
  2664. {
  2665. if (isset($_SESSION['api'])) {
  2666. $user = $this->user->get_api($_SESSION['api']);
  2667. $usp = $user;
  2668. $fgshop = "";
  2669. $sid = "";
  2670. $user = explode('|', trim($user['shop'], '|'));
  2671. foreach ($user as $value) {
  2672. $fgshop .= " shop = " . $value . " or";
  2673. $sid .= " id = " . $value . " or";
  2674. }
  2675. } else {
  2676. echo "请重新登录";
  2677. }
  2678. $post = $this->input->post(NULL, TRUE);
  2679. if (isset($post['page'])) {
  2680. $page = $this->input->post('page', true);
  2681. $perpage = $this->input->post('perpage', true);
  2682. $warehouse = $this->input->post('warehouse', true);
  2683. $xztime = $this->input->post('xztime', true);
  2684. $timetk = $this->input->post('timetkk', true);
  2685. $timetj = $this->input->post('timetjj', true);
  2686. $shop = $this->input->post('shop', true);
  2687. $source = $this->input->post('source', true);
  2688. $orderinfo = $this->input->post('orderinfo', true);
  2689. $number = $this->input->post('number', true);
  2690. $sfxh = $this->input->post('sfxh', true);
  2691. $express = $this->input->post('express', true);
  2692. $waybill = $this->input->post('waybill', true);
  2693. $library = $this->input->post('library', true);
  2694. $country = $this->input->post('country', true);
  2695. $so = $this->input->post('so', true);
  2696. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2697. $print = $this->input->post('print', true);
  2698. $state = $this->input->post('state', true);
  2699. $orderurl = $this->input->post('orderurl', true);
  2700. $timetk = strtotime($timetk);
  2701. $timetj = strtotime($timetj);
  2702. /**
  2703. $sj = $this->input->post('sj',true);
  2704. if($sj)
  2705. {
  2706. $sj = $this->input->post('sj',true);
  2707. }
  2708. else
  2709. {
  2710. $sj = "fullorder";
  2711. }
  2712. **/
  2713. $sj = "fullorderamz";
  2714. $where = "1=1";
  2715. if ($warehouse) {
  2716. $where .= " and type = '$warehouse'";
  2717. }
  2718. if ($timetk && $timetj) {
  2719. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2720. }
  2721. if ($orderinfo) {
  2722. $where .= " and orderinfo = '$orderinfo'";
  2723. }
  2724. if ($number) {
  2725. $where .= " and number = '$number'";
  2726. }
  2727. if ($express) {
  2728. $where .= " and express = '$express'";
  2729. }
  2730. if ($waybill) {
  2731. $where .= " and waybill = '$waybill'";
  2732. }
  2733. if ($library) {
  2734. $where .= " and library = '$library'";
  2735. }
  2736. if ($print) {
  2737. $where .= " and print = '$print'";
  2738. }
  2739. if ($libraryconfirm) {
  2740. $where .= " and libraryconfirm = '$libraryconfirm'";
  2741. }
  2742. if ($state) {
  2743. $where .= " and state = '$state'";
  2744. }
  2745. if ($shop) {
  2746. $where .= " and shop = '$shop'";
  2747. }
  2748. if ($country) {
  2749. $where .= " and country = '$country'";
  2750. }
  2751. if ($sfxh != '') {
  2752. $where .= " and sfxh = '$sfxh'";
  2753. }
  2754. if ($so) {
  2755. $where .= " and shipremarks like '%$so%'";
  2756. }
  2757. if ($source) {
  2758. if ($source == '2d') {
  2759. $where .= " and source >= '2'";
  2760. } else {
  2761. $where .= " and source = '$source'";
  2762. }
  2763. }
  2764. if (isset($_SESSION['api'])) {
  2765. foreach ($user as $value) {
  2766. $fgshop .= " shop = " . $value . " or";
  2767. }
  2768. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2769. }
  2770. if ($orderurl) {
  2771. $url = $this->orderurl->read($orderurl);
  2772. $where .= " and link like '%" . $url['url'] . "%'";
  2773. }
  2774. //数据排序
  2775. $order_str = "librarytime desc";
  2776. if (empty($page)) {
  2777. $start = 0;
  2778. $perpage = 1;
  2779. } else {
  2780. $start = ($page - 1) * $perpage;
  2781. }
  2782. //取得信息列表
  2783. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2784. //格式化数据
  2785. foreach ($info_list as $key => $value) {
  2786. $shop = $this->shop->read($value['shop']);
  2787. $info_list[$key]['shop'] = $shop['shopname'];
  2788. $express = $this->express->read($value['express']);
  2789. $info_list[$key]['express'] = $express['servicename'];
  2790. $warehouse = $this->warehouse->read($value['type']);
  2791. $info_list[$key]['type'] = $warehouse['title'];
  2792. if ($value['librarytime'] == '0') {
  2793. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2794. } else {
  2795. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2796. }
  2797. }
  2798. $total = $this->$sj->find_count($where);
  2799. $pagenum = ceil($total / $perpage);
  2800. $over = $total - ($start + $perpage);
  2801. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2802. echo json_encode($rows);
  2803. exit;
  2804. }
  2805. $this->data['express'] = $this->express->find_all();
  2806. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2807. $this->data['wlshop'] = $wlshop;
  2808. $user = $this->user->get_api($_SESSION['api']);
  2809. $powerid = $this->power->read($user['power']);
  2810. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2811. $pid = '';
  2812. foreach ($powertext as $v) {
  2813. $pid .= " id = " . $v . " or";
  2814. }
  2815. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2816. $this->data['fullorderexcel'] = $fullorderexcel;
  2817. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2818. $this->data['orderurl'] = $orderurl;
  2819. $this->_Template('whlabel_aoutorder', $this->data);
  2820. }
  2821. //速卖通出库订单
  2822. public function _soutorder()
  2823. {
  2824. if (isset($_SESSION['api'])) {
  2825. $user = $this->user->get_api($_SESSION['api']);
  2826. $usp = $user;
  2827. $fgshop = "";
  2828. $sid = "";
  2829. $user = explode('|', trim($user['shop'], '|'));
  2830. foreach ($user as $value) {
  2831. $sid .= " id = " . $value . " or";
  2832. }
  2833. }
  2834. $post = $this->input->post(NULL, TRUE);
  2835. if (isset($post['page'])) {
  2836. $page = $this->input->post('page', true);
  2837. $perpage = $this->input->post('perpage', true);
  2838. $warehouse = $this->input->post('warehouse', true);
  2839. $xztime = $this->input->post('xztime', true);
  2840. $timetk = $this->input->post('timetkk', true);
  2841. $timetj = $this->input->post('timetjj', true);
  2842. $shop = $this->input->post('shop', true);
  2843. $source = $this->input->post('source', true);
  2844. $orderinfo = $this->input->post('orderinfo', true);
  2845. $number = $this->input->post('number', true);
  2846. $express = $this->input->post('express', true);
  2847. $waybill = $this->input->post('waybill', true);
  2848. $library = $this->input->post('library', true);
  2849. $country = $this->input->post('country', true);
  2850. $sfxh = $this->input->post('sfxh', true);
  2851. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2852. $print = $this->input->post('print', true);
  2853. $state = $this->input->post('state', true);
  2854. $so = $this->input->post('so', true);
  2855. $timetk = strtotime($timetk);
  2856. $timetj = strtotime($timetj);
  2857. /**
  2858. $sj = $this->input->post('sj',true);
  2859. if($sj)
  2860. {
  2861. $sj = $this->input->post('sj',true);
  2862. }
  2863. else
  2864. {
  2865. $sj = "fullorder";
  2866. }
  2867. **/
  2868. $sj = "fullordersmt";
  2869. $where = "1=1";
  2870. if ($warehouse) {
  2871. $where .= " and type = '$warehouse'";
  2872. }
  2873. if ($timetk && $timetj) {
  2874. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2875. }
  2876. if ($orderinfo) {
  2877. $where .= " and orderinfo = '$orderinfo'";
  2878. }
  2879. if ($number) {
  2880. $where .= " and number = '$number'";
  2881. }
  2882. if ($express) {
  2883. $where .= " and express = '$express'";
  2884. }
  2885. if ($waybill) {
  2886. $where .= " and waybill = '$waybill'";
  2887. }
  2888. if ($library) {
  2889. $where .= " and library = '$library'";
  2890. }
  2891. if ($print) {
  2892. $where .= " and print = '$print'";
  2893. }
  2894. if ($libraryconfirm) {
  2895. $where .= " and libraryconfirm = '$libraryconfirm'";
  2896. }
  2897. if ($state) {
  2898. $where .= " and state = '$state'";
  2899. }
  2900. if ($shop) {
  2901. $where .= " and shop = '$shop'";
  2902. }
  2903. if ($sfxh != '') {
  2904. $where .= " and sfxh = '$sfxh'";
  2905. }
  2906. if ($so) {
  2907. $where .= " and shipremarks like '%$so%'";
  2908. }
  2909. if ($source) {
  2910. $where .= " and source = '$source'";
  2911. }
  2912. if ($country) {
  2913. $where .= " and country = '$country'";
  2914. } else {
  2915. if (isset($_SESSION['api'])) {
  2916. foreach ($user as $value) {
  2917. $fgshop .= " shop = " . $value . " or";
  2918. }
  2919. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2920. }
  2921. }
  2922. //数据排序
  2923. $order_str = "librarytime desc";
  2924. if (empty($page)) {
  2925. $start = 0;
  2926. $perpage = 1;
  2927. } else {
  2928. $start = ($page - 1) * $perpage;
  2929. }
  2930. //取得信息列表
  2931. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2932. //格式化数据
  2933. foreach ($info_list as $key => $value) {
  2934. $shop = $this->shop->read($value['shop']);
  2935. $info_list[$key]['shop'] = $shop['shopname'];
  2936. $express = $this->express->read($value['express']);
  2937. $info_list[$key]['express'] = $express['servicename'];
  2938. $warehouse = $this->warehouse->read($value['type']);
  2939. $info_list[$key]['type'] = $warehouse['title'];
  2940. if ($value['librarytime'] == '0') {
  2941. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2942. } else {
  2943. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2944. }
  2945. }
  2946. $total = $this->$sj->find_count($where);
  2947. $pagenum = ceil($total / $perpage);
  2948. $over = $total - ($start + $perpage);
  2949. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2950. echo json_encode($rows);
  2951. exit;
  2952. }
  2953. $this->data['express'] = $this->express->find_all();
  2954. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2955. $this->data['wlshop'] = $wlshop;
  2956. $user = $this->user->get_api($_SESSION['api']);
  2957. $powerid = $this->power->read($user['power']);
  2958. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2959. $pid = '';
  2960. foreach ($powertext as $v) {
  2961. $pid .= " id = " . $v . " or";
  2962. }
  2963. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2964. $this->data['fullorderexcel'] = $fullorderexcel;
  2965. $this->_Template('whlabel_soutorder', $this->data);
  2966. }
  2967. //订单退库
  2968. public function _retreat()
  2969. {
  2970. $post = $this->input->post(NULL, TRUE);
  2971. if (isset($post['page'])) {
  2972. $page = $this->input->post('page', true);
  2973. $perpage = $this->input->post('perpage', true);
  2974. $warehouse = $this->input->post('warehouse', true);
  2975. $timetk = $this->input->post('timetk', true);
  2976. $timetj = $this->input->post('timetj', true);
  2977. $shop = $this->input->post('shop', true);
  2978. $source = $this->input->post('source', true);
  2979. $state = $this->input->post('state', true);
  2980. $review = $this->input->post('review', true);
  2981. $state = $this->input->post('state', true);
  2982. $express = $this->input->post('express', true);
  2983. $orderinfo = $this->input->post('orderinfo', true);
  2984. $user = $this->input->post('user', true);
  2985. $name = $this->input->post('name', true);
  2986. $waybill = $this->input->post('waybill', true);
  2987. $timetk = strtotime($timetk);
  2988. $timetj = strtotime($timetj);
  2989. $where = "(state=206 or state=210) and mergeid = 0";
  2990. if ($warehouse) {
  2991. $where .= " and state = '$warehouse'";
  2992. }
  2993. if ($timetk && $timetj) {
  2994. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  2995. }
  2996. if ($shop) {
  2997. $where .= " and shop = '$shop'";
  2998. }
  2999. if ($source) {
  3000. $where .= " and source = '$source'";
  3001. }
  3002. if ($state) {
  3003. $where .= " and state = '$state'";
  3004. }
  3005. if ($review) {
  3006. $where .= " and review = '$review'";
  3007. }
  3008. if ($state) {
  3009. $where .= " and state = '$state'";
  3010. }
  3011. if ($express) {
  3012. $where .= " and express = '$express'";
  3013. }
  3014. if ($orderinfo) {
  3015. $where .= " and orderinfo = '$orderinfo'";
  3016. }
  3017. if ($user) {
  3018. $where .= " and user = '$user'";
  3019. }
  3020. if ($name) {
  3021. $where .= " and name = '$name'";
  3022. }
  3023. if ($waybill) {
  3024. $where .= " and waybill = '$waybill'";
  3025. }
  3026. //数据排序
  3027. $order_str = "id desc";
  3028. if (empty($page)) {
  3029. $start = 0;
  3030. $perpage = 1;
  3031. } else {
  3032. $start = ($page - 1) * $perpage;
  3033. }
  3034. //取得信息列表
  3035. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3036. //格式化数据
  3037. foreach ($info_list as $key => $value) {
  3038. $shop = $this->shop->read($value['shop']);
  3039. $info_list[$key]['shop'] = $shop['shopname'];
  3040. $warehouse = $this->warehouse->read($value['warehouse']);
  3041. $info_list[$key]['warehouse'] = $warehouse['title'];
  3042. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3043. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3044. if ($value['waybill'] == 0) {
  3045. $info_list[$key]['waybill'] = "";
  3046. }
  3047. $express = $this->express->read($value['express']);
  3048. $info_list[$key]['express'] = $express['title'];
  3049. $typeclass = $this->typeclass->read($value['state']);
  3050. $info_list[$key]['state'] = $typeclass['title'];
  3051. }
  3052. $total = $this->fullorder->find_count($where);
  3053. $pagenum = ceil($total / $perpage);
  3054. $over = $total - ($start + $perpage);
  3055. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3056. echo json_encode($rows);
  3057. exit;
  3058. }
  3059. $this->data['express'] = $this->express->find_all();
  3060. $this->_Template('whlabel_retreat', $this->data);
  3061. }
  3062. //退库标签浏览
  3063. public function _retreatlk()
  3064. {
  3065. $post = $this->input->post(NULL, TRUE);
  3066. if (isset($post['page'])) {
  3067. $page = $this->input->post('page', true);
  3068. $perpage = $this->input->post('perpage', true);
  3069. $timetk = $this->input->post('timetk', true);
  3070. $timetj = $this->input->post('timetj', true);
  3071. $sku = $this->input->post('sku', true);
  3072. $warehouse = $this->input->post('warehouse', true);
  3073. $purchase = $this->input->post('purchase', true);
  3074. $orderinfo = $this->input->post('orderinfo', true);
  3075. $waybill = $this->input->post('waybill', true);
  3076. $category = $this->input->post('category', true);
  3077. $size = $this->input->post('size', true);
  3078. $grade = $this->input->post('grade', true);
  3079. $color = $this->input->post('color', true);
  3080. $lowe = $this->input->post('lowe', true);
  3081. $state = $this->input->post('state', true);
  3082. $timetk = strtotime($timetk);
  3083. $timetj = strtotime($timetj);
  3084. $where = "state=2";
  3085. if ($timetk && $timetj) {
  3086. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3087. }
  3088. if ($sku) {
  3089. $where .= " and sku = '$sku'";
  3090. }
  3091. if ($warehouse) {
  3092. $where .= " and warehouse = '$warehouse'";
  3093. }
  3094. if ($purchase) {
  3095. $where .= " and purchase = '$purchase'";
  3096. }
  3097. if ($orderinfo) {
  3098. $where .= " and orderinfo = '$orderinfo'";
  3099. }
  3100. if ($waybill) {
  3101. $where .= " and waybill = '$waybill'";
  3102. }
  3103. if ($category) {
  3104. $where .= " and features like '%-$category-%'";
  3105. }
  3106. if ($size) {
  3107. $where .= " and features like '%-$size-%'";
  3108. }
  3109. if ($grade) {
  3110. $where .= " and features like '%-$grade-%'";
  3111. }
  3112. if ($color) {
  3113. $where .= " and features like '%-$color-%'";
  3114. }
  3115. if ($lowe) {
  3116. $where .= " and features like '%-$lowe-%'";
  3117. }
  3118. //数据排序
  3119. $order_str = "time desc";
  3120. if (empty($page)) {
  3121. $start = 0;
  3122. $perpage = 1;
  3123. } else {
  3124. $start = ($page - 1) * $perpage;
  3125. }
  3126. //取得信息列表
  3127. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3128. foreach ($info_list as $key => $value) {
  3129. $warehouse = $this->warehouse->read($value['warehouse']);
  3130. $info_list[$key]['warehouse'] = $warehouse['title'];
  3131. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3132. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3133. $purchase = $this->purchase->read($value['purchase']);
  3134. $info_list[$key]['purchase'] = $purchase['title'];
  3135. if ($value['outk'] != 0) {
  3136. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3137. } else {
  3138. $info_list[$key]['outk'] = "";
  3139. }
  3140. if ($value['retreat'] != 0) {
  3141. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3142. } else {
  3143. $info_list[$key]['retreat'] = "";
  3144. }
  3145. if ($value['orderinfo'] == 0) {
  3146. $info_list[$key]['orderinfo'] = "";
  3147. }
  3148. if ($value['waybill'] == 0) {
  3149. $info_list[$key]['waybill'] = "";
  3150. }
  3151. }
  3152. $total = $this->whlabel->find_count($where);
  3153. $pagenum = ceil($total / $perpage);
  3154. $over = $total - ($start + $perpage);
  3155. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3156. echo json_encode($rows);
  3157. exit;
  3158. }
  3159. $this->_Template('whlabel_retreatlk', $this->data);
  3160. }
  3161. //更换标签及浏览
  3162. public function _change()
  3163. {
  3164. $post = $this->input->post(NULL, TRUE);
  3165. if (isset($post['page'])) {
  3166. $page = $this->input->post('page', true);
  3167. $perpage = $this->input->post('perpage', true);
  3168. $timetk = $this->input->post('timetk', true);
  3169. $timetj = $this->input->post('timetj', true);
  3170. $label = $this->input->post('label', true);
  3171. $oldlabel = $this->input->post('oldlabel', true);
  3172. $timetk = strtotime($timetk);
  3173. $timetj = strtotime($timetj);
  3174. $where = "state=10 ";
  3175. if ($timetk && $timetj) {
  3176. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3177. }
  3178. if ($label) {
  3179. $where .= " and label = '$label'";
  3180. }
  3181. if ($oldlabel) {
  3182. $where .= " and oldlabel = '$oldlabel'";
  3183. }
  3184. //数据排序
  3185. $order_str = "time asc";
  3186. if (empty($page)) {
  3187. $start = 0;
  3188. $perpage = 1;
  3189. } else {
  3190. $start = ($page - 1) * $perpage;
  3191. }
  3192. //取得信息列表
  3193. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3194. foreach ($info_list as $key => $value) {
  3195. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3196. }
  3197. $total = $this->whlabel->find_count($where);
  3198. $pagenum = ceil($total / $perpage);
  3199. $over = $total - ($start + $perpage);
  3200. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3201. echo json_encode($rows);
  3202. exit;
  3203. }
  3204. $this->_Template('whlabel_change', $this->data);
  3205. }
  3206. //产品标签
  3207. public function _cpbqdc()
  3208. {
  3209. if (isset($_GET['excel'])) {
  3210. $where = "1=1";
  3211. //数据排序
  3212. $order_str = "id desc";
  3213. if (empty($page)) {
  3214. $start = 0;
  3215. $perpage = 1;
  3216. } else {
  3217. $start = ($page - 1) * $perpage;
  3218. }
  3219. $warehouse = $this->input->get('warehouse', true);
  3220. $state = $this->input->get('state', true);
  3221. $timetk = $this->input->get('timetkk', true);
  3222. $timetj = $this->input->get('timetjj', true);
  3223. $timetk = strtotime($timetk);
  3224. $timetj = strtotime($timetj);
  3225. if ($warehouse) {
  3226. $where .= " and warehouse = '$warehouse'";
  3227. }
  3228. if ($state || $state == 0) {
  3229. $where .= " and state = '$state'";
  3230. }
  3231. if ($timetk && $timetj) {
  3232. $where .= " and time > '$timetk' and time < '$timetj'";
  3233. }
  3234. //取得信息列表
  3235. $info_list = $this->whlabel->find_all($where, '*');
  3236. $rows = array();
  3237. $list = array();
  3238. foreach ($info_list as $key => $value) {
  3239. $rows[$value['time']] = $value; //所有数据sku
  3240. }
  3241. foreach ($rows as $value) {
  3242. $warehouse = $this->warehouse->read($value['warehouse']);
  3243. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3244. $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);
  3245. }
  3246. $title = "产品标签统计表";
  3247. $titlename = "<table border=1>
  3248. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3249. <tr align='center'>
  3250. <td>仓库</td>
  3251. <td>SKU</td>
  3252. <td>产品</td>
  3253. <td>入库时间</td>
  3254. <td>操作时间</td>
  3255. <td>备注</td>
  3256. <td>数量</td>
  3257. </tr>
  3258. </table>";
  3259. $filename = $title . ".xls";
  3260. $tail = "";
  3261. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3262. }
  3263. }
  3264. //进销存导出
  3265. public function _exceljxc()
  3266. {
  3267. $classid = $this->classid->sku();
  3268. $pm = $classid;
  3269. $typeclass = array();
  3270. $tc = $this->typeclass->find_all();
  3271. foreach ($tc as $v) {
  3272. $typeclass[$v['id']] = $v;
  3273. }
  3274. $prc = array();
  3275. $purchase = $this->purchase->find_all();
  3276. foreach ($purchase as $k => $v) {
  3277. $prc[$v['id']] = $v['title'];
  3278. }
  3279. if (isset($_GET['excel'])) {
  3280. $where = "sku != 'Preset'";
  3281. //数据排序
  3282. $order_str = "id desc";
  3283. if (empty($page)) {
  3284. $start = 0;
  3285. $perpage = 1;
  3286. } else {
  3287. $start = ($page - 1) * $perpage;
  3288. }
  3289. $category = $this->input->get('category', true);
  3290. $warehouse = $this->input->get('warehouse', true);
  3291. $excelid = $this->input->get('sid', true);
  3292. if ($category) {
  3293. $where .= " and features like '%-$category-%'";
  3294. }
  3295. if ($warehouse) {
  3296. $where .= " and warehouse = '$warehouse'";
  3297. }
  3298. $xzid = '';
  3299. if ($excelid) {
  3300. $excelid = explode(',', trim($excelid, ','));
  3301. foreach ($excelid as $key => $value) {
  3302. $xzid .= " id = " . $value . " or";
  3303. }
  3304. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3305. }
  3306. //取得信息列表
  3307. /**
  3308. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3309. $rows = array();$list = array();
  3310. foreach ($info_list as $key=>$value)
  3311. {
  3312. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3313. }
  3314. **/
  3315. $wt = array();
  3316. $whlabel_type = $this->whlabel_type->find_all();
  3317. foreach ($whlabel_type as $v) {
  3318. $wt[$v['id']] = $v['title'];
  3319. }
  3320. $wh = array();
  3321. $w = $this->warehouse->find_all('1=1', 'id,title');
  3322. foreach ($w as $v) {
  3323. $wh[$v['id']] = $v['title'];
  3324. }
  3325. $list = array();
  3326. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3327. foreach ($rows as $key => $value) {
  3328. if (isset($wt[$value['type']])) {
  3329. $rows[$key]['type'] = $wt[$value['type']];
  3330. } else {
  3331. $rows[$key]['type'] = '未设置';
  3332. }
  3333. $bm = '03';
  3334. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3335. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3336. $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');
  3337. $details = array();
  3338. $cpid = array();
  3339. $cpbz = array();
  3340. $c = 0;
  3341. $g = 0;
  3342. $x = 0;
  3343. $t = 0;
  3344. $s = 0;
  3345. $q = 0;
  3346. foreach ($sd as $k => $v) {
  3347. if ($v['state'] == 0) {
  3348. $c++;
  3349. if ($v['cpid'] != 0) {
  3350. $cpid[$v['cpid']] = $v['cpid'];
  3351. }
  3352. if ($v['cpbz'] != '') {
  3353. $cpbz[$v['cpbz']] = $v['cpbz'];
  3354. }
  3355. }
  3356. if ($v['state'] != 9) {
  3357. $g++;
  3358. }
  3359. if ($v['state'] == 1) {
  3360. $x++;
  3361. }
  3362. if ($v['state'] == 2) {
  3363. $t++;
  3364. }
  3365. if ($v['state'] == 8) {
  3366. $s++;
  3367. }
  3368. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3369. $q++;
  3370. }
  3371. $details[$v['details']] = $v['details'];
  3372. }
  3373. $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'] . '"');
  3374. $rows[$key]['details'] = implode("、", $details);
  3375. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3376. $number = $value['number'];
  3377. $ftime = time() - 15 * 24 * 3600;
  3378. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3379. $rows[$key]['number'] = $g;
  3380. $rows[$key]['c'] = $c;
  3381. $rows[$key]['x'] = $x;
  3382. $rows[$key]['t'] = $t;
  3383. $rows[$key]['s'] = $s;
  3384. $rows[$key]['q'] = $q;
  3385. $rows[$key]['z'] = $z;
  3386. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3387. $features = explode('-', trim($features, '-'));
  3388. $rows[$key]['dbcontent'] = $typeclass[$features[0]]['title'];
  3389. // $pm = $classid;
  3390. // $jm = $classid;
  3391. // foreach($features as $k=>$v)
  3392. // {
  3393. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3394. // {
  3395. // if($typeclass[$v]['bm'] != '')
  3396. // {
  3397. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3398. // }
  3399. // }
  3400. // if($v != 0)
  3401. // {
  3402. // if(!isset($typeclass[$v]))
  3403. // {
  3404. // continue;
  3405. // }
  3406. // if(isset($pm[$typeclass[$v]['classid']]))
  3407. // {
  3408. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3409. // {
  3410. // $tz = explode('|',$typeclass[$v]['zh']);
  3411. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3412. // }
  3413. // else
  3414. // {
  3415. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3416. // }
  3417. // }
  3418. // if(isset($jm[$typeclass[$v]['classid']]))
  3419. // {
  3420. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3421. // }
  3422. // }
  3423. // }
  3424. // $jm = array_filter($jm);
  3425. // $rows[$key]['bs'] = implode("-",$jm);
  3426. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3427. // $zh = implode(" ",$pm);
  3428. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3429. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3430. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3431. // $rows[$key]['features'] = $zh;
  3432. }
  3433. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3434. $final_list = [];
  3435. foreach ($list as $k => $v) {
  3436. if (empty($v['sku'])) {
  3437. continue;
  3438. }
  3439. $final_list[] = [
  3440. "warehouse" => $v["warehouse"],
  3441. "purchase" => $v["purchase"],
  3442. "details" => $v["details"],
  3443. "cpid" => $v["cpid"],
  3444. "dbcontent" => $v["dbcontent"],
  3445. "sku" => $v["sku"],
  3446. "cs" => $v["bm"],
  3447. "bs" => $v["jm"],
  3448. "title" => $v["title"],
  3449. "features" => $v["pm"],
  3450. "cpbz" => $v["cpbz"],
  3451. "sm" => $v["sm"],
  3452. "type" => $v["type"],
  3453. "number" => $v["number"],
  3454. "c" => $v["c"],
  3455. "x" => $v["x"],
  3456. "t" => $v["t"],
  3457. "s" => $v["s"],
  3458. "q" => $v["q"],
  3459. "z" => $v["z"],
  3460. "weight" => $v['weight'],
  3461. ];
  3462. }
  3463. $title = "总进销存统计表";
  3464. $titlename = "<table border=1>
  3465. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3466. <tr align='center'>
  3467. <td>仓库</td>
  3468. <td>供应商</td>
  3469. <td>位置</td>
  3470. <td>库存编码</td>
  3471. <td>类目</td>
  3472. <td>SKU</td>
  3473. <td>用友编码</td>
  3474. <td>用友料号</td>
  3475. <td>商品名称</td>
  3476. <td>商品中文</td>
  3477. <td>产品备注</td>
  3478. <td>说明</td>
  3479. <td>类型</td>
  3480. <td>入库总量</td>
  3481. <td>库存数量</td>
  3482. <td>销售数量</td>
  3483. <td>退货数量</td>
  3484. <td>删除数量</td>
  3485. <td>其它操作</td>
  3486. <td>占单数量</td>
  3487. <td>重量(g)</td>
  3488. </tr>
  3489. </table>";
  3490. $filename = $title . ".xls";
  3491. $tail = "";
  3492. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3493. }
  3494. }
  3495. //入库导出
  3496. public function _excelr()
  3497. {
  3498. if (isset($_GET['excel'])) {
  3499. $category = $this->input->get('category', true);
  3500. $size = $this->input->get('size', true);
  3501. $grade = $this->input->get('grade', true);
  3502. $color = $this->input->get('color', true);
  3503. $lowe = $this->input->get('lowe', true);
  3504. $sku = $this->input->get('sku', true);
  3505. $warehouse = $this->input->get('warehouse', true);
  3506. $purchase = $this->input->get('purchase', true);
  3507. $ktime = $this->input->get('ktime', true);
  3508. $jtime = $this->input->get('jtime', true);
  3509. $ktime = strtotime($ktime);
  3510. $jtime = strtotime($jtime);
  3511. $where = "1=1";
  3512. $gj = "";
  3513. $ck = "";
  3514. if ($category) {
  3515. $where .= " and features like '%-$category-%'";
  3516. }
  3517. if ($size) {
  3518. $where .= " and features like '%-$size-%'";
  3519. }
  3520. if ($grade) {
  3521. $where .= " and features like '%-$grade-%'";
  3522. }
  3523. if ($color) {
  3524. $where .= " and features like '%-$color-%'";
  3525. }
  3526. if ($lowe) {
  3527. $where .= " and features like '%-$lowe-%'";
  3528. }
  3529. if ($warehouse) {
  3530. $where .= " and warehouse = '$warehouse'";
  3531. }
  3532. if ($purchase) {
  3533. $where .= " and purchase = '$purchase'";
  3534. }
  3535. if ($sku) {
  3536. $where .= " and sku = '$sku'";
  3537. }
  3538. if ($ktime && $jtime) {
  3539. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3540. }
  3541. //数据排序
  3542. $order_str = "id desc";
  3543. if (empty($page)) {
  3544. $start = 0;
  3545. $perpage = 1;
  3546. } else {
  3547. $start = ($page - 1) * $perpage;
  3548. }
  3549. $list = array();
  3550. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3551. foreach ($rows as $value) {
  3552. $ck = $this->warehouse->read($value['warehouse']);
  3553. $warehouse = $ck['title'];
  3554. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3555. $retreatwarehouse = $tkck['title'];
  3556. $gy = $this->purchase->read($value['purchase']);
  3557. $purchase = $gy['title'];
  3558. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3559. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3560. }
  3561. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3562. $titlename = "<table border=1>
  3563. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3564. <tr align='center'>
  3565. <td>仓库</td>
  3566. <td>SKU</td>
  3567. <td>产品</td>
  3568. <td>时间</td>
  3569. <td>数量</td>
  3570. </tr>
  3571. </table>";
  3572. $filename = $title . ".xls";
  3573. $tail = "";
  3574. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3575. }
  3576. }
  3577. //出库、退库导出
  3578. public function _excelct()
  3579. {
  3580. $classid = $this->classid->sku();
  3581. $pm = $classid;
  3582. $typeclass = array();
  3583. $tc = $this->typeclass->find_all();
  3584. foreach ($tc as $v) {
  3585. $typeclass[$v['id']] = $v;
  3586. }
  3587. $prc = array();
  3588. $purchase = $this->purchase->find_all();
  3589. foreach ($purchase as $k => $v) {
  3590. $prc[$v['id']] = $v['title'];
  3591. }
  3592. if (isset($_GET['excel'])) {
  3593. $wh = array();
  3594. $w = $this->warehouse->find_all('1=1', 'id,title');
  3595. foreach ($w as $v) {
  3596. $wh[$v['id']] = $v['title'];
  3597. }
  3598. $type = $this->input->get('excel', true);
  3599. $category = $this->input->get('category', true);
  3600. $size = $this->input->get('size', true);
  3601. $grade = $this->input->get('grade', true);
  3602. $color = $this->input->get('color', true);
  3603. $lowe = $this->input->get('lowe', true);
  3604. $sku = $this->input->get('sku', true);
  3605. $warehouse = $this->input->get('warehouse', true);
  3606. $lacetype = $this->input->get('lacetype', true);
  3607. $lacecolor = $this->input->get('lacecolor', true);
  3608. $density = $this->input->get('density', true);
  3609. $haircap = $this->input->get('haircap', true);
  3610. $purchase = $this->input->get('purchase', true);
  3611. $title = $this->input->get('title', true);
  3612. $state = $this->input->get('state', true);
  3613. $sid = $this->input->get('sid', true);
  3614. $ktime = $this->input->get('ktime', true);
  3615. $jtime = $this->input->get('jtime', true);
  3616. $ktime = strtotime($ktime);
  3617. $jtime = strtotime($jtime);
  3618. $where = "1=1";
  3619. $gj = "";
  3620. $ck = "";
  3621. if ($category) {
  3622. $where .= " and features like '%-$category-%'";
  3623. }
  3624. if ($size) {
  3625. $where .= " and features like '%-$size-%'";
  3626. }
  3627. if ($grade) {
  3628. $where .= " and features like '%-$grade-%'";
  3629. }
  3630. if ($color) {
  3631. $where .= " and features like '%-$color-%'";
  3632. }
  3633. if ($lowe) {
  3634. $where .= " and features like '%-$lowe-%'";
  3635. }
  3636. if ($warehouse) {
  3637. $where .= " and warehouse = '$warehouse'";
  3638. }
  3639. if ($purchase) {
  3640. $where .= " and purchase = '$purchase'";
  3641. }
  3642. if ($state) {
  3643. $where .= " and state = '$state'";
  3644. }
  3645. if ($lacetype) {
  3646. $where .= " and features like '%-$lacetype-%'";
  3647. }
  3648. if ($lacecolor) {
  3649. $where .= " and features like '%-$lacecolor-%'";
  3650. }
  3651. if ($density) {
  3652. $where .= " and features like '%-$density-%'";
  3653. }
  3654. if ($haircap) {
  3655. $where .= " and features like '%-$haircap-%'";
  3656. }
  3657. if ($title) {
  3658. $title = trim($title, ' ');
  3659. $title = trim($title, ' ');
  3660. $where .= " and title like '%$title%'";
  3661. }
  3662. if ($sku) {
  3663. $sku = trim($sku, ' ');
  3664. $sku = trim($sku, ' ');
  3665. $where .= " and sku like '%$sku%'";
  3666. }
  3667. if ($ktime && $jtime) {
  3668. if ($type == 1) {
  3669. $tl = '出库';
  3670. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3671. } else if ($type == 2) {
  3672. $tl = '退库';
  3673. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3674. } else if ($type == 3) {
  3675. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3676. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3677. } else if ($type == 4) {
  3678. $tl = '出库+零售';
  3679. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3680. } else if ($type == 5) {
  3681. $tl = '零售';
  3682. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3683. }
  3684. }
  3685. $sidwhere = '';
  3686. if ($sid) {
  3687. $sd = "";
  3688. $s = explode(',', trim($sid, ','));
  3689. foreach ($s as $value) {
  3690. $sd .= " id = " . $value . " or";
  3691. }
  3692. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3693. }
  3694. //数据排序
  3695. $order_str = "time desc";
  3696. if (empty($page)) {
  3697. $start = 0;
  3698. $perpage = 1;
  3699. } else {
  3700. $start = ($page - 1) * $perpage;
  3701. }
  3702. //取得信息列表
  3703. if ($type != 3 && $type != 5) {
  3704. if ($type == 1 || $type == 4) {
  3705. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3706. foreach ($info_list as $key => $value) {
  3707. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3708. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3709. $warehouse = $this->warehouse->read($value['warehouse']);
  3710. $info_list[$key]['warehouse'] = $warehouse['title'];
  3711. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3712. $features = explode('-', trim($features, '-'));
  3713. $pm = $classid;
  3714. foreach ($features as $k => $v) {
  3715. if ($v != 0) {
  3716. if (!isset($typeclass[$v])) {
  3717. continue;
  3718. }
  3719. if (isset($pm[$typeclass[$v]['classid']])) {
  3720. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3721. $tz = explode('|', $typeclass[$v]['zh']);
  3722. $pm[$typeclass[$v]['classid']] = $tz[0];
  3723. } else {
  3724. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3725. }
  3726. }
  3727. }
  3728. }
  3729. $zh = implode(" ", $pm);
  3730. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3731. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3732. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3733. $info_list[$key]['features'] = $zh;
  3734. }
  3735. $final_list = [];
  3736. foreach($info_list as $k=>$v){
  3737. $number = "";
  3738. if(!empty($v['orderinfo'])){
  3739. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3740. if(!empty($tmp_info['number'])){
  3741. $number = $tmp_info['number'];
  3742. }
  3743. }
  3744. $final_list[] = [
  3745. 'warehouse'=>$v['warehouse'],
  3746. 'purchase'=>$v['purchase'],
  3747. 'sku'=>$v['sku'],
  3748. 'title'=>$v['title'],
  3749. 'features'=>$v['features'],
  3750. 'label'=>$v['label'],
  3751. 'orderinfo'=>$v['orderinfo'],
  3752. 'number'=>$number,
  3753. 'waybill'=>$v['waybill'],
  3754. 'outk'=>$v['outk'],
  3755. ];
  3756. }
  3757. } else {
  3758. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3759. foreach ($info_list as $key => $value) {
  3760. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3761. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3762. $warehouse = $this->warehouse->read($value['warehouse']);
  3763. $info_list[$key]['warehouse'] = $warehouse['title'];
  3764. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3765. $features = explode('-', trim($features, '-'));
  3766. $pm = $classid;
  3767. foreach ($features as $k => $v) {
  3768. if ($v != 0) {
  3769. if (!isset($typeclass[$v])) {
  3770. continue;
  3771. }
  3772. if (isset($pm[$typeclass[$v]['classid']])) {
  3773. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3774. $tz = explode('|', $typeclass[$v]['zh']);
  3775. $pm[$typeclass[$v]['classid']] = $tz[0];
  3776. } else {
  3777. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3778. }
  3779. }
  3780. }
  3781. }
  3782. $zh = implode(" ", $pm);
  3783. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3784. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3785. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3786. $info_list[$key]['features'] = $zh;
  3787. }
  3788. $final_list = [];
  3789. foreach($info_list as $k=>$v){
  3790. $number = "";
  3791. if(!empty($v['orderinfo'])){
  3792. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3793. if(!empty($tmp_info['number'])){
  3794. $number = $tmp_info['number'];
  3795. }
  3796. }
  3797. $final_list[] = [
  3798. 'warehouse'=>$v['warehouse'],
  3799. 'purchase'=>$v['purchase'],
  3800. 'sku'=>$v['sku'],
  3801. 'title'=>$v['title'],
  3802. 'features'=>$v['features'],
  3803. 'label'=>$v['label'],
  3804. 'orderinfo'=>$v['orderinfo'],
  3805. 'number'=>$number,
  3806. 'waybill'=>$v['waybill'],
  3807. 'retreat'=>$v['retreat'],
  3808. ];
  3809. }
  3810. }
  3811. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3812. $titlename = "<table border=1>
  3813. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3814. <tr align='center'>
  3815. <td>仓库</td>
  3816. <td>供应商</td>
  3817. <td>SKU</td>
  3818. <td>商品名称</td>
  3819. <td>商品中文</td>
  3820. <td>标签</td>
  3821. <td>订单号</td>
  3822. <td>订单编码</td>
  3823. <td>运单号</td>
  3824. <td>" . $tl . "时间(中国时间)</td>
  3825. </tr>
  3826. </table>";
  3827. $filename = $title . ".xls";
  3828. $tail = "";
  3829. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3830. } else if ($type == 5) {
  3831. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3832. foreach ($info_list as $key => $value) {
  3833. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3834. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3835. $warehouse = $this->warehouse->read($value['warehouse']);
  3836. $info_list[$key]['warehouse'] = $warehouse['title'];
  3837. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3838. $features = explode('-', trim($features, '-'));
  3839. $pm = $classid;
  3840. foreach ($features as $k => $v) {
  3841. if ($v != 0) {
  3842. if (!isset($typeclass[$v])) {
  3843. continue;
  3844. }
  3845. if (isset($pm[$typeclass[$v]['classid']])) {
  3846. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3847. $tz = explode('|', $typeclass[$v]['zh']);
  3848. $pm[$typeclass[$v]['classid']] = $tz[0];
  3849. } else {
  3850. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3851. }
  3852. }
  3853. }
  3854. }
  3855. $zh = implode(" ", $pm);
  3856. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3857. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3858. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3859. $info_list[$key]['features'] = $zh;
  3860. }
  3861. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3862. $titlename = "<table border=1>
  3863. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3864. <tr align='center'>
  3865. <td>仓库</td>
  3866. <td>供应商</td>
  3867. <td>SKU</td>
  3868. <td>商品名称</td>
  3869. <td>商品中文</td>
  3870. <td>标签</td>
  3871. <td>" . $tl . "时间(中国时间)</td>
  3872. </tr>
  3873. </table>";
  3874. $filename = $title . ".xls";
  3875. $tail = "";
  3876. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  3877. } else {
  3878. /**
  3879. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  3880. $rows = array();$list = array();
  3881. foreach ($info_list as $key=>$value)
  3882. {
  3883. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  3884. }
  3885. **/
  3886. $wh = array();
  3887. $w = $this->warehouse->find_all('1=1', 'id,title');
  3888. foreach ($w as $v) {
  3889. $wh[$v['id']] = $v['title'];
  3890. }
  3891. $wt = array();
  3892. $whlabel_type = $this->whlabel_type->find_all();
  3893. foreach ($whlabel_type as $v) {
  3894. $wt[$v['id']] = $v['title'];
  3895. }
  3896. $classid = $this->classid->sku();
  3897. $list = array();
  3898. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  3899. foreach ($rows as $key => $value) {
  3900. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3901. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3902. $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');
  3903. $details = array();
  3904. $cpid = array();
  3905. $cpbz = array();
  3906. $c = 0;
  3907. $g = 0;
  3908. $x = 0;
  3909. $t = 0;
  3910. $s = 0;
  3911. $q = 0;
  3912. foreach ($sd as $k => $v) {
  3913. if ($v['state'] == 0) {
  3914. $c++;
  3915. }
  3916. if ($v['state'] != 9) {
  3917. $g++;
  3918. }
  3919. if ($v['outk'] > 1) {
  3920. $x++;
  3921. }
  3922. if ($v['retreat'] > 0) {
  3923. $t++;
  3924. }
  3925. if ($v['state'] == 8) {
  3926. $s++;
  3927. }
  3928. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3929. $q++;
  3930. }
  3931. $details[$v['details']] = $v['details'];
  3932. if ($v['cpid'] != 0) {
  3933. $cpid[$v['cpid']] = $v['cpid'];
  3934. }
  3935. if ($v['cpbz'] != '') {
  3936. $cpbz[$v['cpbz']] = $v['cpbz'];
  3937. }
  3938. }
  3939. if (isset($wt[$value['type']])) {
  3940. $rows[$key]['type'] = $wt[$value['type']];
  3941. } else {
  3942. $rows[$key]['type'] = '未设置';
  3943. }
  3944. $rows[$key]['details'] = implode("、", $details);
  3945. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3946. $ftime = time() - 15 * 24 * 3600;
  3947. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3948. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  3949. $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);
  3950. $rows[$key]['c'] = $c;
  3951. $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);
  3952. $rows[$key]['t'] = $t;
  3953. $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'] . '"');
  3954. $rows[$key]['z'] = $z;
  3955. // $jm = $classid;
  3956. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3957. $features = explode('-', trim($features, '-'));
  3958. // $pm = $classid;
  3959. // foreach ($features as $k => $v) {
  3960. // if ($v != 0) {
  3961. // if (!isset($typeclass[$v])) {
  3962. // continue;
  3963. // }
  3964. // if (isset($pm[$typeclass[$v]['classid']])) {
  3965. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3966. // $tz = explode('|', $typeclass[$v]['zh']);
  3967. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3968. // } else {
  3969. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3970. // }
  3971. // if (isset($jm[$typeclass[$v]['classid']])) {
  3972. // if ($typeclass[$v]['jm']) {
  3973. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3974. // }
  3975. // }
  3976. // }
  3977. // }
  3978. // }
  3979. // $zh = implode(" ", $pm);
  3980. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3981. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3982. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3983. // $rows[$key]['features'] = $zh;
  3984. // $jm = array_filter($jm); //去除空值
  3985. // $jm = implode("-", $jm);
  3986. // $rows[$key]['jm'] = $jm;
  3987. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  3988. }
  3989. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  3990. // echo "<pre>";
  3991. // print_r($tmp_list);
  3992. // die;
  3993. $final_list =[];
  3994. foreach($tmp_list as $k=>$v){
  3995. $final_list[] = [
  3996. "warehouse"=>$v['warehouse'],
  3997. "purchase"=>$v['purchase'],
  3998. "details"=>$v['details'],
  3999. "cpid"=>$v['cpid'],
  4000. "sku"=>$v['sku'],
  4001. "title"=>$v['title'],
  4002. "features"=>$v['pm'],
  4003. "cpbz"=>$v['cpbz'],
  4004. "sm"=>$v['sm'],
  4005. "type"=>$v['type'],
  4006. "g"=>$v["g"],
  4007. "c"=>$v["c"],
  4008. "x"=>$v["x"],
  4009. "t"=>$v["t"],
  4010. "z"=>$v["z"],
  4011. "jm"=>$v["jm"],
  4012. "weight"=>$v["weight"],
  4013. "asd"=>$v["asd"],
  4014. ];
  4015. }
  4016. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4017. $titlename = "<table border=1>
  4018. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4019. <tr align='center'>
  4020. <td>仓库</td>
  4021. <td>供应商</td>
  4022. <td>位置</td>
  4023. <td>库存编码</td>
  4024. <td>SKU</td>
  4025. <td>商品名称</td>
  4026. <td>商品中文</td>
  4027. <td>产品备注</td>
  4028. <td>说明</td>
  4029. <td>类型</td>
  4030. <td>入库总量</td>
  4031. <td>库存数量</td>
  4032. <td>销售数量</td>
  4033. <td>退货数量</td>
  4034. <td>占单数量</td>
  4035. <td>料号</td>
  4036. <td>重量</td>
  4037. <td>类目</td>
  4038. </tr>
  4039. </table>";
  4040. $filename = $title . ".xls";
  4041. $tail = "";
  4042. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4043. }
  4044. }
  4045. }
  4046. //出库+入库数据整合
  4047. public function _excelcr()
  4048. {
  4049. if (isset($_GET['excel'])) {
  4050. $type = $this->input->get('excel', true);
  4051. $category = $this->input->get('category', true);
  4052. $size = $this->input->get('size', true);
  4053. $grade = $this->input->get('grade', true);
  4054. $color = $this->input->get('color', true);
  4055. $lowe = $this->input->get('lowe', true);
  4056. $sku = $this->input->get('sku', true);
  4057. $warehouse = $this->input->get('warehouse', true);
  4058. $purchase = $this->input->get('purchase', true);
  4059. $state = $this->input->get('state', true);
  4060. $sid = $this->input->get('sid', true);
  4061. $ktime = $this->input->get('ktime', true);
  4062. $jtime = $this->input->get('jtime', true);
  4063. $ktime = strtotime($ktime);
  4064. $jtime = strtotime($jtime);
  4065. $where = "1=1";
  4066. $gj = "";
  4067. $ck = "";
  4068. if ($category) {
  4069. $where .= " and features like '%-$category-%'";
  4070. }
  4071. if ($size) {
  4072. $where .= " and features like '%-$size-%'";
  4073. }
  4074. if ($grade) {
  4075. $where .= " and features like '%-$grade-%'";
  4076. }
  4077. if ($color) {
  4078. $where .= " and features like '%-$color-%'";
  4079. }
  4080. if ($lowe) {
  4081. $where .= " and features like '%-$lowe-%'";
  4082. }
  4083. if ($warehouse) {
  4084. $where .= " and warehouse = '$warehouse'";
  4085. }
  4086. if ($purchase) {
  4087. $where .= " and purchase = '$purchase'";
  4088. }
  4089. if ($state) {
  4090. $where .= " and state = '$state'";
  4091. }
  4092. if ($sku) {
  4093. $where .= " and sku like '%$sku%'";
  4094. }
  4095. if ($ktime && $jtime) {
  4096. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4097. }
  4098. $sidwhere = '';
  4099. if ($sid) {
  4100. $sd = "";
  4101. $s = explode(',', trim($sid, ','));
  4102. foreach ($s as $value) {
  4103. $sd .= " id = " . $value . " or";
  4104. }
  4105. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4106. }
  4107. //取得信息列表
  4108. $timeread = $ktime;
  4109. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4110. $timelist = array();
  4111. for ($i = 0; $i < $timenum; $i++) {
  4112. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4113. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4114. }
  4115. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4116. //echo "<pre>";
  4117. //print_r($info_list);
  4118. //exit();
  4119. $rows = array();
  4120. $list = array();
  4121. foreach ($info_list as $key => $value) {
  4122. $thistime = $timelist;
  4123. if (isset($rows[strtolower($value['sku'])])) {
  4124. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4125. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4126. }
  4127. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4128. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4129. }
  4130. } else {
  4131. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4132. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4133. }
  4134. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4135. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4136. }
  4137. $rows[strtolower($value['sku'])] = $thistime;
  4138. }
  4139. }
  4140. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4141. <head>
  4142. <!--[if gte mso 9]><xml>
  4143. <x:ExcelWorkbook>
  4144. <x:ExcelWorksheets>
  4145. <x:ExcelWorksheet>
  4146. <x:Name>EXCEL</x:Name>
  4147. <x:WorksheetOptions>
  4148. <x:Print>
  4149. <x:ValidPrinterInfo />
  4150. </x:Print>
  4151. </x:WorksheetOptions>
  4152. </x:ExcelWorksheet>
  4153. </x:ExcelWorksheets>
  4154. </x:ExcelWorkbook>
  4155. </xml>
  4156. <![endif]-->
  4157. </head><body>";
  4158. $str .= "<table border=1><tr><td>SKU</td>";
  4159. foreach ($timelist as $k => $v) {
  4160. $str .= "<td>" . $k . "出库</td>";
  4161. $str .= "<td>" . $k . "入库</td>";
  4162. }
  4163. $str .= "</tr></table>";
  4164. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4165. foreach ($rows as $key => $val) {
  4166. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4167. foreach ($val as $k => $v) {
  4168. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4169. if ($val[$k]['r'] > 0) {
  4170. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4171. } else {
  4172. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4173. }
  4174. }
  4175. $str .= "</tr>";
  4176. }
  4177. $str .= "</table>";
  4178. $str .= "</body></html>";
  4179. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4180. header("Content-type: application/octet-stream");
  4181. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4182. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4183. header("Pragma: no-cache");
  4184. header("Expires: 0");
  4185. exit($str);
  4186. }
  4187. }
  4188. //数量调整模板导出
  4189. public function _presetout()
  4190. {
  4191. if (isset($_GET['excel'])) {
  4192. $where = "sku != 'Preset' and purchase != 0";
  4193. //数据排序
  4194. $order_str = "id desc";
  4195. if (empty($page)) {
  4196. $start = 0;
  4197. $perpage = 1;
  4198. } else {
  4199. $start = ($page - 1) * $perpage;
  4200. }
  4201. //取得信息列表
  4202. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4203. $rows = array();
  4204. $list = array();
  4205. foreach ($info_list as $value) {
  4206. $warehouse = $this->warehouse->read($value['warehouse']);
  4207. $number = $value['number'];
  4208. $ftime = time() - 15 * 24 * 3600;
  4209. $purchase = $this->purchase->read($value['purchase']);
  4210. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4211. }
  4212. $title = "库存模板";
  4213. $titlename = "<table border=1>
  4214. <tr align='center'>
  4215. <td>仓库</td>
  4216. <td>供应商编码</td>
  4217. <td>SKU</td>
  4218. <td>增减数量(正数或负数)</td>
  4219. <td>增减备注</td>
  4220. <td>扣减方式:0减少库存1删除库存</td>
  4221. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4222. <td>扣减类型(扣减为必填,填数字):1.销售出库2.销售美国出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4223. </tr>
  4224. </table>";
  4225. $filename = $title . ".xls";
  4226. $tail = "";
  4227. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4228. }
  4229. }
  4230. //数量调整模板导入
  4231. public function _presetedit()
  4232. {
  4233. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4234. $config['upload_path'] = '.' . $dir;
  4235. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4236. $config['allowed_types'] = 'xls|xlsx|csv';
  4237. $config['max_size'] = 10240;
  4238. $this->load->library('upload', $config);
  4239. $this->upload->initialize($config);
  4240. if ($this->upload->do_upload('userfile')) {
  4241. $full_path = $dir . $this->upload->data('file_name');
  4242. $fileName = '.' . $full_path;
  4243. if (!file_exists($fileName)) {
  4244. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4245. exit;
  4246. } else {
  4247. require_once "./data/excel/PHPExcel/IOFactory.php";
  4248. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4249. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4250. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4251. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4252. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4253. ++$column; //如果列数大于26行
  4254. $list = array();
  4255. for ($i = 2; $i <= $row; $i++) // 行数循环
  4256. {
  4257. $data = array();
  4258. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4259. {
  4260. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4261. }
  4262. $list[] = $data;
  4263. }
  4264. }
  4265. $i = 0;
  4266. $j = 0;
  4267. $ed = array();
  4268. foreach ($list as $key => $value) {
  4269. $time = time();
  4270. if ($value['0'] == "") {
  4271. continue;
  4272. }
  4273. $warehouse = $this->warehouse->get_title($value['0']);
  4274. $purchase = $this->purchase->get_bm($value['1']);
  4275. $sku = $value['2'];
  4276. $num = $value['3']; //调整数量
  4277. $text = $value['4']; //扣减说明
  4278. $type = $value['5']; //调整方式0扣减1删除
  4279. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4280. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4281. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4282. if (!$purchase) //如果没有这个SKU
  4283. {
  4284. $ed[] = array($purchase . '-不存在此供应商编码');
  4285. $j++;
  4286. continue;
  4287. }
  4288. if (!$d) //如果没有这个SKU
  4289. {
  4290. $ed[] = array($sku . '-库存中不存在此SKU');
  4291. $j++;
  4292. continue;
  4293. }
  4294. if (!isset($warehouse['id'])) {
  4295. $ed[] = array($sku . '-仓库名错误!');
  4296. $j++;
  4297. continue;
  4298. }
  4299. if ($type != '0' && $type != '1') {
  4300. $ed[] = array($sku . '-扣减方式填写错误!');
  4301. $j++;
  4302. continue;
  4303. }
  4304. if ($num < 0) //扣减库存
  4305. {
  4306. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4307. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4308. $j++;
  4309. continue;
  4310. }
  4311. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4312. if (count($data) < abs($num)) {
  4313. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4314. $j++;
  4315. continue;
  4316. }
  4317. if ($type == 0) //如果扣减方式为 扣减库存
  4318. {
  4319. for ($i = 0; $i < abs($num); $i++) {
  4320. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4321. }
  4322. } else if ($type == 1) {
  4323. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4324. if (count($zt) > 0) {
  4325. $ed[] = array($sku . '-有在途库存无法删除!');
  4326. $j++;
  4327. continue;
  4328. }
  4329. for ($i = 0; $i < abs($num); $i++) {
  4330. $this->whlabel->remove($data[$i]['id']);
  4331. }
  4332. }
  4333. } else if ($num > 0) //增加库存
  4334. {
  4335. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4336. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4337. $j++;
  4338. continue;
  4339. }
  4340. $post['sku'] = $d['sku'];
  4341. $post['shop'] = $d['shop'];
  4342. $post['warehouse'] = $warehouse['id'];
  4343. $post['purchase'] = $purchase['id'];
  4344. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4345. $post['state'] = 0;
  4346. $post['title'] = $d['title'];
  4347. $post['number'] = $d['number'];
  4348. $post['features'] = $d['features'];
  4349. $post['enter'] = $time;
  4350. $post['time'] = $time; //操作时间
  4351. $post['rktype'] = $rktype;
  4352. for ($i = 0; $i < $num; $i++) {
  4353. $post['label'] = time() . rand(100, 999) . $i;
  4354. $this->whlabel->insert($post);
  4355. }
  4356. }
  4357. sleep(1); //防止入库时间一样,需要延迟1秒
  4358. }
  4359. if ($j > 0) {
  4360. $tt = date('Ymd', time());
  4361. $title = '库存导入错误信息-' . $tt;
  4362. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4363. $tail = "\n";
  4364. $filename = $title . ".xls";
  4365. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4366. $dir = '/data/excel/' . $time . '/';
  4367. $file_name = 'error_' . $time . rand(1000, 9999);
  4368. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4369. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4370. fwrite($myfile, $ecl);
  4371. fclose($myfile);
  4372. $error = $dir . $file_name . '.xls';
  4373. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4374. exit;
  4375. } else {
  4376. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4377. exit;
  4378. }
  4379. }
  4380. }
  4381. //笛卡儿积
  4382. function cp($ps, $sets, $list)
  4383. {
  4384. $result = array();
  4385. $j = 0;
  4386. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4387. if ($i == 0) {
  4388. $result = $sets[$i];
  4389. }
  4390. $tmp = array();
  4391. foreach ($result as $res) {
  4392. foreach ($sets[$i + 1] as $set) {
  4393. $tmp[] = $res . ',' . $set;
  4394. }
  4395. }
  4396. $result = $tmp;
  4397. }
  4398. $this->db->trans_begin();
  4399. foreach ($result as $v) {
  4400. $post = array();
  4401. $title = "";
  4402. $num = "";
  4403. $data = explode(',', $v);
  4404. for ($i = 0; $i < count($list); $i++) {
  4405. $post[$list[$i]] = $data[$i];
  4406. $typeclass = $this->typeclass->read($data[$i]);
  4407. $title = $title . $typeclass['title'] . " ";
  4408. if ($data[$i] != 0) {
  4409. $num .= $data[$i]; //所有数据ID拼接
  4410. }
  4411. }
  4412. foreach ($ps as $kp => $vp) {
  4413. $post[$kp] = $vp;
  4414. }
  4415. $post['number'] = $num;
  4416. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4417. if ($info_list) {
  4418. $j++;
  4419. } else {
  4420. $skunum = $this->whlabel->find_count();
  4421. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4422. $post['title'] = rtrim($title, ' ');
  4423. $this->whlabel->insert($post);
  4424. }
  4425. }
  4426. if ($this->db->trans_status() === FALSE) {
  4427. $this->db->trans_commit();
  4428. return NULL;
  4429. } else {
  4430. $this->db->trans_commit();
  4431. return $j;
  4432. }
  4433. }
  4434. public function _kj($arg_array)
  4435. {
  4436. if (isset($_POST['sku'])) {
  4437. $time = time();
  4438. $sku = $this->input->post('sku', true);
  4439. $warehouse = $this->input->post('warehouse', true);
  4440. $num = $this->input->post('num', true);
  4441. $text = $this->input->post('text', true);
  4442. $purchase = $this->input->post('purchase', true);
  4443. $cktype = $this->input->post('cktype', true);
  4444. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4445. if ($cktype != 1 && $text == '') {
  4446. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4447. exit;
  4448. }
  4449. if ($num > count($order)) {
  4450. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4451. exit;
  4452. } else {
  4453. for ($i = 0; $i < $num; $i++) {
  4454. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4455. }
  4456. }
  4457. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4458. exit;
  4459. }
  4460. $uid = $this->whlabel->read($arg_array[0]);
  4461. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4462. $this->data['data'] = $uid;
  4463. $this->_Template('whlabel_kj', $this->data);
  4464. }
  4465. public function _summary($arg_array)
  4466. {
  4467. $prc = array();
  4468. $purchase = $this->purchase->find_all();
  4469. foreach ($purchase as $k => $v) {
  4470. $prc[$v['id']] = $v['title'];
  4471. }
  4472. if (isset($_GET['excel'])) {
  4473. $ktime = $this->input->get('ktime', true);
  4474. $jtime = $this->input->get('jtime', true);
  4475. $ktime = strtotime($ktime);
  4476. $jtime = strtotime($jtime);
  4477. $where = "1=1";
  4478. if ($ktime && $jtime) {
  4479. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4480. }
  4481. //数据排序
  4482. $order_str = "time desc";
  4483. if (empty($page)) {
  4484. $start = 0;
  4485. $perpage = 1;
  4486. } else {
  4487. $start = ($page - 1) * $perpage;
  4488. }
  4489. //取得信息列表
  4490. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4491. foreach ($info_list as $key => $value) {
  4492. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4493. $warehouse = $this->warehouse->read($value['warehouse']);
  4494. $info_list[$key]['warehouse'] = $warehouse['title'];
  4495. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4496. $details = array();
  4497. $cpid = array();
  4498. foreach ($x as $k => $v) {
  4499. if ($v['details'] != '') {
  4500. $details[$v['details']] = $v['details'];
  4501. }
  4502. if ($v['cpid'] != 0) {
  4503. $cpid[$v['cpid']] = $v['cpid'];
  4504. }
  4505. }
  4506. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4507. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4508. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4509. $info_list[$key]['s'] = $s;
  4510. $info_list[$key]['x'] = count($x);
  4511. }
  4512. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4513. $titlename = "<table border=1>
  4514. <tr align='center'>
  4515. <td>仓库</td>
  4516. <td>供应商</td>
  4517. <td>出库位置</td>
  4518. <td>出库编码</td>
  4519. <td>SKU</td>
  4520. <td>产品名</td>
  4521. <td>总剩余库存</td>
  4522. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4523. </tr>
  4524. </table>";
  4525. $filename = $title . ".xls";
  4526. $tail = "";
  4527. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4528. }
  4529. }
  4530. //usps发货清单
  4531. public function _manifest()
  4532. {
  4533. if (isset($_POST['manifest'])) {
  4534. $wltext = $this->input->post('wltext', true);
  4535. $time = time() - 16 * 3600;
  4536. $ptime = strtotime(date('Y-m-d', $time));
  4537. $waybill = array();
  4538. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4539. foreach ($fullorder as $v) {
  4540. $waybill[$v['waybill']] = $v['waybill'];
  4541. }
  4542. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4543. foreach ($fullordersmt as $v) {
  4544. $waybill[$v['waybill']] = $v['waybill'];
  4545. }
  4546. $wltext = explode(';', $wltext);
  4547. foreach ($wltext as $v) {
  4548. if (isset($waybill[$v])) {
  4549. unset($waybill[$v]);
  4550. }
  4551. }
  4552. $data = $this->usps->get_manifest($waybill);
  4553. if (isset($data['Description'])) {
  4554. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4555. exit;
  4556. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4557. $bctime = date('Ymd', time());
  4558. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4559. echo json_encode(array('msg' => $pdf, 'success' => true));
  4560. exit;
  4561. } else {
  4562. echo json_encode(array('msg' => $data, 'success' => false));
  4563. exit;
  4564. }
  4565. }
  4566. }
  4567. public function _pdf($pdf, $title, $bctime)
  4568. {
  4569. $pdf_path = './data/pdf/' . $bctime . '/';
  4570. $file_base64 = $pdf;
  4571. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4572. $file_base64 = base64_decode($file_base64);
  4573. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4574. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4575. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4576. }
  4577. /**
  4578. *
  4579. *
  4580. *
  4581. 进销存占单异常索引
  4582. *
  4583. *
  4584. *
  4585. **/
  4586. public function _abnormal()
  4587. {
  4588. $post = $this->input->post(NULL, TRUE);
  4589. if (isset($post['page'])) {
  4590. $page = $this->input->post('page', true);
  4591. $perpage = $this->input->post('perpage', true);
  4592. $sku = $this->input->post('sku', true);
  4593. $where = "1=1";
  4594. //数据排序
  4595. $order_str = "id desc";
  4596. if (empty($page)) {
  4597. $start = 0;
  4598. $perpage = 1;
  4599. } else {
  4600. $start = ($page - 1) * $perpage;
  4601. }
  4602. //取得信息列表
  4603. $info_list = $this->whlabel->find_all($where, '*');
  4604. $rows = array();
  4605. $list = array();
  4606. foreach ($info_list as $key => $value) {
  4607. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4608. }
  4609. foreach ($rows as $value) {
  4610. $warehouse = $this->warehouse->read($value['warehouse']);
  4611. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4612. $number = $value['number'];
  4613. $ftime = time() - 15 * 24 * 3600;
  4614. if ($value['shop'] != '') {
  4615. $shop = $value['shop'];
  4616. $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');
  4617. $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');
  4618. $order = array_merge($orderdlz, $ordersmt);
  4619. $od = 0;
  4620. $a = '';
  4621. $orid = '';
  4622. foreach ($order as $v) {
  4623. $or = explode('|', ltrim($v['whlabel'], '|'));
  4624. for ($i = 0; $i < count($or); $i++) {
  4625. $orod = explode('-', $or[$i]);
  4626. if ($orod[0] == $number) {
  4627. $od += $orod[1];
  4628. }
  4629. }
  4630. $orid .= $v['number'] . '-';
  4631. }
  4632. } else {
  4633. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4634. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4635. $order = array_merge($orderdlz, $ordersmt);
  4636. $od = 0;
  4637. $a = '';
  4638. $orid = '';
  4639. $qt = array();
  4640. foreach ($order as $v) {
  4641. $or = explode('|', ltrim($v['whlabel'], '|'));
  4642. for ($i = 0; $i < count($or); $i++) {
  4643. $orod = explode('-', $or[$i]);
  4644. if ($orod[0] == $number) {
  4645. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4646. if ($czzs > 0) {
  4647. if (isset($qt[$v['shop']])) {
  4648. if ($qt[$v['shop']] < $orod[1]) {
  4649. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4650. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4651. } else {
  4652. $qt[$v['shop']] -= $orod[1];
  4653. }
  4654. } else {
  4655. $qt[$v['shop']] = $czzs;
  4656. }
  4657. } else {
  4658. $od += $orod[1];
  4659. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4660. }
  4661. }
  4662. }
  4663. }
  4664. }
  4665. $z = $od . '(' . $orid . ')'; //查看订单号
  4666. //$z = $od;
  4667. if ($od > $c) {
  4668. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4669. }
  4670. }
  4671. $listdata = array_slice($list, $start, $perpage);
  4672. $total = count($list);
  4673. $pagenum = ceil($total / $perpage);
  4674. $over = $total - ($start + $perpage);
  4675. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4676. echo json_encode($rows);
  4677. exit;
  4678. }
  4679. $this->_Template('whlabel_abnormal', $this->data);
  4680. }
  4681. /**
  4682. *
  4683. *
  4684. *
  4685. 进销存占单异常索引
  4686. *
  4687. *
  4688. *
  4689. **/
  4690. public function _error()
  4691. {
  4692. $post = $this->input->post(NULL, TRUE);
  4693. if (isset($post['page'])) {
  4694. $page = $this->input->post('page', true);
  4695. $perpage = $this->input->post('perpage', true);
  4696. $sku = $this->input->post('sku', true);
  4697. $warehouse = $this->input->post('warehouse', true);
  4698. $ktime = $this->input->post('ktime', true);
  4699. $jtime = $this->input->post('jtime', true);
  4700. $ktime = strtotime($ktime);
  4701. $jtime = strtotime($jtime);
  4702. $where = "sku != 'Preset'";
  4703. $gj = '';
  4704. if ($sku) {
  4705. $where .= " and sku like '%$sku%'";
  4706. } else {
  4707. if ($ktime && $jtime) {
  4708. $gj = " and time > '$ktime' and time < '$jtime'";
  4709. }
  4710. }
  4711. if ($warehouse) {
  4712. $where .= " and warehouse = '$warehouse'";
  4713. }
  4714. //数据排序
  4715. $order_str = "id desc";
  4716. if (empty($page)) {
  4717. $start = 0;
  4718. $perpage = 1;
  4719. } else {
  4720. $start = ($page - 1) * $perpage;
  4721. }
  4722. //取得信息列表
  4723. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4724. $rows = array();
  4725. $list = array();
  4726. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4727. // foreach ($info_list as $value)
  4728. // {
  4729. // $warehouse = $this->warehouse->read($value['warehouse']);
  4730. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4731. // $number = $value['number'];$ftime = time()-15*24*3600;
  4732. // if($c < 1)
  4733. // {
  4734. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4735. // }
  4736. // }
  4737. $warehouse_list = $this->warehouse->find_all();
  4738. $warehouse_list = array_column($warehouse_list, null, 'id');
  4739. foreach ($info_list as $value) {
  4740. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4741. 'title' => "",
  4742. ];
  4743. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4744. $number = $value['number'];
  4745. $ftime = time() - 15 * 24 * 3600;
  4746. if ($c < 1) {
  4747. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4748. }
  4749. }
  4750. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4751. // $query = $this->db->query($sql);
  4752. // $info_list = $query->result_array();
  4753. // $sql_two = "select title,id from crowd_warehouse";
  4754. // $query_two = $this->db->query($sql_two);
  4755. // $warehouse_list = $query_two->result_array();
  4756. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4757. // foreach ($info_list as $value)
  4758. // {
  4759. // if(isset($warehouse_arr[$value['warehouse']])){
  4760. // $warehouse = $warehouse_arr[$value['warehouse']];
  4761. // }else{
  4762. // $warehouse = [
  4763. // 'id'=>0,
  4764. // 'title'=>"异常",
  4765. // ];
  4766. // }
  4767. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4768. // $number = $value['number'];$ftime = time()-15*24*3600;
  4769. // if($c < 1)
  4770. // {
  4771. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4772. // }
  4773. // }
  4774. $listdata = array_slice($list, $start, $perpage);
  4775. $total = count($list);
  4776. $pagenum = ceil($total / $perpage);
  4777. $over = $total - ($start + $perpage);
  4778. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4779. echo json_encode($rows);
  4780. exit;
  4781. }
  4782. if (isset($post['s'])) {
  4783. $id_arr = $this->input->post('s');
  4784. $id_arr = explode(',', trim($id_arr, ','));
  4785. if (!$id_arr) {
  4786. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4787. exit;
  4788. }
  4789. //循环删除记录
  4790. foreach ($id_arr as $v) {
  4791. $dd = $this->whlabel->read($v);
  4792. if (!isset($dd['id'])) {
  4793. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4794. exit;
  4795. }
  4796. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4797. if (isset($zt[0])) {
  4798. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4799. exit;
  4800. }
  4801. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4802. foreach ($deldd as $vv) {
  4803. $this->whlabel->remove($vv['id']);
  4804. }
  4805. }
  4806. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4807. exit;
  4808. }
  4809. $this->_Template('whlabel_error', $this->data);
  4810. }
  4811. public function _errorexcel()
  4812. {
  4813. $post = $this->input->post(NULL, TRUE);
  4814. if (isset($_GET['page'])) {
  4815. $page = $this->input->get('page', true);
  4816. $perpage = $this->input->get('perpage', true);
  4817. $sku = $this->input->get('sku', true);
  4818. $warehouse = $this->input->get('warehouse', true);
  4819. $ktime = $this->input->get('ktime', true);
  4820. $jtime = $this->input->get('jtime', true);
  4821. $ktime = strtotime($ktime);
  4822. $jtime = strtotime($jtime);
  4823. $where = "sku != 'Preset'";
  4824. $gj = '';
  4825. if ($sku) {
  4826. $where .= " and sku like '%$sku%'";
  4827. } else {
  4828. if ($ktime && $jtime) {
  4829. $gj = " and time > '$ktime' and time < '$jtime'";
  4830. }
  4831. }
  4832. if ($warehouse) {
  4833. $where .= " and warehouse = '$warehouse'";
  4834. }
  4835. //数据排序
  4836. $order_str = "id desc";
  4837. if (empty($page)) {
  4838. $start = 0;
  4839. $perpage = 1;
  4840. } else {
  4841. $start = ($page - 1) * $perpage;
  4842. }
  4843. //取得信息列表
  4844. $rows = array();
  4845. $list = array();
  4846. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4847. foreach ($info_list as $value) {
  4848. $warehouse = $this->warehouse->read($value['warehouse']);
  4849. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4850. $number = $value['number'];
  4851. $ftime = time() - 15 * 24 * 3600;
  4852. if ($c < 1) {
  4853. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4854. }
  4855. }
  4856. $title = "0库存汇总";
  4857. $titlename = "<table border=1>
  4858. <tr align='center'>
  4859. <td>仓库</td>
  4860. <td>SKU</td>
  4861. <td>产品</td>
  4862. <td>当前库存</td>
  4863. </tr>
  4864. </table>";
  4865. $filename = $title . ".xls";
  4866. $tail = "";
  4867. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4868. }
  4869. }
  4870. /**
  4871. *
  4872. *
  4873. * 占单
  4874. *
  4875. *
  4876. **/
  4877. public function _kcyz()
  4878. {
  4879. $post = $this->input->post(NULL, TRUE);
  4880. if (isset($post['warehouse'])) {
  4881. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  4882. exit; //不再使用
  4883. $warehouse = $this->input->post('warehouse', true);
  4884. $whlabel = $this->input->post('whlabel', true);
  4885. $id = $this->input->post('id', true);
  4886. $shop = $this->input->post('shop', true);
  4887. $number = $this->input->post('number', true);
  4888. if (!$whlabel || $whlabel == '|') {
  4889. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  4890. exit;
  4891. }
  4892. $pp = explode('|', trim($whlabel, '|'));
  4893. $x = 0;
  4894. $save = array();
  4895. foreach ($pp as $va) {
  4896. $num = explode('-', $va);
  4897. if ($number) {
  4898. $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 = '')"); //通用
  4899. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  4900. } else {
  4901. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  4902. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  4903. }
  4904. $x++;
  4905. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  4906. $save[] = $x - 1;
  4907. continue; //提前先加X不然出错,所以要减1
  4908. }
  4909. }
  4910. if (isset($save[0])) {
  4911. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  4912. exit;
  4913. } else {
  4914. echo json_encode(array('success' => true));
  4915. exit;
  4916. }
  4917. }
  4918. }
  4919. public function _db()
  4920. {
  4921. $post = $this->input->post(NULL, TRUE);
  4922. if (isset($post['page'])) {
  4923. $page = $this->input->post('page', true);
  4924. $perpage = $this->input->post('perpage', true);
  4925. $sku = $this->input->post('sku', true);
  4926. $number = $this->input->post('number', true);
  4927. $warehouse = $this->input->post('warehouse', true);
  4928. $purchase = $this->input->post('purchase', true);
  4929. $orderinfo = $this->input->post('orderinfo', true);
  4930. $waybill = $this->input->post('waybill', true);
  4931. $category = $this->input->post('category', true);
  4932. $size = $this->input->post('size', true);
  4933. $grade = $this->input->post('grade', true);
  4934. $color = $this->input->post('color', true);
  4935. $lowe = $this->input->post('lowe', true);
  4936. $state = $this->input->post('state', true);
  4937. $label = $this->input->post('label', true);
  4938. $timetk = $this->input->post('timetkk', true);
  4939. $timetj = $this->input->post('timetjj', true);
  4940. $timetk = strtotime($timetk);
  4941. $timetj = strtotime($timetj);
  4942. $where = "dbtime > 0";
  4943. if ($timetk && $timetj) {
  4944. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  4945. }
  4946. if ($sku) {
  4947. $where .= " and sku = '$sku'";
  4948. }
  4949. if ($warehouse) {
  4950. $where .= " and warehouse = '$warehouse'";
  4951. if ($warehouse == 12) {
  4952. $w = 'specialstock';
  4953. } else {
  4954. $w = 'whlabel';
  4955. }
  4956. }
  4957. if ($purchase) {
  4958. $where .= " and purchase = '$purchase'";
  4959. }
  4960. if ($category) {
  4961. $where .= " and features like '%-$category-%'";
  4962. }
  4963. if ($size) {
  4964. $where .= " and features like '%-$size-%'";
  4965. }
  4966. if ($grade) {
  4967. $where .= " and features like '%-$grade-%'";
  4968. }
  4969. if ($color) {
  4970. $where .= " and features like '%-$color-%'";
  4971. }
  4972. if ($lowe) {
  4973. $where .= " and features like '%-$lowe-%'";
  4974. }
  4975. if ($state != '') {
  4976. $where .= " and state = '$state'";
  4977. }
  4978. //数据排序
  4979. $order_str = "dbtime desc";
  4980. if (empty($page)) {
  4981. $start = 0;
  4982. $perpage = 1;
  4983. } else {
  4984. $start = ($page - 1) * $perpage;
  4985. }
  4986. //取得信息列表
  4987. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  4988. foreach ($info_list as $key => $value) {
  4989. $warehouse = $this->$w->read($value['warehouse']);
  4990. $info_list[$key]['warehouse'] = $warehouse['title'];
  4991. $purchase = $this->purchase->read($value['purchase']);
  4992. $info_list[$key]['purchase'] = $purchase['title'];
  4993. if ($value['enter'] != 0) {
  4994. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  4995. } else {
  4996. $info_list[$key]['enter'] = "";
  4997. }
  4998. if ($value['dbtime'] != 0) {
  4999. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5000. } else {
  5001. $info_list[$key]['dbtime'] = "";
  5002. }
  5003. if ($value['state'] == 0) {
  5004. $info_list[$key]['state'] = "在库";
  5005. } else if ($value['state'] == 1) {
  5006. $info_list[$key]['state'] = "出库";
  5007. } else if ($value['state'] == 2) {
  5008. $info_list[$key]['state'] = "退库";
  5009. } else if ($value['state'] == 3) {
  5010. $info_list[$key]['state'] = "调拨中";
  5011. } else if ($value['state'] == 4) {
  5012. $info_list[$key]['state'] = "再加工";
  5013. } else if ($value['state'] == 5) {
  5014. $info_list[$key]['state'] = "维修中";
  5015. } else if ($value['state'] == 6) {
  5016. $info_list[$key]['state'] = "盘亏";
  5017. } else if ($value['state'] == 7) {
  5018. $info_list[$key]['state'] = "更换标签";
  5019. } else if ($value['state'] == 8) {
  5020. $info_list[$key]['state'] = "其它";
  5021. } else if ($value['state'] == 9) {
  5022. $info_list[$key]['state'] = "预设";
  5023. }
  5024. }
  5025. $total = $this->whlabel->find_count($where);
  5026. $pagenum = ceil($total / $perpage);
  5027. $over = $total - ($start + $perpage);
  5028. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5029. echo json_encode($rows);
  5030. exit;
  5031. }
  5032. if (isset($post['outsku'])) {
  5033. $time = time();
  5034. $cz = $this->input->post('cz', true);
  5035. $label = $this->input->post('outsku', true);
  5036. $sl = $this->input->post('sl', true);
  5037. $num = $this->input->post('num', true);
  5038. //$warehouse = $this->input->post('warehouse',true);
  5039. if (!$sl) {
  5040. $sl = 1;
  5041. }
  5042. if (!$warehouse) {
  5043. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5044. exit;
  5045. }
  5046. $dblabel = $this->whlabellabel->get_label($label);
  5047. if ($dblabel) {
  5048. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5049. if (count($data) < 1) {
  5050. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5051. exit;
  5052. }
  5053. if (count($data) < $num) {
  5054. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5055. exit;
  5056. }
  5057. for ($i = 0; $i < $sl; $i++) {
  5058. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5059. }
  5060. echo json_encode(array('success' => true));
  5061. exit;
  5062. } else {
  5063. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5064. exit;
  5065. }
  5066. }
  5067. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5068. $this->_Template('whlabel_db', $this->data);
  5069. }
  5070. public function _dbrk()
  5071. {
  5072. $post = $this->input->post(NULL, TRUE);
  5073. if (isset($post['page'])) {
  5074. $page = $this->input->post('page', true);
  5075. $perpage = $this->input->post('perpage', true);
  5076. $sku = $this->input->post('sku', true);
  5077. $number = $this->input->post('number', true);
  5078. $warehouse = $this->input->post('warehouse', true);
  5079. $purchase = $this->input->post('purchase', true);
  5080. $orderinfo = $this->input->post('orderinfo', true);
  5081. $waybill = $this->input->post('waybill', true);
  5082. $category = $this->input->post('category', true);
  5083. $size = $this->input->post('size', true);
  5084. $grade = $this->input->post('grade', true);
  5085. $color = $this->input->post('color', true);
  5086. $lowe = $this->input->post('lowe', true);
  5087. $state = $this->input->post('state', true);
  5088. $label = $this->input->post('label', true);
  5089. $ctime = $this->input->post('ctime', true);
  5090. $timetk = $this->input->post('timetkk', true);
  5091. $timetj = $this->input->post('timetjj', true);
  5092. $timetk = strtotime($timetk);
  5093. $timetj = strtotime($timetj);
  5094. $where = "dbtime > 0";
  5095. if ($timetk && $timetj) {
  5096. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5097. }
  5098. if ($sku) {
  5099. $where .= " and sku = '$sku'";
  5100. }
  5101. if ($warehouse) {
  5102. $where .= " and warehouse = '$warehouse'";
  5103. }
  5104. if ($purchase) {
  5105. $where .= " and purchase = '$purchase'";
  5106. }
  5107. if ($category) {
  5108. $where .= " and features like '%-$category-%'";
  5109. }
  5110. if ($size) {
  5111. $where .= " and features like '%-$size-%'";
  5112. }
  5113. if ($grade) {
  5114. $where .= " and features like '%-$grade-%'";
  5115. }
  5116. if ($color) {
  5117. $where .= " and features like '%-$color-%'";
  5118. }
  5119. if ($lowe) {
  5120. $where .= " and features like '%-$lowe-%'";
  5121. }
  5122. if ($state != '') {
  5123. $where .= " and state = '$state'";
  5124. }
  5125. //数据排序
  5126. $order_str = "dbtime desc";
  5127. if (empty($page)) {
  5128. $start = 0;
  5129. $perpage = 1;
  5130. } else {
  5131. $start = ($page - 1) * $perpage;
  5132. }
  5133. //取得信息列表
  5134. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5135. foreach ($info_list as $key => $value) {
  5136. $warehouse = $this->warehouse->read($value['warehouse']);
  5137. $info_list[$key]['warehouse'] = $warehouse['title'];
  5138. $purchase = $this->purchase->read($value['purchase']);
  5139. $info_list[$key]['purchase'] = $purchase['title'];
  5140. if ($value['enter'] != 0) {
  5141. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5142. } else {
  5143. $info_list[$key]['enter'] = "";
  5144. }
  5145. if ($value['dbtime'] != 0) {
  5146. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5147. } else {
  5148. $info_list[$key]['dbtime'] = "";
  5149. }
  5150. if ($value['state'] == 0) {
  5151. $info_list[$key]['state'] = "在库";
  5152. } else if ($value['state'] == 1) {
  5153. $info_list[$key]['state'] = "出库";
  5154. } else if ($value['state'] == 2) {
  5155. $info_list[$key]['state'] = "退库";
  5156. } else if ($value['state'] == 3) {
  5157. $info_list[$key]['state'] = "调拨中";
  5158. } else if ($value['state'] == 4) {
  5159. $info_list[$key]['state'] = "再加工";
  5160. } else if ($value['state'] == 5) {
  5161. $info_list[$key]['state'] = "维修中";
  5162. } else if ($value['state'] == 6) {
  5163. $info_list[$key]['state'] = "盘亏";
  5164. } else if ($value['state'] == 7) {
  5165. $info_list[$key]['state'] = "更换标签";
  5166. } else if ($value['state'] == 8) {
  5167. $info_list[$key]['state'] = "其它";
  5168. } else if ($value['state'] == 9) {
  5169. $info_list[$key]['state'] = "预设";
  5170. }
  5171. }
  5172. $total = $this->whlabel->find_count($where);
  5173. $pagenum = ceil($total / $perpage);
  5174. $over = $total - ($start + $perpage);
  5175. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5176. echo json_encode($rows);
  5177. exit;
  5178. }
  5179. if (isset($post['rsku'])) {
  5180. $cz = $this->input->post('cz', true);
  5181. $label = $this->input->post('rsku', true);
  5182. $sl = $this->input->post('sl', true);
  5183. $warehouse = $this->input->post('warehouse', true);
  5184. if (!$sl) {
  5185. $sl = 1;
  5186. }
  5187. if (!$warehouse) {
  5188. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5189. exit;
  5190. }
  5191. $dblabel = $this->whlabellabel->get_label($label);
  5192. if ($dblabel) {
  5193. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5194. if (count($data) < 1) {
  5195. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5196. exit;
  5197. }
  5198. if ($sl > count($data)) {
  5199. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5200. exit;
  5201. }
  5202. $time = time();
  5203. for ($i = 0; $i < $sl; $i++) {
  5204. $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']);
  5205. }
  5206. echo json_encode(array('success' => true));
  5207. exit;
  5208. } else {
  5209. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5210. exit;
  5211. }
  5212. }
  5213. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5214. $this->_Template('whlabel_dbrk', $this->data);
  5215. }
  5216. public function _whlabelczdc()
  5217. {
  5218. if (isset($_GET['excel'])) {
  5219. //数据排序
  5220. $order_str = "id desc";
  5221. if (empty($page)) {
  5222. $start = 0;
  5223. $perpage = 1;
  5224. } else {
  5225. $start = ($page - 1) * $perpage;
  5226. }
  5227. $state = $this->input->get('state', true);
  5228. $sku = $this->input->get('sku', true);
  5229. $ctime = $this->input->get('ctime', true);
  5230. $category = $this->input->get('category', true);
  5231. $size = $this->input->get('size', true);
  5232. $grade = $this->input->get('grade', true);
  5233. $color = $this->input->get('color', true);
  5234. $lowe = $this->input->get('lowe', true);
  5235. $timetk = $this->input->get('timetkk', true);
  5236. $timetj = $this->input->get('timetjj', true);
  5237. $timetk = strtotime($timetk);
  5238. $timetj = strtotime($timetj);
  5239. $where = "dbtime > 0";
  5240. if ($timetk && $timetj) {
  5241. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5242. }
  5243. if ($category) {
  5244. $where .= " and features like '%-$category-%'";
  5245. }
  5246. if ($size) {
  5247. $where .= " and features like '%-$size-%'";
  5248. }
  5249. if ($grade) {
  5250. $where .= " and features like '%-$grade-%'";
  5251. }
  5252. if ($color) {
  5253. $where .= " and features like '%-$color-%'";
  5254. }
  5255. if ($lowe) {
  5256. $where .= " and features like '%-$lowe-%'";
  5257. }
  5258. //取得信息列表
  5259. $info_list = $this->whlabel->find_all($where, '*');
  5260. $rows = array();
  5261. $list = array();
  5262. foreach ($info_list as $key => $value) {
  5263. $rows[$value['sku']] = $value; //所有数据sku
  5264. }
  5265. foreach ($rows as $value) {
  5266. $warehouse = $this->warehouse->read($value['warehouse']);
  5267. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5268. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5269. if ($value['orderinfo'] == 0) {
  5270. $info_list[$key]['orderinfo'] = "";
  5271. }
  5272. if ($value['waybill'] == 0) {
  5273. $info_list[$key]['waybill'] = "";
  5274. }
  5275. if ($value['state'] == 0) {
  5276. $value['state'] = "在库";
  5277. } else if ($value['state'] == 3) {
  5278. $value['state'] = "调拨中";
  5279. }
  5280. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5281. }
  5282. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5283. $titlename = "<table border=1>
  5284. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5285. <tr align='center'>
  5286. <td>SKU</td>
  5287. <td>产品</td>
  5288. <td>调拨数量</td>
  5289. <td>入库数量</td>
  5290. </tr>
  5291. </table>";
  5292. $filename = $title . ".xls";
  5293. $tail = "";
  5294. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5295. }
  5296. }
  5297. public function _print($arg_array)
  5298. {
  5299. if (isset($_SESSION['api'])) {
  5300. $user = $this->user->get_api($_SESSION['api']);
  5301. $usp = $user;
  5302. $fgshop = "";
  5303. $sid = "";
  5304. $wid = "";
  5305. $wtype = "";
  5306. $usersp = explode('|', trim($user['shop'], '|'));
  5307. $userwh = explode('|', trim($user['warehouse'], '|'));
  5308. foreach ($usersp as $value) {
  5309. $fgshop .= " shop = " . $value . " or";
  5310. $sid .= " id = " . $value . " or";
  5311. }
  5312. foreach ($userwh as $value) {
  5313. $wid .= " id = " . $value . " or";
  5314. $wtype .= " type = " . $value . " or";
  5315. }
  5316. }
  5317. $post = $this->input->post(NULL, TRUE);
  5318. if (isset($post['tmsku'])) {
  5319. $tmsku = $this->input->post('tmsku', true);
  5320. if (is_numeric($tmsku)) {
  5321. $yyh = $this->whlabellabel->get_label($tmsku);
  5322. } else {
  5323. $yyh = $this->whlabellabel->get_sku($tmsku);
  5324. }
  5325. if ($yyh) {
  5326. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5327. exit;
  5328. } else {
  5329. echo json_encode(array('success' => false));
  5330. exit;
  5331. }
  5332. }
  5333. $classid = $this->classid->sku();
  5334. $pm = $classid;
  5335. $scsku = $classid;
  5336. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5337. if (isset($post['warehouse'])) {
  5338. if ($post['warehouse']) {
  5339. $list = array();
  5340. $num = "";
  5341. $title = "";
  5342. $features = "";
  5343. $order = 0;
  5344. $post['shop'] = '';
  5345. $brand = $this->input->post('brand', true);
  5346. if ($brand != '0,') {
  5347. $b = $this->brand->read(rtrim($brand, ','));
  5348. if ($b) {
  5349. $post['shop'] = str_replace('|', ',', $b['shop']);
  5350. }
  5351. }
  5352. $post['details'] = $this->input->post('details', true); //打印数量
  5353. $xbqnum = $this->input->post('xbqnum', true);
  5354. $post['purchase'] = $this->input->post('purchase', true);
  5355. $post['warehouse'] = $this->input->post('warehouse', true);
  5356. $post['purchase'] = $this->input->post('purchase', true);
  5357. $post['retreatwarehouse'] = $post['warehouse'];
  5358. $post['cpbz'] = $this->input->post('cpbz', true);
  5359. $post['state'] = 9;
  5360. $category = $this->input->post('category', true);
  5361. $list['category'] = $category;
  5362. $list['hairtype'] = $this->input->post('hairtype', true);
  5363. $list['grade'] = $this->input->post('grade', true);
  5364. $size = $this->input->post('size', true);
  5365. $list['size'] = rtrim($size, ',');
  5366. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5367. $list['extension'] = $this->input->post('extension', true);
  5368. if ($category == 1297) {
  5369. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5370. }
  5371. if ($category == 1702) {
  5372. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5373. $list['syother'] = $this->input->post('syother', true);
  5374. }
  5375. if ($category == 133) {
  5376. $list['fittype'] = $this->input->post('fittype', true);
  5377. $list['acother'] = $this->input->post('acother', true);
  5378. }
  5379. $list['color'] = $this->input->post('color', true);
  5380. $list['lowe'] = $this->input->post('lowe', true);
  5381. if ($category == 127) {
  5382. $list['type'] = $this->input->post('type', true);
  5383. $list['headroad'] = $this->input->post('headroad', true);
  5384. $list['density'] = $this->input->post('density', true);
  5385. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5386. $list['lacesize'] = $this->input->post('lacesize', true);
  5387. }
  5388. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5389. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5390. }
  5391. if ($category == 128) {
  5392. $list['lacetype'] = $this->input->post('lacetype', true);
  5393. $list['haircap'] = $this->input->post('haircap', true);
  5394. $list['density'] = $this->input->post('density', true);
  5395. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5396. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5397. $list['wigother'] = $this->input->post('wigother', true);
  5398. $list['wigother1'] = $this->input->post('wigother1', true);
  5399. $list['wigother2'] = $this->input->post('wigother2', true);
  5400. }
  5401. if ($category == 129) {
  5402. $list['wide'] = $this->input->post('wide', true);
  5403. }
  5404. if ($category == 131) {
  5405. $list['gifttype'] = $this->input->post('gifttype', true);
  5406. $list['giftother'] = $this->input->post('giftother', true);
  5407. }
  5408. if ($category == 134) {
  5409. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5410. }
  5411. if ($category == 1297) {
  5412. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5413. $list['sywigother'] = $this->input->post('sywigother', true);
  5414. }
  5415. if ($category == 130 || $category == 133 || $category == 1702) {
  5416. $list['items'] = $this->input->post('items', true);
  5417. $list['weight'] = $this->input->post('weight', true);
  5418. }
  5419. if ($category == 1702) {
  5420. $list['syhairther'] = $this->input->post('syhairther', true);
  5421. }
  5422. foreach ($list as $k => $v) {
  5423. if ($v != 0) {
  5424. $num .= $v;
  5425. $features .= $v . '-';
  5426. $post[$k] = $v;
  5427. $typeclass = $this->typeclass->read($v);
  5428. if (isset($pm[$typeclass['classid']])) {
  5429. if (stripos($typeclass['zh'], '|') !== false) {
  5430. $exzh = explode('|', $typeclass['zh']);
  5431. $pm[$typeclass['classid']] = $exzh[0];
  5432. } else {
  5433. $pm[$typeclass['classid']] = $typeclass['zh'];
  5434. }
  5435. }
  5436. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5437. if ($k != 'size') {
  5438. $title .= $typeclass['title'] . " ";
  5439. }
  5440. }
  5441. }
  5442. $typeclass = $this->typeclass->read($list['size']);
  5443. $title .= $typeclass['title'];
  5444. $time = time();
  5445. $post['title'] = rtrim($title, ' ');
  5446. $post['number'] = $num;
  5447. $post['features'] = '-' . $features;
  5448. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5449. $featurespp = explode('-', trim($featurespp, '-'));
  5450. if (isset($featurespp[5])) {
  5451. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5452. } else {
  5453. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5454. }
  5455. $post['enter'] = $time;
  5456. $post['time'] = $time; //操作时间
  5457. $scsku = implode("-", $scsku);
  5458. $zh = implode(" ", $pm);
  5459. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5460. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5461. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5462. $post['sku'] = $bqsku;
  5463. $label = time() . rand(0, 9);
  5464. $post['label'] = $label;
  5465. $cpid = $this->whlabellabel->find_count();
  5466. $post['cpid'] = $cpid + 1;
  5467. $cpid = $post['cpid'];
  5468. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5469. //if($whlabelbarcode)
  5470. //{
  5471. //$post['label'] = $whlabelbarcode['label'];
  5472. //if(!$this->whlabellabel->insert($post))
  5473. //{
  5474. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5475. //}
  5476. //}
  5477. //else
  5478. //{
  5479. $this->db->trans_begin();
  5480. $this->whlabellabel->insert($post);
  5481. //$this->whlabelbarcode->insert($post);
  5482. if ($this->db->trans_status() === TRUE) {
  5483. $this->db->trans_commit();
  5484. } else {
  5485. $this->db->trans_rollback();
  5486. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5487. exit;
  5488. }
  5489. //}
  5490. $warehouse_name = "";
  5491. $warehouse = $post['warehouse'];
  5492. if($warehouse == 12){
  5493. $warehouse_name = "特殊库存库";
  5494. }
  5495. // if($warehouse == 13){
  5496. // $warehouse_name = "许昌仓";
  5497. // }
  5498. // if($warehouse == 5){
  5499. // $warehouse_name = "美国店";
  5500. // }
  5501. // if($warehouse == 16){
  5502. // $warehouse_name = "定制头套仓";
  5503. // }
  5504. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5505. if(!empty($warehouse_name)){
  5506. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5507. }
  5508. $purchase = $this->purchase->read($post['purchase']);
  5509. 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));
  5510. exit; //特殊仓目前不需要仓库选项
  5511. }
  5512. }
  5513. if (isset($_SESSION['api'])) {
  5514. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5515. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5516. $this->data['wlshop'] = $wlshop;
  5517. $this->data['warehouse'] = $warehouse;
  5518. }
  5519. $whlabelwz = $this->whlabelwz->find_all();
  5520. $this->data['whlabelwz'] = $whlabelwz;
  5521. $this->_Template('whlabel_print', $this->data);
  5522. }
  5523. public function _usaprint($arg_array)
  5524. {
  5525. if (isset($_SESSION['api'])) {
  5526. $user = $this->user->get_api($_SESSION['api']);
  5527. $usp = $user;
  5528. $fgshop = "";
  5529. $sid = "";
  5530. $wid = "";
  5531. $wtype = "";
  5532. $usersp = explode('|', trim($user['shop'], '|'));
  5533. $userwh = explode('|', trim($user['warehouse'], '|'));
  5534. foreach ($usersp as $value) {
  5535. $fgshop .= " shop = " . $value . " or";
  5536. $sid .= " id = " . $value . " or";
  5537. }
  5538. foreach ($userwh as $value) {
  5539. $wid .= " id = " . $value . " or";
  5540. $wtype .= " type = " . $value . " or";
  5541. }
  5542. }
  5543. $post = $this->input->post(NULL, TRUE);
  5544. if (isset($post['tmsku'])) {
  5545. $tmsku = $this->input->post('tmsku', true);
  5546. if (is_numeric($tmsku)) {
  5547. $yyh = $this->whlabellabel->get_label($tmsku);
  5548. } else {
  5549. $yyh = $this->whlabellabel->get_sku($tmsku);
  5550. }
  5551. if ($yyh) {
  5552. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5553. exit;
  5554. } else {
  5555. echo json_encode(array('success' => false));
  5556. exit;
  5557. }
  5558. }
  5559. $classid = $this->classid->sku();
  5560. $pm = $classid;
  5561. $scsku = $classid;
  5562. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5563. if (isset($post['warehouse'])) {
  5564. if ($post['warehouse']) {
  5565. $list = array();
  5566. $num = "";
  5567. $title = "";
  5568. $features = "";
  5569. $order = 0;
  5570. $post['shop'] = '';
  5571. $brand = $this->input->post('brand', true);
  5572. if ($brand != '0,') {
  5573. $b = $this->brand->read(rtrim($brand, ','));
  5574. if ($b) {
  5575. $post['shop'] = str_replace('|', ',', $b['shop']);
  5576. }
  5577. }
  5578. $post['details'] = $this->input->post('details', true); //打印数量
  5579. $xbqnum = $this->input->post('xbqnum', true);
  5580. $post['purchase'] = $this->input->post('purchase', true);
  5581. $post['warehouse'] = $this->input->post('warehouse', true);
  5582. $post['purchase'] = $this->input->post('purchase', true);
  5583. $post['retreatwarehouse'] = $post['warehouse'];
  5584. $post['cpbz'] = $this->input->post('cpbz', true);
  5585. $post['state'] = 9;
  5586. $category = $this->input->post('category', true);
  5587. $list['category'] = $category;
  5588. $list['hairtype'] = $this->input->post('hairtype', true);
  5589. $list['grade'] = $this->input->post('grade', true);
  5590. $size = $this->input->post('size', true);
  5591. $list['size'] = rtrim($size, ',');
  5592. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5593. $list['extension'] = $this->input->post('extension', true);
  5594. if ($category == 1297) {
  5595. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5596. }
  5597. if ($category == 1702) {
  5598. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5599. $list['syother'] = $this->input->post('syother', true);
  5600. }
  5601. if ($category == 133) {
  5602. $list['fittype'] = $this->input->post('fittype', true);
  5603. $list['acother'] = $this->input->post('acother', true);
  5604. }
  5605. $list['color'] = $this->input->post('color', true);
  5606. $list['lowe'] = $this->input->post('lowe', true);
  5607. if ($category == 127) {
  5608. $list['type'] = $this->input->post('type', true);
  5609. $list['headroad'] = $this->input->post('headroad', true);
  5610. $list['density'] = $this->input->post('density', true);
  5611. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5612. $list['lacesize'] = $this->input->post('lacesize', true);
  5613. }
  5614. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5615. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5616. }
  5617. if ($category == 128) {
  5618. $list['lacetype'] = $this->input->post('lacetype', true);
  5619. $list['haircap'] = $this->input->post('haircap', true);
  5620. $list['density'] = $this->input->post('density', true);
  5621. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5622. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5623. $list['wigother'] = $this->input->post('wigother', true);
  5624. $list['wigother1'] = $this->input->post('wigother1', true);
  5625. $list['wigother2'] = $this->input->post('wigother2', true);
  5626. }
  5627. if ($category == 129) {
  5628. $list['wide'] = $this->input->post('wide', true);
  5629. }
  5630. if ($category == 131) {
  5631. $list['gifttype'] = $this->input->post('gifttype', true);
  5632. $list['giftother'] = $this->input->post('giftother', true);
  5633. }
  5634. if ($category == 134) {
  5635. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5636. }
  5637. if ($category == 1297) {
  5638. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5639. $list['sywigother'] = $this->input->post('sywigother', true);
  5640. }
  5641. if ($category == 130 || $category == 133 || $category == 1702) {
  5642. $list['items'] = $this->input->post('items', true);
  5643. $list['weight'] = $this->input->post('weight', true);
  5644. }
  5645. if ($category == 1702) {
  5646. $list['syhairther'] = $this->input->post('syhairther', true);
  5647. }
  5648. foreach ($list as $k => $v) {
  5649. if ($v != 0) {
  5650. $num .= $v;
  5651. $features .= $v . '-';
  5652. $post[$k] = $v;
  5653. $typeclass = $this->typeclass->read($v);
  5654. if (isset($pm[$typeclass['classid']])) {
  5655. if (stripos($typeclass['zh'], '|') !== false) {
  5656. $exzh = explode('|', $typeclass['zh']);
  5657. $pm[$typeclass['classid']] = $exzh[0];
  5658. } else {
  5659. $pm[$typeclass['classid']] = $typeclass['zh'];
  5660. }
  5661. }
  5662. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5663. if ($k != 'size') {
  5664. $title .= $typeclass['title'] . " ";
  5665. }
  5666. }
  5667. }
  5668. $typeclass = $this->typeclass->read($list['size']);
  5669. $title .= $typeclass['title'];
  5670. $time = time();
  5671. $post['title'] = rtrim($title, ' ');
  5672. $post['number'] = $num;
  5673. $post['features'] = '-' . $features;
  5674. $fp = $this->whlabel->get_features($post['features']);
  5675. if (!$fp) {
  5676. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5677. exit;
  5678. }
  5679. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5680. $featurespp = explode('-', trim($featurespp, '-'));
  5681. if (isset($featurespp[5])) {
  5682. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5683. } else {
  5684. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5685. }
  5686. $post['enter'] = $time;
  5687. $post['time'] = $time; //操作时间
  5688. $scsku = implode("-", $scsku);
  5689. $zh = implode(" ", $pm);
  5690. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5691. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5692. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5693. $post['sku'] = $fp['sku'];
  5694. $post['label'] = $fp['sku'];
  5695. $cpid = $this->whlabellabel->find_count();
  5696. $post['cpid'] = $cpid + 1;
  5697. $cpid = $post['cpid'];
  5698. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5699. //if($whlabelbarcode)
  5700. //{
  5701. //$post['label'] = $whlabelbarcode['label'];
  5702. //if(!$this->whlabellabel->insert($post))
  5703. //{
  5704. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5705. //}
  5706. //}
  5707. //else
  5708. //{
  5709. $this->db->trans_begin();
  5710. $this->whlabellabel->insert($post);
  5711. //$this->whlabelbarcode->insert($post);
  5712. if ($this->db->trans_status() === TRUE) {
  5713. $this->db->trans_commit();
  5714. } else {
  5715. $this->db->trans_rollback();
  5716. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5717. exit;
  5718. }
  5719. //}
  5720. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5721. $purchase = $this->purchase->read($post['purchase']);
  5722. 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));
  5723. exit; //特殊仓目前不需要仓库选项
  5724. }
  5725. }
  5726. if (isset($_SESSION['api'])) {
  5727. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5728. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5729. $this->data['wlshop'] = $wlshop;
  5730. $this->data['warehouse'] = $warehouse;
  5731. }
  5732. $whlabelwz = $this->whlabelwz->find_all();
  5733. $this->data['whlabelwz'] = $whlabelwz;
  5734. $this->_Template('whlabel_usaprint', $this->data);
  5735. }
  5736. public function _printrk($arg_array)
  5737. {
  5738. $prc = array();
  5739. $purchase = $this->purchase->find_all();
  5740. foreach ($purchase as $k => $v) {
  5741. $prc[$v['id']] = $v['title'];
  5742. }
  5743. $post = $this->input->post(NULL, TRUE);
  5744. if (isset($post['page'])) {
  5745. $page = $this->input->post('page', true);
  5746. $perpage = $this->input->post('perpage', true);
  5747. $sku = $this->input->post('sku', true);
  5748. $bs = $this->input->post('bs', true);
  5749. $number = $this->input->post('number', true);
  5750. $warehouse = $this->input->post('warehouse', true);
  5751. $purchase = $this->input->post('purchase', true);
  5752. $orderinfo = $this->input->post('orderinfo', true);
  5753. $waybill = $this->input->post('waybill', true);
  5754. $category = $this->input->post('category', true);
  5755. $size = $this->input->post('size', true);
  5756. $grade = $this->input->post('grade', true);
  5757. $color = $this->input->post('color', true);
  5758. $lowe = $this->input->post('lowe', true);
  5759. $state = $this->input->post('state', true);
  5760. $label = $this->input->post('label', true);
  5761. $timetk = $this->input->post('ktime', true);
  5762. $timetj = $this->input->post('jtime', true);
  5763. $timetk = strtotime($timetk);
  5764. $timetj = strtotime($timetj);
  5765. $where = "1=1 ";
  5766. if ($timetk && $timetj) {
  5767. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5768. }
  5769. if ($sku) {
  5770. $where .= " and sku = '$sku'";
  5771. }
  5772. if ($bs != '') {
  5773. $where .= " and bs = '$bs'";
  5774. }
  5775. if ($number) {
  5776. $where .= " and number = '$number'";
  5777. }
  5778. if ($warehouse) {
  5779. $where .= " and warehouse = '$warehouse'";
  5780. }
  5781. if ($purchase) {
  5782. $where .= " and purchase = '$purchase'";
  5783. }
  5784. if ($orderinfo) {
  5785. $where .= " and orderinfo = '$orderinfo'";
  5786. }
  5787. if ($waybill) {
  5788. $where .= " and waybill = '$waybill'";
  5789. }
  5790. if ($category) {
  5791. $where .= " and features like '%-$category-%'";
  5792. }
  5793. if ($size) {
  5794. $where .= " and features like '%-$size-%'";
  5795. }
  5796. if ($grade) {
  5797. $where .= " and features like '%-$grade-%'";
  5798. }
  5799. if ($color) {
  5800. $where .= " and features like '%-$color-%'";
  5801. }
  5802. if ($lowe) {
  5803. $where .= " and features like '%-$lowe-%'";
  5804. }
  5805. if ($label) {
  5806. $where .= " and label = '$label'";
  5807. }
  5808. if ($state || $state == 0) {
  5809. $where .= " and state = '$state'";
  5810. }
  5811. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5812. //数据排序
  5813. $order_str = "enter desc";
  5814. if (empty($page)) {
  5815. $start = 0;
  5816. $perpage = 1;
  5817. } else {
  5818. $start = ($page - 1) * $perpage;
  5819. }
  5820. //取得信息列表
  5821. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5822. foreach ($info_list as $key => $value) {
  5823. $warehouse = $this->warehouse->read($value['warehouse']);
  5824. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5825. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5826. if ($value['state'] == 0) {
  5827. $info_list[$key]['state'] = "在库";
  5828. } else if ($value['state'] == 1) {
  5829. $info_list[$key]['state'] = "出库";
  5830. } else if ($value['state'] == 2) {
  5831. $info_list[$key]['state'] = "退库";
  5832. } else if ($value['state'] == 3) {
  5833. $info_list[$key]['state'] = "调拨中";
  5834. } else if ($value['state'] == 4) {
  5835. $info_list[$key]['state'] = "再加工";
  5836. } else if ($value['state'] == 5) {
  5837. $info_list[$key]['state'] = "维修中";
  5838. } else if ($value['state'] == 6) {
  5839. $info_list[$key]['state'] = "盘亏";
  5840. } else if ($value['state'] == 7) {
  5841. $info_list[$key]['state'] = "更换标签";
  5842. } else if ($value['state'] == 8) {
  5843. $info_list[$key]['state'] = "其它";
  5844. } else if ($value['state'] == 9) {
  5845. $info_list[$key]['state'] = "预设";
  5846. } else if ($value['state'] == 10) {
  5847. $info_list[$key]['state'] = "美店零售";
  5848. }
  5849. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5850. }
  5851. $total = $this->$ck->find_count($where);
  5852. $pagenum = ceil($total / $perpage);
  5853. $over = $total - ($start + $perpage);
  5854. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5855. echo json_encode($rows);
  5856. exit;
  5857. }
  5858. if (isset($post['tmsku'])) {
  5859. $time = time();
  5860. $tmsku = $this->input->post('tmsku', true);
  5861. //$post['shop'] = $this->input->post('shop',true);
  5862. $num = $this->input->post('num', true);
  5863. $rktype = $this->input->post('rktype', true);
  5864. if ($num > 200) {
  5865. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5866. exit;
  5867. }
  5868. if (!$rktype) {
  5869. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5870. }
  5871. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  5872. /**
  5873. $wz = array();
  5874. foreach ($rk as $key=>$value)
  5875. {
  5876. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  5877. }
  5878. if(count($wz) > 1)
  5879. {
  5880. $wz = array_values($wz);
  5881. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  5882. }
  5883. **/
  5884. if (isset($rk[0]['purchase'])) {
  5885. $rk = $rk[0];
  5886. $j = 0;
  5887. $post['purchase'] = $rk['purchase'];
  5888. $post['warehouse'] = $rk['warehouse'];
  5889. $post['retreatwarehouse'] = $rk['warehouse'];
  5890. $post['sku'] = $rk['sku'];
  5891. $post['number'] = $rk['number'];
  5892. $post['features'] = $rk['features'];
  5893. $post['title'] = $rk['title'];
  5894. $post['enter'] = $time;
  5895. $post['time'] = $time;
  5896. $post['bs'] = 1;
  5897. $post['shop'] = $rk['shop'];
  5898. $post['details'] = $rk['details'];
  5899. $post['cpid'] = $rk['cpid'];
  5900. $post['cpbz'] = $rk['cpbz'];
  5901. //$post['rktype'] = $rktype;
  5902. $warehouse = $this->warehouse->read($rk['warehouse']);
  5903. if ($warehouse['bdck'] == '') {
  5904. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  5905. exit;
  5906. } else {
  5907. $bdck = $warehouse['bdck'];
  5908. }
  5909. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  5910. if (isset($pdwz['details'])) {
  5911. if ($pdwz['details'] != $post['details']) {
  5912. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  5913. exit;
  5914. }
  5915. }
  5916. $post['featurespp'] = $rk['featurespp'];
  5917. if ($post['warehouse'] == '5') {
  5918. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5919. if ($yza) {
  5920. if ($post['features'] != $yza[0]['features']) {
  5921. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  5922. exit;
  5923. }
  5924. }
  5925. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5926. if ($yzb) {
  5927. if ($post['sku'] != $yzb[0]['sku']) {
  5928. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  5929. exit;
  5930. }
  5931. }
  5932. }
  5933. for ($i = 0; $i < $num; $i++) {
  5934. $post['label'] = time() . rand(100, 999) . $i;
  5935. if ($this->$bdck->insert($post)) {
  5936. $j++;
  5937. }
  5938. }
  5939. /**
  5940. if($post['warehouse'] != 12)
  5941. {
  5942. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  5943. }
  5944. **/
  5945. if ($j == $num) {
  5946. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  5947. exit;
  5948. } else {
  5949. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  5950. exit;
  5951. }
  5952. } else {
  5953. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  5954. exit;
  5955. }
  5956. }
  5957. $this->_Template('whlabel_printrk', $this->data);
  5958. }
  5959. public function _printxzrk($arg_array)
  5960. {
  5961. $post = $this->input->post(NULL, TRUE);
  5962. if (isset($post['wzid'])) {
  5963. $time = time();
  5964. $id = $this->input->post('wzid', true);
  5965. //$post['shop'] = $this->input->post('shop',true);
  5966. $num = 1;
  5967. $rk = $this->whlabellabel->read($id);
  5968. if (isset($rk['purchase'])) {
  5969. $x = 0;
  5970. $post['purchase'] = $rk['purchase'];
  5971. $post['warehouse'] = $rk['warehouse'];
  5972. $post['retreatwarehouse'] = $rk['warehouse'];
  5973. $post['sku'] = $rk['sku'];
  5974. $post['number'] = $rk['number'];
  5975. $post['features'] = $rk['features'];
  5976. $post['title'] = $rk['title'];
  5977. $post['enter'] = $time;
  5978. $post['time'] = $time;
  5979. $post['bs'] = 1;
  5980. $post['shop'] = $rk['shop'];
  5981. $post['details'] = $rk['details'];
  5982. $post['cpid'] = $rk['cpid'];
  5983. $post['cpbz'] = $rk['cpbz'];
  5984. $warehouse = $this->warehouse->read($rk['warehouse']);
  5985. if ($warehouse['bdck'] == '') {
  5986. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  5987. exit;
  5988. } else {
  5989. $bdck = $warehouse['bdck'];
  5990. }
  5991. $post['featurespp'] = $rk['featurespp'];
  5992. $this->db->trans_begin();
  5993. for ($i = 0; $i < $num; $i++) {
  5994. $post['label'] = time() . rand(100, 999) . $i;
  5995. $this->$bdck->insert($post);
  5996. }
  5997. /**
  5998. if($post['warehouse'] != 12)
  5999. {
  6000. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6001. }
  6002. **/
  6003. if ($this->db->trans_status() === TRUE) {
  6004. $this->db->trans_commit();
  6005. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6006. exit;
  6007. } else {
  6008. $this->db->trans_rollback();
  6009. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6010. exit;
  6011. }
  6012. } else {
  6013. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6014. exit;
  6015. }
  6016. }
  6017. }
  6018. public function _printck($arg_array)
  6019. {
  6020. $prc = array();
  6021. $purchase = $this->purchase->find_all();
  6022. foreach ($purchase as $k => $v) {
  6023. $prc[$v['id']] = $v['title'];
  6024. }
  6025. $post = $this->input->post(NULL, TRUE);
  6026. if (isset($post['page'])) {
  6027. $page = $this->input->post('page', true);
  6028. $perpage = $this->input->post('perpage', true);
  6029. $sku = $this->input->post('sku', true);
  6030. $bs = $this->input->post('bs', true);
  6031. $number = $this->input->post('number', true);
  6032. $warehouse = $this->input->post('warehouse', true);
  6033. $purchase = $this->input->post('purchase', true);
  6034. $orderinfo = $this->input->post('orderinfo', true);
  6035. $waybill = $this->input->post('waybill', true);
  6036. $category = $this->input->post('category', true);
  6037. $size = $this->input->post('size', true);
  6038. $grade = $this->input->post('grade', true);
  6039. $color = $this->input->post('color', true);
  6040. $lowe = $this->input->post('lowe', true);
  6041. $state = $this->input->post('state', true);
  6042. $label = $this->input->post('label', true);
  6043. $timetk = $this->input->post('ktime', true);
  6044. $timetj = $this->input->post('jtime', true);
  6045. $timetk = strtotime($timetk);
  6046. $timetj = strtotime($timetj);
  6047. $where = "state=1 ";
  6048. if ($timetk && $timetj) {
  6049. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6050. }
  6051. if ($sku) {
  6052. $where .= " and sku = '$sku'";
  6053. }
  6054. if ($bs != '') {
  6055. $where .= " and bs = '$bs'";
  6056. }
  6057. if ($number) {
  6058. $where .= " and number = '$number'";
  6059. }
  6060. if ($warehouse) {
  6061. $where .= " and warehouse = '$warehouse'";
  6062. }
  6063. if ($purchase) {
  6064. $where .= " and purchase = '$purchase'";
  6065. }
  6066. if ($orderinfo) {
  6067. $where .= " and orderinfo = '$orderinfo'";
  6068. }
  6069. if ($waybill) {
  6070. $where .= " and waybill = '$waybill'";
  6071. }
  6072. if ($category) {
  6073. $where .= " and features like '%-$category-%'";
  6074. }
  6075. if ($size) {
  6076. $where .= " and features like '%-$size-%'";
  6077. }
  6078. if ($grade) {
  6079. $where .= " and features like '%-$grade-%'";
  6080. }
  6081. if ($color) {
  6082. $where .= " and features like '%-$color-%'";
  6083. }
  6084. if ($lowe) {
  6085. $where .= " and features like '%-$lowe-%'";
  6086. }
  6087. if ($label) {
  6088. $where .= " and label = '$label'";
  6089. }
  6090. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6091. //数据排序
  6092. $order_str = "outk desc";
  6093. if (empty($page)) {
  6094. $start = 0;
  6095. $perpage = 1;
  6096. } else {
  6097. $start = ($page - 1) * $perpage;
  6098. }
  6099. //取得信息列表
  6100. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6101. foreach ($info_list as $key => $value) {
  6102. $warehouse = $this->warehouse->read($value['warehouse']);
  6103. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6104. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6105. if ($value['state'] == 0) {
  6106. $info_list[$key]['state'] = "在库";
  6107. } else if ($value['state'] == 1) {
  6108. $info_list[$key]['state'] = "出库";
  6109. } else if ($value['state'] == 2) {
  6110. $info_list[$key]['state'] = "退库";
  6111. } else if ($value['state'] == 3) {
  6112. $info_list[$key]['state'] = "调拨中";
  6113. } else if ($value['state'] == 4) {
  6114. $info_list[$key]['state'] = "再加工";
  6115. } else if ($value['state'] == 5) {
  6116. $info_list[$key]['state'] = "维修中";
  6117. } else if ($value['state'] == 6) {
  6118. $info_list[$key]['state'] = "盘亏";
  6119. } else if ($value['state'] == 7) {
  6120. $info_list[$key]['state'] = "更换标签";
  6121. } else if ($value['state'] == 8) {
  6122. $info_list[$key]['state'] = "其它";
  6123. } else if ($value['state'] == 9) {
  6124. $info_list[$key]['state'] = "预设";
  6125. } else if ($value['state'] == 10) {
  6126. $info_list[$key]['state'] = "美店零售";
  6127. }
  6128. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6129. }
  6130. $total = $this->$ck->find_count($where);
  6131. $pagenum = ceil($total / $perpage);
  6132. $over = $total - ($start + $perpage);
  6133. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6134. echo json_encode($rows);
  6135. exit;
  6136. }
  6137. if (isset($post['tmsku'])) {
  6138. $time = time();
  6139. $tmsku = $this->input->post('tmsku', true);
  6140. //$post['shop'] = $this->input->post('shop',true);
  6141. $num = $this->input->post('num', true);
  6142. $cktype = $this->input->post('cktype', true);
  6143. $label = $this->whlabellabel->get_label($tmsku);
  6144. if (!$cktype) {
  6145. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6146. }
  6147. if (!isset($label['warehouse'])) {
  6148. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6149. exit;
  6150. }
  6151. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6152. if (stripos($label['features'], '-126-') !== false) {
  6153. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6154. } else {
  6155. $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 = ''");
  6156. }
  6157. $j = 0;
  6158. if (count($ck) >= $num) {
  6159. for ($i = 0; $i < $num; $i++) {
  6160. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6161. {
  6162. $j++;
  6163. }
  6164. }
  6165. if ($j == $num) {
  6166. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6167. exit;
  6168. } else {
  6169. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6170. exit;
  6171. }
  6172. } else {
  6173. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6174. exit;
  6175. }
  6176. }
  6177. if(isset($_SESSION['api']))
  6178. {
  6179. $user = $this->user->get_api($_SESSION['api']);
  6180. if(in_array($user['power'],[1,27])){
  6181. $vip = 1;
  6182. }
  6183. }
  6184. else
  6185. {
  6186. $vip = 0;
  6187. header('Location: /');exit;
  6188. }
  6189. $this->data['vip'] = $vip;
  6190. $this->_Template('whlabel_printck', $this->data);
  6191. }
  6192. public function _printexcel()
  6193. {
  6194. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6195. $config['upload_path'] = '.' . $dir;
  6196. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6197. $config['allowed_types'] = 'xls|xlsx|csv';
  6198. $config['max_size'] = 10240;
  6199. $this->load->library('upload', $config);
  6200. $this->upload->initialize($config);
  6201. if ($this->upload->do_upload('userfile')) {
  6202. $full_path = $dir . $this->upload->data('file_name');
  6203. $fileName = '.' . $full_path;
  6204. if (!file_exists($fileName)) {
  6205. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6206. exit;
  6207. } else {
  6208. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6209. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6210. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6211. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6212. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6213. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6214. ++$column; //如果列数大于26行
  6215. $list = array();
  6216. for ($i = 2; $i <= $row; $i++) // 行数循环
  6217. {
  6218. $data = array();
  6219. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6220. {
  6221. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6222. }
  6223. $list[] = $data;
  6224. }
  6225. }
  6226. $ed = array();
  6227. $i = 0;
  6228. $j = 0;
  6229. $dcdata = array();
  6230. $yc = '';
  6231. $cmf_arr = array_column($list, '1');
  6232. array_multisort($cmf_arr, SORT_ASC, $list);
  6233. foreach ($list as $key => $value) {
  6234. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6235. if ($typeclass) {
  6236. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6237. } else {
  6238. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6239. $i++;
  6240. continue;
  6241. }
  6242. }
  6243. if ($i > 0) {
  6244. $yc = $i . '条异常';
  6245. }
  6246. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6247. exit;
  6248. }
  6249. }
  6250. public function _uck()
  6251. {
  6252. if (isset($_GET['excel'])) {
  6253. $tc = array();
  6254. $typeclass = $this->typeclass->find_all();
  6255. foreach ($typeclass as $v) {
  6256. $tc[$v['id']] = $v['zh'];
  6257. }
  6258. $data = array();
  6259. $t = array();
  6260. $rq = '';
  6261. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6262. $ts = $ts / (24 * 3600);
  6263. for ($i = 0; $i < $ts; $i++) {
  6264. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6265. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6266. }
  6267. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6268. foreach ($info_list as $k => $v) {
  6269. $features = explode('-', trim($v['features'], '-'));
  6270. if (!isset($features[3]) || !isset($features[4])) {
  6271. continue;
  6272. }
  6273. $data[$k][0] = $tc[$features[0]]; //类型
  6274. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6275. $data[$k][2] = $tc[$features[4]]; //曲度
  6276. $data[$k][3] = '';
  6277. if (isset($data[$k][1])) {
  6278. $data[$k][3] .= $data[$k][1];
  6279. }
  6280. if (isset($data[$k][2])) {
  6281. $data[$k][3] .= $data[$k][2];
  6282. }
  6283. if (isset($features[5])) {
  6284. $data[$k][3] .= $tc[$features[5]];
  6285. }
  6286. if (isset($features[2])) {
  6287. $data[$k][3] .= $tc[$features[2]];
  6288. }
  6289. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6290. $data[$k][4] = $v['sku'];
  6291. $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())) . '))'); //月初库存
  6292. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6293. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6294. $ztrq = '';
  6295. $ztsl = '';
  6296. if (count($zt) > 0) {
  6297. foreach ($zt as $vv) {
  6298. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6299. $ztsl .= $vv['num'] . '<br>';
  6300. }
  6301. }
  6302. $data[$k][] = trim($ztsl, '<br>');
  6303. $data[$k][] = trim($ztrq, '<br>');
  6304. $byck = 0;
  6305. foreach ($t as $vv) {
  6306. $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));
  6307. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6308. $byck += $sl;
  6309. }
  6310. $data[$k][] = ($byck > 0) ? $byck : '';
  6311. }
  6312. $title = "详情 " . date("Y-m-d", time());
  6313. $titlename = "<table border=1>
  6314. <tr align='center'>
  6315. <td>类别</td>
  6316. <td>颜色</td>
  6317. <td>曲度</td>
  6318. <td>名称</td>
  6319. <td>SKU</td>
  6320. <td>月初库存</td>
  6321. <td>剩余库存</td>
  6322. <td>在途数量</td>
  6323. <td>预达日期</td>" .
  6324. $rq
  6325. . "<td>本月出库</td></tr>
  6326. </table>";
  6327. $filename = $title . ".xls";
  6328. $tail = "";
  6329. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6330. }
  6331. }
  6332. public function _whlabelexcelzh()
  6333. {
  6334. if (isset($_GET['excel'])) {
  6335. $where = "sku != 'Preset'";
  6336. //数据排序
  6337. $order_str = "id desc";
  6338. if (empty($page)) {
  6339. $start = 0;
  6340. $perpage = 1;
  6341. } else {
  6342. $start = ($page - 1) * $perpage;
  6343. }
  6344. $category = $this->input->get('category', true);
  6345. $warehouse = $this->input->get('warehouse', true);
  6346. $excelid = $this->input->get('sid', true);
  6347. if ($category) {
  6348. $where .= " and features like '%-$category-%'";
  6349. }
  6350. if ($warehouse) {
  6351. $where .= " and warehouse = '$warehouse'";
  6352. }
  6353. $xzid = '';
  6354. if ($excelid) {
  6355. $excelid = explode(',', trim($excelid, ','));
  6356. foreach ($excelid as $key => $value) {
  6357. $xzid .= " id = " . $value . " or";
  6358. }
  6359. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6360. }
  6361. //取得信息列表
  6362. /**
  6363. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6364. $rows = array();$list = array();
  6365. foreach ($info_list as $key=>$value)
  6366. {
  6367. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6368. }
  6369. **/
  6370. $list = array();
  6371. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6372. foreach ($rows as $key => $value) {
  6373. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6374. $zh = '';
  6375. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6376. foreach ($zt as $v) {
  6377. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6378. }
  6379. $zt = array_sum(array_column($zt, 'num'));
  6380. $number = $value['number'];
  6381. $ftime = time() - 15 * 24 * 3600;
  6382. $warehouse = $this->warehouse->read($value['warehouse']);
  6383. $rows[$key]['warehouse'] = $warehouse['title'];
  6384. $rows[$key]['number'] = $c;
  6385. $rows[$key]['features'] = $zh;
  6386. $rows[$key]['hb'] = $c + $zt;
  6387. }
  6388. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6389. $titlename = "<table border=1>
  6390. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6391. <tr align='center'>
  6392. <td>仓库</td>
  6393. <td>SKU</td>
  6394. <td>产品</td>
  6395. <td>库存数量</td>
  6396. <td>在途数量及预达日期</td>
  6397. <td>在途+库存数量</td>
  6398. </tr>
  6399. </table>";
  6400. $filename = $title . ".xls";
  6401. $tail = "";
  6402. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6403. }
  6404. if (isset($_GET['excel'])) {
  6405. $warehouse = $this->input->get('warehouse', true);
  6406. $sku = $this->input->get('sku', true);
  6407. $cz = $this->input->get('cz', true);
  6408. $text = $this->input->post('text', true);
  6409. $xztime = $this->input->get('xztime', true);
  6410. $timetk = $this->input->get('timetk', true);
  6411. $timetj = $this->input->get('timetj', true);
  6412. $timetk = strtotime($timetk);
  6413. $timetj = strtotime($timetj);
  6414. $where = "time = '0' ";
  6415. if ($warehouse) {
  6416. $where .= " and warehouse = '$warehouse'";
  6417. }
  6418. if ($sku) {
  6419. $where .= " and sku = '$sku'";
  6420. }
  6421. if ($text) {
  6422. $where .= " and text like '%$text%'";
  6423. }
  6424. if ($cz != '') {
  6425. $where .= " and cz = '$cz'";
  6426. }
  6427. if ($timetk && $timetj) {
  6428. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6429. }
  6430. //数据排序
  6431. $order_str = $xztime . " desc";
  6432. //取得信息列表
  6433. $zh = array();
  6434. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6435. foreach ($info_list as $v) {
  6436. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6437. $warehouse = $this->warehouse->read($v['warehouse']);
  6438. $v['warehouse'] = $warehouse['title'];
  6439. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6440. $v['stime'] = date('Y-m-d', $v['stime']);
  6441. if (isset($zh[$v['features']])) {
  6442. $zh[$v['features']]['num'] += $v['num'];
  6443. } else {
  6444. $zh[$v['features']] = $v;
  6445. }
  6446. $zh[$v['features']]['features'] = $c;
  6447. }
  6448. $title = "在途数据" . date('Y-m-d', time());
  6449. $titlename = "<table border=1>
  6450. <tr align='center'>
  6451. <td>仓库</td>
  6452. <td>SKU</td>
  6453. <td>名称</td>
  6454. <td>在途数量</td>
  6455. <td>库存数量</td>
  6456. <td>添加在途日期</td>
  6457. <td>预达日期</td>
  6458. <td>备注</td>
  6459. </tr>
  6460. </table>";
  6461. $filename = $title . ".xls";
  6462. $tail = "";
  6463. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6464. }
  6465. }
  6466. public function _fc()
  6467. {
  6468. $vip = 0;
  6469. if (isset($_SESSION['api'])) {
  6470. $user = $this->user->get_api($_SESSION['api']);
  6471. if ($user['vip'] == 1) {
  6472. $vip = 1;
  6473. }
  6474. } else {
  6475. header('Location: /');
  6476. exit;
  6477. }
  6478. $post = $this->input->post(NULL, TRUE);
  6479. if (isset($post['page'])) {
  6480. $page = $this->input->post('page', true);
  6481. $perpage = $this->input->post('perpage', true);
  6482. $category = $this->input->post('category', true);
  6483. $size = $this->input->post('size', true);
  6484. $grade = $this->input->post('grade', true);
  6485. $color = $this->input->post('color', true);
  6486. $lowe = $this->input->post('lowe', true);
  6487. $sku = $this->input->post('sku');
  6488. $title = $this->input->post('title');
  6489. $warehouse = $this->input->post('warehouse', true);
  6490. $usa = $this->input->post('usa', true);
  6491. $purchase = $this->input->post('purchase', true);
  6492. $lacetype = $this->input->post('lacetype', true);
  6493. $haircap = $this->input->post('haircap', true);
  6494. $density = $this->input->post('density', true);
  6495. $details = $this->input->post('details', true);
  6496. $state = $this->input->post('state', true);
  6497. $ktime = $this->input->post('ktime', true);
  6498. $jtime = $this->input->post('jtime', true);
  6499. $ktime = strtotime($ktime);
  6500. $jtime = strtotime($jtime);
  6501. $where = "state = '11'";
  6502. $gj = "";
  6503. $ck = "";
  6504. if ($lacetype) {
  6505. $where .= " and features like '%-$lacetype-%'";
  6506. }
  6507. if ($category) {
  6508. $where .= " and features like '%-$category-%'";
  6509. }
  6510. if ($size) {
  6511. $where .= " and features like '%-$size-%'";
  6512. }
  6513. if ($grade) {
  6514. $where .= " and features like '%-$grade-%'";
  6515. }
  6516. if ($color) {
  6517. $where .= " and features like '%-$color-%'";
  6518. }
  6519. if ($lowe) {
  6520. $where .= " and features like '%-$lowe-%'";
  6521. }
  6522. if ($haircap) {
  6523. $where .= " and features like '%-$haircap-%'";
  6524. }
  6525. if ($density) {
  6526. $where .= " and features like '%-$density-%'";
  6527. }
  6528. if ($usa) {
  6529. if (!$warehouse) {
  6530. $where .= " and (warehouse = '5' or warehouse = '8')";
  6531. }
  6532. }
  6533. if ($warehouse) {
  6534. $where .= " and warehouse = '$warehouse'";
  6535. }
  6536. if ($details) {
  6537. $where .= " and details = '$details'";
  6538. }
  6539. if ($purchase) {
  6540. $where .= " and purchase = '$purchase'";
  6541. }
  6542. if ($state) {
  6543. $where .= " and state = '$state'";
  6544. }
  6545. if ($ktime && $jtime) {
  6546. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6547. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6548. }
  6549. //数据排序
  6550. $order_str = "id desc";
  6551. if (empty($page)) {
  6552. $start = 0;
  6553. $perpage = 1;
  6554. } else {
  6555. $start = ($page - 1) * $perpage;
  6556. }
  6557. if ($sku) {
  6558. $sku = trim($sku, ' ');
  6559. $sku = trim($sku, ' ');
  6560. $where .= " and sku like '%$sku%'";
  6561. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6562. } else if ($title) {
  6563. $title = trim($title, ' ');
  6564. $title = trim($title, ' ');
  6565. $where .= " and title like '%$title%'";
  6566. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6567. } else {
  6568. //$where .= " and time > '$ktime' and time < '$jtime'";
  6569. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6570. }
  6571. //取得信息列表
  6572. $rows = array();
  6573. $list = array();
  6574. foreach ($info_list as $key => $value) {
  6575. $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'] . '"');
  6576. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6577. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6578. $warehouse = $this->warehouse->read($value['warehouse']);
  6579. $info_list[$key]['warehouse'] = $warehouse['title'];
  6580. $info_list[$key]['number'] = $g;
  6581. $info_list[$key]['features'] = $x;
  6582. $info_list[$key]['x'] = $s;
  6583. }
  6584. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6585. $pagenum = ceil($total / $perpage);
  6586. $over = $total - ($start + $perpage);
  6587. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6588. echo json_encode($rows);
  6589. exit;
  6590. }
  6591. $this->data['vip'] = $vip;
  6592. $this->_Template('whlabel_fc', $this->data);
  6593. }
  6594. public function _fcmb()
  6595. {
  6596. $where = "sku != 'Preset'";
  6597. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6598. foreach ($rows as $k => $v) {
  6599. $warehouse = $this->warehouse->read($v['warehouse']);
  6600. $rows[$k]['warehouse'] = $warehouse['title'];
  6601. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6602. $rows[$k]['t'] = '';
  6603. $rows[$k]['n'] = '';
  6604. }
  6605. $title = "封货产品数据导入模板";
  6606. $titlename = "<table border=1>
  6607. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6608. <tr align='center'>
  6609. <td>仓库</td>
  6610. <td>SKU</td>
  6611. <td>产品</td>
  6612. <td>封存产品总数量</td>
  6613. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6614. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6615. </tr>
  6616. </table>";
  6617. $filename = $title . ".xls";
  6618. $tail = "";
  6619. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6620. }
  6621. public function _fcexcel()
  6622. {
  6623. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6624. $config['upload_path'] = '.' . $dir;
  6625. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6626. $config['allowed_types'] = 'xls|xlsx|csv';
  6627. $config['max_size'] = 10240;
  6628. $this->load->library('upload', $config);
  6629. $this->upload->initialize($config);
  6630. if ($this->upload->do_upload('userfile')) {
  6631. $full_path = $dir . $this->upload->data('file_name');
  6632. $fileName = '.' . $full_path;
  6633. if (!file_exists($fileName)) {
  6634. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6635. exit;
  6636. } else {
  6637. libxml_use_internal_errors(true);
  6638. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6639. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6640. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6641. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6642. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6643. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6644. ++$column; //如果列数大于26行
  6645. $list = array();
  6646. for ($i = 2; $i <= $row; $i++) // 行数循环
  6647. {
  6648. $data = array();
  6649. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6650. {
  6651. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6652. }
  6653. $list[] = $data;
  6654. }
  6655. }
  6656. $i = 0;
  6657. $j = 0;
  6658. $ed = array();
  6659. foreach ($list as $key => $value) {
  6660. $time = time();
  6661. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6662. continue;
  6663. }
  6664. $warehouse = $this->warehouse->get_title($value['0']);
  6665. $sku = $value['1'];
  6666. $type = $value['4']; //调整方式0扣减1删除
  6667. $num = $value['5']; //调整数量
  6668. //$text = $value['4'];//扣减说明
  6669. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6670. if (!$d) //如果没有这个SKU
  6671. {
  6672. $ed[] = array($sku . '-库存中不存在此SKU');
  6673. $j++;
  6674. continue;
  6675. }
  6676. if (!isset($warehouse['id'])) {
  6677. $ed[] = array($sku . '-仓库名错误!');
  6678. $j++;
  6679. continue;
  6680. }
  6681. if ($type == 1 || $type == 2) //扣减库存
  6682. {
  6683. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6684. if (count($data) < abs($num)) {
  6685. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6686. $j++;
  6687. continue;
  6688. }
  6689. if ($type == 1) //转入库存
  6690. {
  6691. for ($i = 0; $i < abs($num); $i++) {
  6692. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6693. }
  6694. } else if ($type == 2) //删除
  6695. {
  6696. for ($i = 0; $i < abs($num); $i++) {
  6697. $this->whlabel->remove($data[$i]['id']);
  6698. }
  6699. }
  6700. } else if ($type == 0) //增加库存
  6701. {
  6702. $post['sku'] = $d['sku'];
  6703. $post['shop'] = '';
  6704. $post['warehouse'] = $warehouse['id'];
  6705. $post['purchase'] = $d['purchase'];
  6706. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6707. $post['state'] = 11;
  6708. $post['title'] = $d['title'];
  6709. $post['number'] = $d['number'];
  6710. $post['features'] = $d['features'];
  6711. $post['enter'] = $time;
  6712. $post['time'] = $time; //操作时间
  6713. for ($i = 0; $i < $num; $i++) {
  6714. $post['label'] = time() . rand(100, 999) . $i;
  6715. $this->whlabel->insert($post);
  6716. }
  6717. }
  6718. sleep(1); //防止入库时间一样,需要延迟1秒
  6719. }
  6720. if ($j > 0) {
  6721. $tt = date('Ymd', time());
  6722. $title = '库存导入错误信息-' . $tt;
  6723. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6724. $tail = "\n";
  6725. $filename = $title . ".xls";
  6726. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6727. $dir = '/data/excel/' . $time . '/';
  6728. $file_name = 'error_' . $time . rand(1000, 9999);
  6729. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6730. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6731. fwrite($myfile, $ecl);
  6732. fclose($myfile);
  6733. $error = $dir . $file_name . '.xls';
  6734. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6735. exit;
  6736. } else {
  6737. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6738. exit;
  6739. }
  6740. }
  6741. }
  6742. public function _fcjxc($arg_array)
  6743. {
  6744. if (isset($_GET['excel'])) {
  6745. $category = $this->input->get('category', true);
  6746. $size = $this->input->get('size', true);
  6747. $grade = $this->input->get('grade', true);
  6748. $color = $this->input->get('color', true);
  6749. $lowe = $this->input->get('lowe', true);
  6750. $sku = $this->input->get('sku');
  6751. $title = $this->input->get('title');
  6752. $warehouse = $arg_array[0];
  6753. $usa = $this->input->get('usa', true);
  6754. $purchase = $this->input->get('purchase', true);
  6755. $lacetype = $this->input->get('lacetype', true);
  6756. $haircap = $this->input->get('haircap', true);
  6757. $density = $this->input->get('density', true);
  6758. $title = $this->input->get('title', true);
  6759. $state = $this->input->get('state', true);
  6760. $ktime = $this->input->get('ktime', true);
  6761. $jtime = $this->input->get('jtime', true);
  6762. $where = "state=11";
  6763. $gj = "";
  6764. $ck = "";
  6765. if ($lacetype) {
  6766. $where .= " and features like '%-$lacetype-%'";
  6767. }
  6768. if ($category) {
  6769. $where .= " and features like '%-$category-%'";
  6770. }
  6771. if ($size) {
  6772. $where .= " and features like '%-$size-%'";
  6773. }
  6774. if ($grade) {
  6775. $where .= " and features like '%-$grade-%'";
  6776. }
  6777. if ($color) {
  6778. $where .= " and features like '%-$color-%'";
  6779. }
  6780. if ($lowe) {
  6781. $where .= " and features like '%-$lowe-%'";
  6782. }
  6783. if ($haircap) {
  6784. $where .= " and features like '%-$haircap-%'";
  6785. }
  6786. if ($density) {
  6787. $where .= " and features like '%-$density-%'";
  6788. }
  6789. if ($usa) {
  6790. if (!$warehouse) {
  6791. $where .= " and (warehouse = '5' or warehouse = '8')";
  6792. }
  6793. }
  6794. if ($warehouse) {
  6795. $where .= " and warehouse = '$warehouse'";
  6796. }
  6797. if ($purchase) {
  6798. $where .= " and purchase = '$purchase'";
  6799. }
  6800. if ($state) {
  6801. $where .= " and state = '$state'";
  6802. }
  6803. $order_str = "id desc";
  6804. if ($sku) {
  6805. $sku = trim($sku, ' ');
  6806. $sku = trim($sku, ' ');
  6807. $where .= " and sku like '%$sku%'";
  6808. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6809. } else if ($title) {
  6810. $title = trim($title, ' ');
  6811. $title = trim($title, ' ');
  6812. $where .= " and title like '%$title%'";
  6813. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6814. } else {
  6815. //$where .= " and time > '$ktime' and time < '$jtime'";
  6816. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6817. }
  6818. //取得信息列表
  6819. $rows = array();
  6820. $list = array();
  6821. foreach ($info_list as $key => $value) {
  6822. $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'] . '"');
  6823. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6824. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6825. $rows[$key] = $value;
  6826. $warehouse = $this->warehouse->read($value['warehouse']);
  6827. $rows[$key]['warehouse'] = $warehouse['title'];
  6828. $rows[$key]['features'] = $g;
  6829. $rows[$key]['a'] = $x;
  6830. $rows[$key]['b'] = $s;
  6831. }
  6832. $title = "总统计表";
  6833. $titlename = "<table border=1>
  6834. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6835. <tr align='center'>
  6836. <td>仓库</td>
  6837. <td>SKU</td>
  6838. <td>产品名称</td>
  6839. <td>录入总量</td>
  6840. <td>取出总量</td>
  6841. <td>剩余总量</td>
  6842. </tr>
  6843. </table>";
  6844. $filename = $title . ".xls";
  6845. $tail = "";
  6846. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6847. }
  6848. $vip = 0;
  6849. if (isset($_SESSION['api'])) {
  6850. $user = $this->user->get_api($_SESSION['api']);
  6851. if ($user['vip'] == 1) {
  6852. $vip = 1;
  6853. }
  6854. } else {
  6855. header('Location: /');
  6856. exit;
  6857. }
  6858. $post = $this->input->post(NULL, TRUE);
  6859. if (isset($post['page'])) {
  6860. $page = $this->input->post('page', true);
  6861. $perpage = $this->input->post('perpage', true);
  6862. $category = $this->input->post('category', true);
  6863. $size = $this->input->post('size', true);
  6864. $grade = $this->input->post('grade', true);
  6865. $color = $this->input->post('color', true);
  6866. $lowe = $this->input->post('lowe', true);
  6867. $sku = $this->input->post('sku');
  6868. $title = $this->input->post('title');
  6869. $warehouse = $arg_array[0];
  6870. $usa = $this->input->post('usa', true);
  6871. $purchase = $this->input->post('purchase', true);
  6872. $lacetype = $this->input->post('lacetype', true);
  6873. $haircap = $this->input->post('haircap', true);
  6874. $density = $this->input->post('density', true);
  6875. $title = $this->input->post('title', true);
  6876. $state = $this->input->post('state', true);
  6877. $ktime = $this->input->post('ktime', true);
  6878. $jtime = $this->input->post('jtime', true);
  6879. $ktime = strtotime($ktime);
  6880. $jtime = strtotime($jtime);
  6881. $where = "state=11";
  6882. $gj = "";
  6883. $ck = "";
  6884. if ($lacetype) {
  6885. $where .= " and features like '%-$lacetype-%'";
  6886. }
  6887. if ($category) {
  6888. $where .= " and features like '%-$category-%'";
  6889. }
  6890. if ($size) {
  6891. $where .= " and features like '%-$size-%'";
  6892. }
  6893. if ($grade) {
  6894. $where .= " and features like '%-$grade-%'";
  6895. }
  6896. if ($color) {
  6897. $where .= " and features like '%-$color-%'";
  6898. }
  6899. if ($lowe) {
  6900. $where .= " and features like '%-$lowe-%'";
  6901. }
  6902. if ($haircap) {
  6903. $where .= " and features like '%-$haircap-%'";
  6904. }
  6905. if ($density) {
  6906. $where .= " and features like '%-$density-%'";
  6907. }
  6908. if ($usa) {
  6909. if (!$warehouse) {
  6910. $where .= " and (warehouse = '5' or warehouse = '8')";
  6911. }
  6912. }
  6913. if ($warehouse) {
  6914. $where .= " and warehouse = '$warehouse'";
  6915. }
  6916. if ($purchase) {
  6917. $where .= " and purchase = '$purchase'";
  6918. }
  6919. if ($state) {
  6920. $where .= " and state = '$state'";
  6921. }
  6922. if ($ktime && $jtime) {
  6923. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6924. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6925. }
  6926. //数据排序
  6927. $order_str = "id desc";
  6928. $xs = 0;
  6929. $rows = array();
  6930. $list = array();
  6931. if (empty($page)) {
  6932. $start = 0;
  6933. $perpage = 1;
  6934. } else {
  6935. $start = ($page - 1) * $perpage;
  6936. }
  6937. if ($sku || $title) {
  6938. if ($title) {
  6939. $title = trim($title, ' ');
  6940. $title = trim($title, ' ');
  6941. $where .= " and title like '%$title%'";
  6942. } else {
  6943. $sku = trim($sku, ' ');
  6944. $sku = trim($sku, ' ');
  6945. $where .= " and sku like '%$sku%'";
  6946. }
  6947. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6948. foreach ($info_list as $key => $value) {
  6949. $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'] . '"');
  6950. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6951. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6952. $rows[$key] = $value;
  6953. $warehouse = $this->warehouse->read($value['warehouse']);
  6954. $rows[$key]['warehouse'] = $warehouse['title'];
  6955. $rows[$key]['features'] = $g;
  6956. $rows[$key]['a'] = $x;
  6957. $rows[$key]['b'] = $s;
  6958. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6959. $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天销量
  6960. $yj = $c / ($xl / 30);
  6961. if ($yj < 7) {
  6962. $rows[$key]['y'] = round($yj) . '天销量';
  6963. } else {
  6964. $rows[$key]['y'] = '正常';
  6965. }
  6966. }
  6967. } else {
  6968. //$where .= " and time > '$ktime' and time < '$jtime'";
  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. $zs[$key] = $value;
  6975. $warehouse = $this->warehouse->read($value['warehouse']);
  6976. $zs[$key]['warehouse'] = $warehouse['title'];
  6977. $zs[$key]['features'] = $g;
  6978. $zs[$key]['a'] = $x;
  6979. $zs[$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. $zs[$key]['y'] = round($yj) . '天销量';
  6985. $rows[$key] = $zs[$key];
  6986. }
  6987. }
  6988. }
  6989. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  6990. $pagenum = ceil($total / $perpage);
  6991. $over = $total - ($start + $perpage);
  6992. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  6993. echo json_encode($rows);
  6994. exit;
  6995. }
  6996. $this->data['arg_array'] = $arg_array[0];
  6997. $this->_Template('whlabel_fcjxc', $this->data);
  6998. }
  6999. public function _0kcdel()
  7000. {
  7001. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7002. $config['upload_path'] = '.' . $dir;
  7003. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7004. $config['allowed_types'] = 'xls|xlsx|csv';
  7005. $config['max_size'] = 10240;
  7006. $this->load->library('upload', $config);
  7007. $this->upload->initialize($config);
  7008. if ($this->upload->do_upload('userfile')) {
  7009. $full_path = $dir . $this->upload->data('file_name');
  7010. $fileName = '.' . $full_path;
  7011. if (!file_exists($fileName)) {
  7012. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7013. exit;
  7014. } else {
  7015. require_once "./data/excel/PHPExcel/IOFactory.php";
  7016. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7017. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7018. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7019. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7020. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7021. ++$column; //如果列数大于26行
  7022. $list = array();
  7023. for ($i = 2; $i <= $row; $i++) // 行数循环
  7024. {
  7025. $data = array();
  7026. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7027. {
  7028. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7029. }
  7030. $list[] = $data;
  7031. }
  7032. }
  7033. $i = 0;
  7034. $j = 0;
  7035. $ed = array();
  7036. foreach ($list as $key => $value) {
  7037. $time = time();
  7038. if ($value['0'] == "" || $value['1'] == "") {
  7039. continue;
  7040. }
  7041. $warehouse = $this->warehouse->get_title($value['0']);
  7042. $sku = $value['1'];
  7043. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7044. if (!$d) //如果没有这个SKU
  7045. {
  7046. $ed[] = array($sku . '-库存中不存在此SKU');
  7047. $j++;
  7048. continue;
  7049. }
  7050. if (!isset($warehouse['id'])) {
  7051. $ed[] = array($sku . '-仓库名错误!');
  7052. $j++;
  7053. continue;
  7054. }
  7055. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7056. if ($z < 1) {
  7057. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7058. foreach ($z as $v) {
  7059. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7060. if (count($zt) > 0) {
  7061. $ed[] = array($sku . '-有在途库存无法删除!');
  7062. $j++;
  7063. continue;
  7064. }
  7065. $this->whlabel->remove($v['id']);
  7066. }
  7067. } else {
  7068. $ed[] = array($sku . '-非0库存!');
  7069. $j++;
  7070. continue;
  7071. }
  7072. }
  7073. if ($j > 0) {
  7074. $tt = date('Ymd', time());
  7075. $title = '删除0库存错误信息-' . $tt;
  7076. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7077. $tail = "\n";
  7078. $filename = $title . ".xls";
  7079. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7080. $dir = '/data/excel/' . $time . '/';
  7081. $file_name = 'error_' . $time . rand(1000, 9999);
  7082. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7083. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7084. fwrite($myfile, $ecl);
  7085. fclose($myfile);
  7086. $error = $dir . $file_name . '.xls';
  7087. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7088. exit;
  7089. } else {
  7090. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7091. exit;
  7092. }
  7093. }
  7094. }
  7095. public function _gbhtype()
  7096. {
  7097. $post = $this->input->post(NULL, TRUE);
  7098. if (isset($post['s'])) {
  7099. $n = $this->input->post('n');
  7100. $d = $this->input->post('s');
  7101. if (!$d) {
  7102. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7103. exit;
  7104. }
  7105. $d = explode(',', trim($d, ','));
  7106. $t = $this->whlabel_type->read($n);
  7107. //循环删除记录
  7108. foreach ($d as $v) {
  7109. $u = $this->whlabel->read($v);
  7110. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7111. foreach ($data as $val) {
  7112. $this->whlabel->save(array('type' => $n), $val['id']);
  7113. }
  7114. }
  7115. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7116. }
  7117. }
  7118. //出库、退库导出
  7119. public function _dccrtype()
  7120. {
  7121. $classid = $this->classid->sku();
  7122. $pm = $classid;
  7123. $typeclass = array();
  7124. $tc = $this->typeclass->find_all();
  7125. foreach ($tc as $v) {
  7126. $typeclass[$v['id']] = $v;
  7127. }
  7128. $prc = array();
  7129. $purchase = $this->purchase->find_all();
  7130. foreach ($purchase as $k => $v) {
  7131. $prc[$v['id']] = $v['title'];
  7132. }
  7133. if (isset($_GET['sid'])) {
  7134. $wh = array();
  7135. $w = $this->warehouse->find_all('1=1', 'id,title');
  7136. foreach ($w as $v) {
  7137. $wh[$v['id']] = $v['title'];
  7138. }
  7139. $type = $this->input->get('excel', true);
  7140. $category = $this->input->get('category', true);
  7141. $size = $this->input->get('size', true);
  7142. $grade = $this->input->get('grade', true);
  7143. $color = $this->input->get('color', true);
  7144. $lowe = $this->input->get('lowe', true);
  7145. $sku = $this->input->get('sku', true);
  7146. $warehouse = $this->input->get('warehouse', true);
  7147. $lacetype = $this->input->get('lacetype', true);
  7148. $lacecolor = $this->input->get('lacecolor', true);
  7149. $density = $this->input->get('density', true);
  7150. $haircap = $this->input->get('haircap', true);
  7151. $purchase = $this->input->get('purchase', true);
  7152. $title = $this->input->get('title', true);
  7153. $state = $this->input->get('state', true);
  7154. $sid = $this->input->get('sid', true);
  7155. $ktime = $this->input->get('ktime', true);
  7156. $jtime = $this->input->get('jtime', true);
  7157. $ktime = strtotime($ktime);
  7158. $jtime = strtotime($jtime);
  7159. $where = "1=1";
  7160. $gj = "";
  7161. $ck = "";
  7162. if ($category) {
  7163. $where .= " and features like '%-$category-%'";
  7164. }
  7165. if ($size) {
  7166. $where .= " and features like '%-$size-%'";
  7167. }
  7168. if ($grade) {
  7169. $where .= " and features like '%-$grade-%'";
  7170. }
  7171. if ($color) {
  7172. $where .= " and features like '%-$color-%'";
  7173. }
  7174. if ($lowe) {
  7175. $where .= " and features like '%-$lowe-%'";
  7176. }
  7177. if ($warehouse) {
  7178. $where .= " and warehouse = '$warehouse'";
  7179. }
  7180. if ($purchase) {
  7181. $where .= " and purchase = '$purchase'";
  7182. }
  7183. if ($state) {
  7184. $where .= " and state = '$state'";
  7185. }
  7186. if ($lacetype) {
  7187. $where .= " and features like '%-$lacetype-%'";
  7188. }
  7189. if ($lacecolor) {
  7190. $where .= " and features like '%-$lacecolor-%'";
  7191. }
  7192. if ($density) {
  7193. $where .= " and features like '%-$density-%'";
  7194. }
  7195. if ($haircap) {
  7196. $where .= " and features like '%-$haircap-%'";
  7197. }
  7198. if ($title) {
  7199. $title = trim($title, ' ');
  7200. $title = trim($title, ' ');
  7201. $where .= " and title like '%$title%'";
  7202. }
  7203. if ($sku) {
  7204. $sku = trim($sku, ' ');
  7205. $sku = trim($sku, ' ');
  7206. $where .= " and sku like '%$sku%'";
  7207. }
  7208. if ($ktime && $jtime) {
  7209. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7210. }
  7211. $sidwhere = '';
  7212. if ($sid) {
  7213. $sd = "";
  7214. $s = explode(',', trim($sid, ','));
  7215. foreach ($s as $value) {
  7216. $sd .= " id = " . $value . " or";
  7217. }
  7218. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7219. }
  7220. //数据排序
  7221. $order_str = "time desc";
  7222. if (empty($page)) {
  7223. $start = 0;
  7224. $perpage = 1;
  7225. } else {
  7226. $start = ($page - 1) * $perpage;
  7227. }
  7228. $wh = array();
  7229. $w = $this->warehouse->find_all('1=1', 'id,title');
  7230. foreach ($w as $v) {
  7231. $wh[$v['id']] = $v['title'];
  7232. }
  7233. $wt = array();
  7234. $whlabel_type = $this->whlabel_type->find_all();
  7235. foreach ($whlabel_type as $v) {
  7236. $wt[$v['id']] = $v['title'];
  7237. }
  7238. $classid = $this->classid->sku();
  7239. $list = array();
  7240. $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');
  7241. foreach ($rows_r as $key => $value) {
  7242. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7243. $pm = $classid;
  7244. $jm = $classid;
  7245. $rows_r[$key]['enter'] = '入库';
  7246. $rows_r[$key]['time'] = $value['enter'];
  7247. if ($value['rktype'] == 1) {
  7248. $rows_r[$key]['rktype'] = '采购入库';
  7249. } else if ($value['rktype'] == 2) {
  7250. $rows_r[$key]['rktype'] = '盘盈调整';
  7251. } else if ($value['rktype'] == 3) {
  7252. $rows_r[$key]['rktype'] = '其他调整入库';
  7253. } else if ($value['rktype'] == 4) {
  7254. $rows_r[$key]['rktype'] = '其他调整入库';
  7255. } else if ($value['rktype'] == 5) {
  7256. $rows_r[$key]['rktype'] = '退库入库';
  7257. } else if ($value['rktype'] == 6) {
  7258. $rows_r[$key]['rktype'] = '退货可用入库';
  7259. } else if ($value['rktype'] == 7) {
  7260. $rows_r[$key]['rktype'] = '形态转换入库';
  7261. } else {
  7262. $rows_r[$key]['rktype'] = '';
  7263. }
  7264. $features = explode('-', trim($value['features'], '-'));
  7265. foreach ($features as $v) {
  7266. if (isset($typeclass[$v])) {
  7267. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7268. $pm[$typeclass[$v]['classid']] = $zh[0];
  7269. }
  7270. if (isset($typeclass[$v])) {
  7271. if (isset($jm[$typeclass[$v]['classid']])) {
  7272. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7273. }
  7274. }
  7275. }
  7276. $zh = implode(" ", $pm);
  7277. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7278. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7279. $rows_r[$key]['zh'] = $zh;
  7280. $jm = array_filter($jm);
  7281. $rows_r[$key]['features'] = implode("-", $jm);
  7282. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7283. }
  7284. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout');
  7285. foreach ($rows_c as $key => $value) {
  7286. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7287. $pm = $classid;
  7288. $jm = $classid;
  7289. $rows_c[$key]['time'] = $value['outk'];
  7290. $rows_c[$key]['outk'] = '出库';
  7291. if ($value['cktype'] == 1) {
  7292. $rows_c[$key]['cktype'] = '销售出库';
  7293. } else if ($value['cktype'] == 2) {
  7294. $rows_c[$key]['cktype'] = '销售美国出库';
  7295. } else if ($value['cktype'] == 3) {
  7296. $rows_c[$key]['cktype'] = '盘亏调整';
  7297. } else if ($value['cktype'] == 4) {
  7298. $rows_c[$key]['cktype'] = '其他调整出库';
  7299. } else if ($value['cktype'] == 5) {
  7300. $rows_c[$key]['cktype'] = '形态转换出库';
  7301. } else {
  7302. $rows_c[$key]['cktype'] = '';
  7303. }
  7304. $features = explode('-', trim($value['features'], '-'));
  7305. foreach ($features as $v) {
  7306. if (isset($typeclass[$v])) {
  7307. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7308. $pm[$typeclass[$v]['classid']] = $zh[0];
  7309. }
  7310. if (isset($typeclass[$v])) {
  7311. if (isset($jm[$typeclass[$v]['classid']])) {
  7312. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7313. }
  7314. }
  7315. }
  7316. $zh = implode(" ", $pm);
  7317. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7318. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7319. $rows_c[$key]['zh'] = $zh;
  7320. $jm = array_filter($jm);
  7321. $rows_c[$key]['features'] = implode("-", $jm);
  7322. $rows_c[$key]['number'] = 1;
  7323. }
  7324. $merged = $rows_r;
  7325. foreach ($rows_c as $key => $value) {
  7326. if (isset($merged[$key])) {
  7327. $merged[] = $value;
  7328. } else {
  7329. $merged[$key] = $value;
  7330. }
  7331. }
  7332. usort($merged, function ($a, $b) {
  7333. return $a['time'] - $b['time'];
  7334. });
  7335. foreach ($merged as $key => $value) {
  7336. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7337. }
  7338. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7339. $titlename = "<table border=1>
  7340. <tr align='center'>
  7341. <td>仓库</td>
  7342. <td>SKU</td>
  7343. <td>商品名称</td>
  7344. <td>仓库品名</td>
  7345. <td>料号</td>
  7346. <td>时间</td>
  7347. <td>操作</td>
  7348. <td>类型</td>
  7349. <td>数量</td>
  7350. <td>备注</td>
  7351. </tr>
  7352. </table>";
  7353. $filename = $title . ".xlsx";
  7354. $tail = "";
  7355. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7356. }
  7357. }
  7358. }