MainController.php 243 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class MainController extends DooController {
  6. public $staff;
  7. public $nature = array (
  8. '1' => '设计',
  9. '2' => '造价管理',
  10. '3' => '业主',
  11. '4' => '交通局',
  12. '5' => '公路局',
  13. '6' => '审计',
  14. '7' => '财政',
  15. '8' => '审核',
  16. '9' => '施工',
  17. '10' => '咨询',
  18. '11' => '招标代理',
  19. '12' => '监理',
  20. '13' => '学校',
  21. '14' => '个人',
  22. '15' => '合作伙伴'
  23. );
  24. public $tooltip = array (
  25. '1' => array (
  26. 'L',
  27. '点击筛选标签'
  28. ),
  29. '2' => array (
  30. 'M',
  31. '点击筛选标签'
  32. ),
  33. '3' => array (
  34. 'N',
  35. '点击筛选标签'
  36. ),
  37. '4' => array (
  38. 'O',
  39. '点击筛选标签'
  40. ),
  41. '5' => array (
  42. 'P',
  43. '点击筛选标签'
  44. ),
  45. '6' => array (
  46. 'Q',
  47. '点击筛选标签'
  48. ),
  49. '7' => array (
  50. 'R',
  51. '点击筛选标签'
  52. )
  53. );
  54. public $webPath = "http://cld.smartcost.com.cn/upload/emailAnnex/";
  55. function __construct() {
  56. // phpinfo();die;
  57. // include './protected/config/common.conf.php';
  58. // include $config['BASE_PATH'].'diagnostic/debug.php';
  59. if (isset ( $_COOKIE ["staff"] )) {
  60. if (! empty ( $_COOKIE ["staff"] )) {
  61. Doo::loadModel ( 'staff' );
  62. $staff = new staff ();
  63. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  64. return "/";
  65. }
  66. }
  67. Doo::loadCore ( 'uri/DooUriRouter' );
  68. $router = new DooUriRouter ();
  69. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  70. if ($routeRs ['1'] != "login") {
  71. header ( 'Content-Type:text/html;charset=utf-8' );
  72. @header ( "Location: /login" );
  73. }
  74. }
  75. function isMobile() {
  76. // 如果有HTTP_X_WAP_PROFILE则一定是移动设备
  77. if (isset ( $_SERVER ['HTTP_X_WAP_PROFILE'] )) {
  78. return true;
  79. }
  80. // 如果via信息含有wap则一定是移动设备,部分服务商会屏蔽该信息
  81. if (isset ( $_SERVER ['HTTP_VIA'] )) {
  82. // 找不到为flase,否则为true
  83. return stristr ( $_SERVER ['HTTP_VIA'], "wap" ) ? true : false;
  84. }
  85. // 脑残法,判断手机发送的客户端标志,兼容性有待提高
  86. if (isset ( $_SERVER ['HTTP_USER_AGENT'] )) {
  87. $clientkeywords = array (
  88. 'nokia',
  89. 'sony',
  90. 'ericsson',
  91. 'mot',
  92. 'samsung',
  93. 'htc',
  94. 'sgh',
  95. 'lg',
  96. 'sharp',
  97. 'sie-',
  98. 'philips',
  99. 'panasonic',
  100. 'alcatel',
  101. 'lenovo',
  102. 'iphone',
  103. 'ipod',
  104. 'blackberry',
  105. 'meizu',
  106. 'android',
  107. 'netfront',
  108. 'symbian',
  109. 'ucweb',
  110. 'windowsce',
  111. 'palm',
  112. 'operamini',
  113. 'operamobi',
  114. 'openwave',
  115. 'nexusone',
  116. 'cldc',
  117. 'midp',
  118. 'wap',
  119. 'mobile'
  120. );
  121. // 从HTTP_USER_AGENT中查找手机浏览器的关键字
  122. if (preg_match ( "/(" . implode ( '|', $clientkeywords ) . ")/i", strtolower ( $_SERVER ['HTTP_USER_AGENT'] ) )) {
  123. return true;
  124. }
  125. }
  126. // 协议法,因为有可能不准确,放到最后判断
  127. if (isset ( $_SERVER ['HTTP_ACCEPT'] )) {
  128. // 如果只支持wml并且不支持html那一定是移动设备
  129. // 如果支持wml和html但是wml在html之前则是移动设备
  130. if ((strpos ( $_SERVER ['HTTP_ACCEPT'], 'vnd.wap.wml' ) !== false) && (strpos ( $_SERVER ['HTTP_ACCEPT'], 'text/html' ) === false || (strpos ( $_SERVER ['HTTP_ACCEPT'], 'vnd.wap.wml' ) < strpos ( $_SERVER ['HTTP_ACCEPT'], 'text/html' )))) {
  131. return true;
  132. }
  133. }
  134. return false;
  135. }
  136. /**
  137. * 优化actionLog表
  138. */
  139. function backUpActionLog() {
  140. Doo::loadModel ( 'action_log' );
  141. $action_log = new action_log ();
  142. $date = date ( "Y" );
  143. $tableName = 'CLD_action_log' . $date;
  144. $action_log->copyActionLogToBakTable ( $tableName );
  145. $action_log = new action_log ();
  146. $aid = 0;
  147. $action_log->delActionLogByAid ( $aid );
  148. }
  149. function login() {
  150. $passwork = $this->get_args ( 'passwork' ) ? $this->get_args ( 'passwork' ) : 0;
  151. $uid = $this->get_args ( 'user' ) ? $this->get_args ( 'user' ) : 0;
  152. Doo::loadModel ( 'staff' );
  153. $staff = new staff ();
  154. Doo::loadClass ( 'XDeode' );
  155. $XDeode = new XDeode ( 5 );
  156. if (! empty ( $passwork )) {
  157. $userinfo = $staff->checkUser ( $uid, $passwork );
  158. if (! empty ( $userinfo )) {
  159. setcookie ( "staff", $XDeode->encode ( $userinfo [0] ['sid'] ), time () + 36000, "/" );
  160. return "/";
  161. }
  162. }
  163. $data ['staff'] = ""; // $staff->getUser ();
  164. $data ['login'] = "";
  165. if (! empty ( $passwork ))
  166. $data ['login'] = "inputErrow";
  167. $this->render ( "/login", $data );
  168. }
  169. function out() {
  170. setcookie ( "staff", "", time () - 3600, "/" );
  171. return "/";
  172. }
  173. function test() {
  174. // 实例化redis
  175. }
  176. function index2() {
  177. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  178. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  179. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  180. $page = $this->get_args ( 'page' ) ? $this->get_args ( 'page' ) : 1;
  181. Doo::loadModel ( 'action_log' );
  182. $action_log = new action_log ();
  183. Doo::loadModel ( 'staff' );
  184. $staff = new staff ();
  185. Doo::loadModel ( 'client_staff' );
  186. $client_staff = new client_staff ();
  187. Doo::loadModel ( 'longle' );
  188. $longle = new longle ();
  189. Doo::loadModel ( 'L_category' );
  190. $lcategory = new L_category ();
  191. $limit = 50;
  192. $p = $page;
  193. if ($page != 1)
  194. $page = $page * $limit - 1;
  195. else
  196. $page --;
  197. $condition = "";
  198. // if (!empty($cid) && $cid != 12) {
  199. // $condition = " and cid=" . $cid . " and sid=" . $sid;
  200. // }
  201. $staffCondition = "";
  202. $categorylist2 = array ();
  203. if ($this->staff [0] ['cid'] != 12) {
  204. $staffCondition = " and cid=" . $this->staff [0] ['cid'];
  205. array_push ( $categorylist2, array (
  206. 'cid' => $this->staff [0] ['cid'],
  207. 'title' => $this->staff [0] ['category']
  208. ) );
  209. if (! empty ( $sid ))
  210. $condition = " and cid=" . $this->staff [0] ['cid'] . " and sid=" . $sid;
  211. else
  212. $condition = " and cid=" . $this->staff [0] ['cid'];
  213. } else {
  214. $sql = 'SELECT `CLD_L_category`.cid,`CLD_L_category`.title,count(`CLD_staff`.sid) as count FROM `CLD_L_category` left join `CLD_staff` on `CLD_L_category`.cid=`CLD_staff`.cid group by `CLD_staff`.cid HAVING count(`CLD_staff`.sid)>0 order by count(`CLD_staff`.sid) desc';
  215. $query = Doo::db ()->query ( $sql );
  216. $result = $query->fetchAll ();
  217. $categorylist2 = $result;
  218. }
  219. // 有待优化
  220. Doo::loadModel ( 'department' );
  221. $department = new department ();
  222. $categorylist3 = $categorylist2;
  223. $bakCategory = array ();
  224. foreach ( $categorylist3 as $key => $value ) {
  225. $departList = $department->getDepartmentBycid ( $value ['cid'] );
  226. if (! empty ( $departList )) {
  227. // $bakCategory=$categorylist2[$key];
  228. array_unshift ( $bakCategory, $value );
  229. unset ( $categorylist2 [$key] );
  230. foreach ( $departList as $v ) {
  231. array_unshift ( $bakCategory, array (
  232. 'cid' => $v ['cid'],
  233. 'title' => $value ['title'],
  234. 'count' => $value ['count'],
  235. 'did' => $v ['did'],
  236. 'departmentName' => $v ['departmentName']
  237. ) );
  238. }
  239. }
  240. }
  241. foreach ( $bakCategory as $value ) {
  242. array_unshift ( $categorylist2, $value );
  243. }
  244. $data ['did'] = '';
  245. if (! empty ( $cid )) {
  246. $staffCondition = " and cid=" . $cid;
  247. if (! is_numeric ( $cid )) {
  248. $cdid = explode ( '-', $cid );
  249. $cid = $cdid [0];
  250. $data ['did'] = $cdid [1];
  251. $staffCondition = " and cid=" . $cid . " and departmentID=" . $cdid [1];
  252. }
  253. if (! empty ( $sid ))
  254. $condition = " and cid=" . $cid . " and sid=" . $sid;
  255. else
  256. $condition = " and cid=" . $cid;
  257. }
  258. /*
  259. * $itemCategoryList=$action_log->find(array('select'=>'updatetime,COUNT(*)', 'where'=>" Year(updatetime)=2014",'groupby'=>'Month(updatetime)','asArray'=>true)); print_r($itemCategoryList);die;
  260. */
  261. $staffList = $staff->find ( array (
  262. 'where' => ' username!="admin" ' . $staffCondition,
  263. 'asArray' => true
  264. ) );
  265. $alCondition = ' aid>' . REMIT . ' ';
  266. $actionLogList = $action_log->find ( array (
  267. 'where' => $alCondition . $condition,
  268. 'limit' => $page . ',' . $limit,
  269. 'desc' => 'aid',
  270. 'asArray' => true
  271. ) );
  272. // echo $condition;
  273. // 抽取日期 ,'groupby'=>'updatetime'
  274. $dateLog = $action_log->find ( array (
  275. 'select' => 'updatetime',
  276. 'where' => $alCondition . $condition,
  277. 'limit' => $limit,
  278. 'desc' => 'aid',
  279. 'asArray' => true
  280. ) );
  281. $dl = array ();
  282. foreach ( $dateLog as $value ) {
  283. array_push ( $dl, $value ['updatetime'] );
  284. }
  285. $dateLog = array_unique ( $dl );
  286. $log = array ();
  287. foreach ( $dateLog as $key => $value ) {
  288. $log [$value] = array ();
  289. foreach ( $actionLogList as $k => $v ) {
  290. if ($value == $v ['updatetime']) {
  291. array_push ( $log [$value], $v );
  292. unset ( $actionLogList [$k] );
  293. }
  294. }
  295. }
  296. $max = array ();
  297. foreach ( $staffList as $key => $value ) {
  298. $staffList [$key] ['count'] = $client_staff->count ( array (
  299. 'where' => 'sid=' . $value ['sid'],
  300. 'asArray' => true
  301. ) );
  302. array_push ( $max, $staffList [$key] ['count'] . ':' . $value ['username'] );
  303. }
  304. rsort ( $max, SORT_NUMERIC );
  305. $sum = 0;
  306. foreach ( $max as $key => $value ) {
  307. $max [$key] = explode ( ":", $value );
  308. $sum += $max [$key] [0];
  309. }
  310. $max2 = $max;
  311. array_shift ( $max2 );
  312. array_shift ( $max2 );
  313. array_shift ( $max2 );
  314. $lcategoryList = $lcategory->find ( array (
  315. 'asArray' => true
  316. ) );
  317. $useL = array ();
  318. $Rsum = $Ssum = 0;
  319. foreach ( $lcategoryList as $key => $value ) {
  320. $longleR = $longle->count ( array (
  321. 'where' => 'cid=' . $value ['cid'],
  322. 'asArray' => true
  323. ) );
  324. $longleS = $longle->count ( array (
  325. 'where' => 'cid=' . $value ['cid'] . ' and status!=1 and status!=2',
  326. 'asArray' => true
  327. ) );
  328. $Rsum += $longleR;
  329. $Ssum += $longleS;
  330. if (! empty ( $longleS ))
  331. array_push ( $useL, round ( ($longleS / $longleR) * 100 ) . '% :' . $value ['title'] );
  332. else
  333. array_push ( $useL, '0% :' . $value ['title'] );
  334. }
  335. rsort ( $useL, SORT_NUMERIC ); // $sum=0;
  336. foreach ( $useL as $key => $value ) {
  337. $useL [$key] = explode ( ":", $value );
  338. // $sum+=$max[$key][0];
  339. }
  340. $useL2 = $useL;
  341. array_shift ( $useL2 );
  342. array_shift ( $useL2 );
  343. array_shift ( $useL2 );
  344. $data ['Ssum'] = round ( ($Ssum / $Rsum) * 100 ) . '%';
  345. $data ['Rsum'] = $Rsum;
  346. $data ['useL2'] = $useL2;
  347. $data ['useL'] = $useL;
  348. $data ['sum'] = $sum;
  349. $data ['max'] = $max;
  350. $data ['max2'] = $max2;
  351. $data ['log'] = $log;
  352. $data ['page'] = $p;
  353. $data ['staffList'] = $staffList;
  354. $data ['categorylist2'] = $categorylist2;
  355. $data ['cid'] = $cid;
  356. $data ['sid'] = $sid;
  357. $data ['memu'] = "index";
  358. $data ['staff'] = $this->staff;
  359. $this->render ( "index2", $data );
  360. }
  361. function indexPage() {
  362. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  363. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  364. $page = $this->get_args ( 'page' ) ? $this->get_args ( 'page' ) : 1;
  365. Doo::loadModel ( 'action_log' );
  366. $action_log = new action_log ();
  367. $limit = 50;
  368. $p = $page;
  369. // if ($page!=1)
  370. // $page=$page*$limit-1;
  371. // else
  372. // $page--;
  373. $page = (-- $p) * $limit;
  374. /*
  375. * $condition=""; if (!empty($cid)&&$cid!=12){ $condition=" and cid=".$cid; } $staffCondition=""; if($this->staff[0]['cid']!=12){ $staffCondition=" and cid=".$this->staff[0]['cid']; $condition=" and cid=".$this->staff[0]['cid']; }
  376. */
  377. $condition = "";
  378. if (! empty ( $cid ) && $cid != 12) {
  379. $condition = " and cid=" . $cid . " and sid=" . $sid;
  380. }
  381. $staffCondition = "";
  382. if ($this->staff [0] ['cid'] != 12) {
  383. $staffCondition = " and cid=" . $this->staff [0] ['cid'];
  384. if (! empty ( $sid ))
  385. $condition = " and cid=" . $this->staff [0] ['cid'] . " and sid=" . $sid;
  386. else
  387. $condition = " and cid=" . $this->staff [0] ['cid'];
  388. }
  389. $actionLogList = $action_log->find ( array (
  390. 'where' => ' 1 ' . $condition,
  391. 'limit' => $page . ',' . $limit,
  392. 'desc' => 'aid',
  393. 'asArray' => true
  394. ) );
  395. // 抽取日期 ,'groupby'=>'updatetime'
  396. $dateLog = $action_log->find ( array (
  397. 'select' => 'updatetime',
  398. 'where' => ' 1 ' . $condition,
  399. 'limit' => $page . ',' . $limit,
  400. 'desc' => 'aid',
  401. 'asArray' => true
  402. ) );
  403. $dl = array ();
  404. foreach ( $dateLog as $value ) {
  405. array_push ( $dl, $value ['updatetime'] );
  406. }
  407. $dateLog = array_unique ( $dl );
  408. $log = array ();
  409. foreach ( $dateLog as $key => $value ) {
  410. $log [$value] = array ();
  411. foreach ( $actionLogList as $k => $v ) {
  412. if ($value == $v ['updatetime']) {
  413. array_push ( $log [$value], $v );
  414. unset ( $actionLogList [$k] );
  415. }
  416. }
  417. }
  418. $html = '';
  419. foreach ( $log as $key => $value ) {
  420. $html .= '<div class="item">
  421. <div class="date">' . $key . '</div>
  422. <dl class="recordList clearfix">';
  423. foreach ( $value as $k => $v ) {
  424. $html .= '<dd class="' . $v ['class'] . '"><span class="fR">' . $v ['time'] . '</span>' . $v ['action'] . '</dd>';
  425. }
  426. $html .= '</dl></div>';
  427. }
  428. echo $html;
  429. }
  430. function logStatistics() {
  431. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  432. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  433. Doo::loadModel ( 'action_log' );
  434. $action_log = new action_log ();
  435. Doo::loadModel ( 'staff' );
  436. $staff = new staff ();
  437. Doo::loadModel ( 'client_staff' );
  438. $client_staff = new client_staff ();
  439. Doo::loadModel ( 'longle' );
  440. $longle = new longle ();
  441. Doo::loadModel ( 'L_category' );
  442. $lcategory = new L_category ();
  443. Doo::loadModel ( 'department' );
  444. $department = new department ();
  445. $redis = new Redis ();
  446. $redis->connect ( '127.0.0.1', '6379' ); // 120.27.200.79
  447. $staffCondition = "";
  448. $categorylist2 = array ();
  449. if ($this->staff [0] ['cid'] != 12) {
  450. $staffCondition = " and cid=" . $this->staff [0] ['cid'];
  451. // array_push ( $categorylist2, array (
  452. // 'cid' => $this->staff [0] ['cid'],
  453. // 'title' => $this->staff [0] ['category']
  454. // ) );
  455. $otherC = $lcategory->getCategoryById ( $this->staff [0] ['cid'], $this->staff [0] ['othercid'] );
  456. foreach ( $otherC as $value ) {
  457. array_push ( $categorylist2, array (
  458. 'cid' => $value ['cid'],
  459. 'title' => $value ['title']
  460. ) );
  461. }
  462. } else {
  463. $sql = 'SELECT `CLD_L_category`.cid,`CLD_L_category`.title,count(`CLD_staff`.sid) as count FROM `CLD_L_category` left join `CLD_staff` on `CLD_L_category`.cid=`CLD_staff`.cid group by `CLD_staff`.cid HAVING count(`CLD_staff`.sid)>0 order by count(`CLD_staff`.sid) desc';
  464. $query = Doo::db ()->query ( $sql );
  465. $result = $query->fetchAll ();
  466. $categorylist2 = $result;
  467. // $otherC=$lcategory->getCategoryById($this->staff [0] ['cid'],$this->staff [0] ['othercid']);
  468. }
  469. // print_r($categorylist2);
  470. // 有待优化
  471. $categorylist3 = $categorylist2;
  472. $bakCategory = array ();
  473. foreach ( $categorylist3 as $key => $value ) {
  474. $departList = $department->getDepartmentBycid ( $value ['cid'] );
  475. if (! empty ( $departList )) {
  476. // $bakCategory=$categorylist2[$key];
  477. array_unshift ( $bakCategory, $value );
  478. unset ( $categorylist2 [$key] );
  479. foreach ( $departList as $v ) {
  480. array_unshift ( $bakCategory, array (
  481. 'cid' => $v ['cid'],
  482. 'title' => $value ['title'],
  483. 'count' => $value ['count'],
  484. 'did' => $v ['did'],
  485. 'departmentName' => $v ['departmentName']
  486. ) );
  487. }
  488. }
  489. }
  490. foreach ( $bakCategory as $value ) {
  491. array_unshift ( $categorylist2, $value );
  492. }
  493. // array_unshift($categorylist2,$bakCategory);
  494. // print_r($categorylist2);
  495. $did = $data ['did'] = '';
  496. $othercateSql = '';
  497. if (! empty ( $this->staff [0] ['othercid'] ))
  498. $othercateSql = " or (othercid like '" . $this->staff [0] ['othercid'] . "')";
  499. if (! empty ( $cid )) { //
  500. if (is_numeric ( $cid ))
  501. $staffCondition = " and cid=" . $cid . $othercateSql;
  502. else {
  503. $cdid = explode ( '-', $cid );
  504. $cid = $cdid [0];
  505. $data ['did'] = $did = $cdid [1];
  506. $staffCondition = " and cid=" . $cdid [0] . " and departmentID=" . $cdid [1] . $othercateSql;
  507. }
  508. }
  509. // echo $staffCondition;
  510. // echo $staffCondition;
  511. // Doo::db()->beginTransaction();
  512. $staffList = $staff->find ( array (
  513. 'where' => ' username !="admin"' . $staffCondition,
  514. 'asArray' => true
  515. ) );
  516. $max = array ();
  517. $sum = 0;
  518. // 客户总数
  519. $redisKey = date ( 'Y-m-d' ) . '_logStatisticsCSum_' . $this->staff [0] ['cid'];
  520. $redisValue = $redis->lrange ( $redisKey, 0, - 1 );
  521. if (empty ( $redisValue )) {
  522. $kkk = array ();
  523. foreach ( $staffList as $key => $value ) {
  524. $staffList [$key] ['count'] = $client_staff->count ( array (
  525. 'where' => 'sid=' . $value ['sid'],
  526. 'asArray' => true
  527. ) );
  528. array_push ( $max, $staffList [$key] ['count'] . ':' . $value ['username'] );
  529. if ($this->staff [0] ['cid'] == 12)
  530. array_push ( $kkk, $staffList [$key] ['count'] );
  531. if ($this->staff [0] ['cid'] == $value ['cid'] && $this->staff [0] ['cid'] != 12) {
  532. array_push ( $kkk, $staffList [$key] ['count'] );
  533. }
  534. }
  535. foreach ( $kkk as $key => $value ) {
  536. $sum += $value;
  537. }
  538. $sortMaxStr = json_encode ( $max );
  539. $redis->lpush ( $redisKey, $sum );
  540. $redis->lpush ( $redisKey, $sortMaxStr );
  541. } else {
  542. $sum = $redisValue [1];
  543. $max = json_decode ( $redisValue [0], true );
  544. }
  545. rsort ( $max, SORT_NUMERIC );
  546. foreach ( $max as $key => $value ) {
  547. $max [$key] = explode ( ":", $value );
  548. // $sum+=$max[$key][0];
  549. }
  550. $max2 = $max;
  551. array_shift ( $max2 );
  552. array_shift ( $max2 );
  553. array_shift ( $max2 );
  554. $lcategoryList = $lcategory->find ( array (
  555. 'asArray' => true
  556. ) );
  557. $useL = array ();
  558. $Rsum = $Ssum = 0;
  559. $redisKey = date ( 'Y-m-d' ) . '_logStatisticsLongle';
  560. $redisValue = $redis->lrange ( $redisKey, 0, - 1 );
  561. if (empty ( $redisValue )) {
  562. foreach ( $lcategoryList as $key => $value ) {
  563. $longleR = $longle->count ( array (
  564. 'where' => 'cid=' . $value ['cid'],
  565. 'asArray' => true
  566. ) );
  567. $longleS = $longle->count ( array (
  568. 'where' => 'cid=' . $value ['cid'] . ' and status!=1 and status!=2',
  569. 'asArray' => true
  570. ) );
  571. $Rsum += $longleR;
  572. $Ssum += $longleS;
  573. if (! empty ( $longleS ))
  574. array_push ( $useL, round ( ($longleS / $longleR) * 100 ) . '% :' . $value ['title'] );
  575. else
  576. array_push ( $useL, '0% :' . $value ['title'] );
  577. }
  578. $useLStr = json_encode ( $useL );
  579. $redis->lpush ( $redisKey, $Rsum );
  580. $redis->lpush ( $redisKey, $Ssum );
  581. $redis->lpush ( $redisKey, $useLStr );
  582. } else {
  583. $useL = $redisValue [0];
  584. $useL = json_decode ( $useL, true );
  585. $Ssum = $redisValue [1];
  586. $Rsum = $redisValue [2];
  587. }
  588. rsort ( $useL, SORT_NUMERIC );
  589. foreach ( $useL as $key => $value ) {
  590. $useL [$key] = explode ( ":", $value );
  591. }
  592. $useL2 = $useL;
  593. array_shift ( $useL2 );
  594. array_shift ( $useL2 );
  595. array_shift ( $useL2 );
  596. // statistics
  597. // 30天操作日志数
  598. $categoryCondition = " and cid=" . $this->staff [0] ['cid'];
  599. $redisCid = $this->staff [0] ['cid'];
  600. $sidCondition = $redisSid = "";
  601. if (! empty ( $cid )) {
  602. $categoryCondition = " and cid=" . $cid;
  603. $redisCid = $cid;
  604. }
  605. if (! empty ( $sid )) {
  606. $redisSid = $sid;
  607. $sidCondition = " and sid=" . $sid;
  608. }
  609. if ($this->staff [0] ['cid'] == 12 && empty ( $cid )) {
  610. $categoryCondition = "";
  611. $redisCid = '';
  612. }
  613. $redisKey = date ( 'Y-m-d' ) . 'SL_' . $redisCid . '_' . $redisSid;
  614. $redisValue = $redis->get ( $redisKey );
  615. if (empty ( $redisValue )) {
  616. $actionLogLongle = $action_log->find ( array (
  617. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  618. 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=3" . $categoryCondition . $sidCondition,
  619. 'groupby' => 'date_format(updatetime,"%m-%d")',
  620. 'asArray' => true
  621. ) );
  622. $statisticsLongle = array ();
  623. for($d = 0; $d <= 29; $d ++) {
  624. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  625. $falgLongle = true;
  626. foreach ( $actionLogLongle as $value ) {
  627. if ($value ['updatetime'] == $MD) {
  628. array_push ( $statisticsLongle, $value ['count'] );
  629. $falgLongle = false;
  630. break;
  631. }
  632. }
  633. if ($falgLongle)
  634. array_push ( $statisticsLongle, 0 );
  635. }
  636. $statisticsLongle = array_reverse ( $statisticsLongle );
  637. $jsl = json_encode ( $statisticsLongle );
  638. $redis->set ( $redisKey, $jsl );
  639. $data ['statisticsLongle'] = $jsl;
  640. } else {
  641. $data ['statisticsLongle'] = $redisValue;
  642. }
  643. // 添加客户 数30天
  644. $redisKey = date ( 'Y-m-d' ) . 'SC_' . $redisCid . '_' . $redisSid;
  645. // echo $redisKey;
  646. // echo "<br/> date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=1" . $categoryCondition . $sidCondition;
  647. $redisValue = $redis->get ( $redisKey );
  648. if (empty ( $redisValue )) {
  649. $actionLogClient = $action_log->find ( array (
  650. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  651. 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=1" . $categoryCondition . $sidCondition,
  652. 'groupby' => 'date_format(updatetime,"%m-%d")',
  653. 'asArray' => true
  654. ) );
  655. $statisticsClient = array ();
  656. for($d = 0; $d <= 29; $d ++) {
  657. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  658. $falgClient = true;
  659. foreach ( $actionLogClient as $value ) {
  660. if ($value ['updatetime'] == $MD) {
  661. array_push ( $statisticsClient, $value ['count'] );
  662. $falgClient = false;
  663. break;
  664. }
  665. }
  666. if ($falgClient)
  667. array_push ( $statisticsClient, 0 );
  668. }
  669. $statisticsClient = array_reverse ( $statisticsClient );
  670. $jsc = json_encode ( $statisticsClient );
  671. $redis->set ( $redisKey, $jsc );
  672. $data ['statisticsClient'] = $jsc;
  673. } else {
  674. $data ['statisticsClient'] = $redisValue;
  675. }
  676. $statisticsDay = array ();
  677. for($d = 0; $d <= 29; $d ++) {
  678. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  679. array_push ( $statisticsDay, $MD );
  680. }
  681. $statisticsDay = array_reverse ( $statisticsDay );
  682. // / Year(updatetime)=".date('Y')." and Month(updatetime)=".date('m')." and
  683. $categoryList = $lcategory->find ( array (
  684. 'asArray' => true
  685. ) );
  686. // 最近30天区域分布图
  687. $redisKey = date ( 'Y-m-d' ) . 'SCCT_' . $redisCid . '_' . $redisSid;
  688. $redisValue = $redis->lrange ( $redisKey, 0, - 1 );
  689. if (empty ( $redisValue )) {
  690. $CategoryClient = $action_log->find ( array (
  691. 'select' => 'cid,COUNT(*) as count,city',
  692. 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=1" . $categoryCondition . $sidCondition,
  693. 'groupby' => 'cid',
  694. 'asArray' => true
  695. ) );
  696. $CategoryCompany = $action_log->find ( array (
  697. 'select' => 'cid, COUNT(*) as count,company,districtid',
  698. 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and (status=1 )" . $categoryCondition . $sidCondition,
  699. 'groupby' => 'cid,districtid,company',
  700. 'asArray' => true
  701. ) );
  702. $statisticsCategory = array ();
  703. $statisticsCompany = array ();
  704. foreach ( $categoryList as $value ) {
  705. $falgClient = $falgLongle = true;
  706. foreach ( $CategoryClient as $v ) {
  707. if ($value ['cid'] == $v ['cid'] && $v ['cid'] != 12) {
  708. array_push ( $statisticsCategory, array (
  709. 'value' => $v ['count'],
  710. 'name' => str_replace ( "办", "省", $value ['title'] )
  711. ) );
  712. $falgClient = false;
  713. break;
  714. }
  715. }
  716. if ($falgClient) {
  717. array_push ( $statisticsCategory, array (
  718. 'value' => 0,
  719. 'name' => str_replace ( "办", "省", $value ['title'] )
  720. ) );
  721. }
  722. // company statistics
  723. $i = 0;
  724. foreach ( $CategoryCompany as $v ) {
  725. if ($value ['cid'] == $v ['cid'] && $v ['cid'] != 12) {
  726. $i ++;
  727. }
  728. }
  729. array_push ( $statisticsCompany, array (
  730. 'value' => $i,
  731. 'name' => str_replace ( "办", "省", $value ['title'] )
  732. ) );
  733. }
  734. $scctA = json_encode ( $statisticsCompany );
  735. $scctB = json_encode ( $statisticsCategory );
  736. $redis->lpush ( $redisKey, $scctA );
  737. $redis->lpush ( $redisKey, $scctB );
  738. $data ['statisticsCompany'] = $scctA;
  739. $data ['statisticsCategory'] = $scctB;
  740. } else {
  741. $data ['statisticsCompany'] = $redisValue [1];
  742. $data ['statisticsCategory'] = $redisValue [0];
  743. }
  744. // print_r($CategoryClient);
  745. $redisKey = date ( 'Y-m-d' ) . 'SN_' . $redisCid . '_' . $redisSid;
  746. $redisValue = $redis->get ( $redisKey );
  747. if (empty ( $redisValue )) {
  748. $natureList = $action_log->find ( array (
  749. 'select' => 'cid, COUNT(*) as count,nature',
  750. 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=1 and nature !=''" . $categoryCondition . $sidCondition,
  751. 'groupby' => 'nature',
  752. 'asArray' => true
  753. ) );
  754. $statisticsNature = array ();
  755. foreach ( $this->nature as $value ) {
  756. $flagNature = true;
  757. foreach ( $natureList as $v ) {
  758. if ($value == $v ['nature']) {
  759. array_push ( $statisticsNature, array (
  760. 'value' => $v ['count'],
  761. 'name' => $value
  762. ) );
  763. $flagNature = false;
  764. break;
  765. }
  766. }
  767. if ($flagNature)
  768. array_push ( $statisticsNature, array (
  769. 'value' => 0,
  770. 'name' => $value
  771. ) );
  772. }
  773. $jsn = json_encode ( $statisticsNature );
  774. $redis->set ( $redisKey, $jsn );
  775. $data ['statisticsNature'] = $jsn;
  776. } else {
  777. $data ['statisticsNature'] = $redisValue;
  778. }
  779. $data ['statisticsDay'] = json_encode ( $statisticsDay );
  780. $data ['categorylist2'] = $categorylist2;
  781. $data ['Ssum'] = round ( ($Ssum / $Rsum) * 100 ) . '%';
  782. $data ['Rsum'] = $Rsum;
  783. $data ['useL2'] = $useL2;
  784. $data ['useL'] = $useL;
  785. $data ['sum'] = $sum;
  786. $data ['max'] = $max;
  787. $data ['max2'] = $max2;
  788. $data ['staffList'] = $staffList;
  789. $data ['cid'] = $cid;
  790. $data ['sid'] = $sid;
  791. $data ['memu'] = "index";
  792. $data ['staff'] = $this->staff;
  793. $this->render ( "/indexStat", $data );
  794. }
  795. function longleStatistics() {
  796. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  797. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  798. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 4;
  799. $districtH = $this->get_args ( 'district' ) ? $this->get_args ( 'district' ) : 0;
  800. Doo::loadModel ( 'action_log' );
  801. $action_log = new action_log ();
  802. Doo::loadModel ( 'staff' );
  803. $staff = new staff ();
  804. Doo::loadModel ( 'client_staff' );
  805. $client_staff = new client_staff ();
  806. Doo::loadModel ( 'longle' );
  807. $longle = new longle ();
  808. Doo::loadModel ( 'L_category' );
  809. $lcategory = new L_category ();
  810. Doo::loadModel ( 'district' );
  811. $district = new district ();
  812. $staffCondition = "";
  813. $categorylist2 = array ();
  814. if ($this->staff [0] ['cid'] != 12) {
  815. $staffCondition = " and cid=" . $this->staff [0] ['cid'];
  816. array_push ( $categorylist2, array (
  817. 'cid' => $this->staff [0] ['cid'],
  818. 'title' => $this->staff [0] ['category']
  819. ) );
  820. } else {
  821. $sql = 'SELECT `CLD_L_category`.cid,`CLD_L_category`.title,count(`CLD_staff`.sid) as count FROM `CLD_L_category` left join `CLD_staff` on `CLD_L_category`.cid=`CLD_staff`.cid group by `CLD_staff`.cid HAVING count(`CLD_staff`.sid)>0 order by count(`CLD_staff`.sid) desc';
  822. $query = Doo::db ()->query ( $sql );
  823. $result = $query->fetchAll ();
  824. $categorylist2 = $result;
  825. }
  826. // 有待优化
  827. Doo::loadModel ( 'department' );
  828. $department = new department ();
  829. $categorylist3 = $categorylist2;
  830. $bakCategory = array ();
  831. foreach ( $categorylist3 as $key => $value ) {
  832. $departList = $department->getDepartmentBycid ( $value ['cid'] );
  833. if (! empty ( $departList )) {
  834. // $bakCategory=$categorylist2[$key];
  835. array_unshift ( $bakCategory, $value );
  836. unset ( $categorylist2 [$key] );
  837. foreach ( $departList as $v ) {
  838. array_unshift ( $bakCategory, array (
  839. 'cid' => $v ['cid'],
  840. 'title' => $value ['title'],
  841. 'count' => $value ['count'],
  842. 'did' => $v ['did'],
  843. 'departmentName' => $v ['departmentName']
  844. ) );
  845. }
  846. }
  847. }
  848. foreach ( $bakCategory as $value ) {
  849. array_unshift ( $categorylist2, $value );
  850. }
  851. $data ['did'] = '';
  852. if (! empty ( $cid )) {
  853. if (is_numeric ( $cid ))
  854. $staffCondition = " and cid=" . $cid;
  855. else {
  856. $cdid = explode ( '-', $cid );
  857. $cid = $cdid [0];
  858. $data ['did'] = $cdid [1];
  859. $staffCondition = " and cid=" . $cdid [0] . " and departmentID=" . $cdid [1];
  860. }
  861. // $staffCondition = " and cid=" . $cid;
  862. }
  863. $staffList = $staff->find ( array (
  864. 'where' => ' username!="admin"' . $staffCondition,
  865. 'asArray' => true
  866. ) );
  867. $max = array ();
  868. foreach ( $staffList as $key => $value ) {
  869. $staffList [$key] ['count'] = $client_staff->count ( array (
  870. 'where' => 'sid=' . $value ['sid'],
  871. 'asArray' => true
  872. ) );
  873. array_push ( $max, $staffList [$key] ['count'] . ':' . $value ['username'] );
  874. }
  875. rsort ( $max, SORT_NUMERIC );
  876. $sum = 0;
  877. foreach ( $max as $key => $value ) {
  878. $max [$key] = explode ( ":", $value );
  879. $sum += $max [$key] [0];
  880. }
  881. $max2 = $max;
  882. array_shift ( $max2 );
  883. array_shift ( $max2 );
  884. array_shift ( $max2 );
  885. $lcategoryList = $lcategory->find ( array (
  886. 'asArray' => true
  887. ) );
  888. $useL = array ();
  889. $Rsum = $Ssum = 0;
  890. foreach ( $lcategoryList as $key => $value ) {
  891. $longleR = $longle->count ( array (
  892. 'where' => 'cid=' . $value ['cid'],
  893. 'asArray' => true
  894. ) );
  895. $longleS = $longle->count ( array (
  896. 'where' => 'cid=' . $value ['cid'] . ' and status!=1 and status!=2',
  897. 'asArray' => true
  898. ) );
  899. $Rsum += $longleR;
  900. $Ssum += $longleS;
  901. if (! empty ( $longleS ))
  902. array_push ( $useL, round ( ($longleS / $longleR) * 100 ) . '% :' . $value ['title'] );
  903. else
  904. array_push ( $useL, '0% :' . $value ['title'] );
  905. }
  906. rsort ( $useL, SORT_NUMERIC ); // $sum=0;
  907. foreach ( $useL as $key => $value ) {
  908. $useL [$key] = explode ( ":", $value );
  909. // $sum+=$max[$key][0];
  910. }
  911. $useL2 = $useL;
  912. array_shift ( $useL2 );
  913. array_shift ( $useL2 );
  914. array_shift ( $useL2 );
  915. // statistics
  916. $categoryCondition = " and cid=" . $this->staff [0] ['cid'];
  917. $sidCondition = "";
  918. if (! empty ( $cid ))
  919. $categoryCondition = " and cid=" . $cid;
  920. if (! empty ( $sid ))
  921. $sidCondition = " and sid=" . $sid;
  922. if ($this->staff [0] ['cid'] == 12 && empty ( $cid )) {
  923. $categoryCondition = "";
  924. }
  925. // Year(updatetime)=".date('Y')." and Month(updatetime)=".date('m')." date_format(updatetime,"%m-%d") Day(updatetime)
  926. $actionLogClient = $action_log->find ( array (
  927. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  928. 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=4" . $categoryCondition . $sidCondition,
  929. 'groupby' => 'Day(updatetime)',
  930. 'asArray' => true
  931. ) );
  932. $actionLogLongle = $action_log->find ( array (
  933. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  934. 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=5" . $categoryCondition . $sidCondition,
  935. 'groupby' => 'Day(updatetime)',
  936. 'asArray' => true
  937. ) );
  938. $actionLogGet = $action_log->find ( array (
  939. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  940. 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=6" . $categoryCondition . $sidCondition,
  941. 'groupby' => 'Day(updatetime)',
  942. 'asArray' => true
  943. ) );
  944. $statisticsDay = array ();
  945. $statisticsClient = $statisticsLongle = $statisticsGet = array ();
  946. /**
  947. * for ($d=1;$d<=date("t");$d++){ $MD=date('m')."-".$d;
  948. */
  949. for($d = 0; $d <= 29; $d ++) {
  950. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  951. $falgClient = $falgLongle = $falgGet = true;
  952. array_push ( $statisticsDay, $MD );
  953. foreach ( $actionLogClient as $value ) {
  954. if ($value ['updatetime'] == $MD) {
  955. array_push ( $statisticsClient, $value ['count'] );
  956. $falgClient = false;
  957. break;
  958. }
  959. }
  960. if ($falgClient)
  961. array_push ( $statisticsClient, 0 );
  962. foreach ( $actionLogLongle as $value ) {
  963. if ($value ['updatetime'] == $MD) {
  964. array_push ( $statisticsLongle, $value ['count'] );
  965. $falgLongle = false;
  966. break;
  967. }
  968. }
  969. if ($falgLongle)
  970. array_push ( $statisticsLongle, 0 );
  971. foreach ( $actionLogGet as $value ) {
  972. if ($value ['updatetime'] == $MD) {
  973. array_push ( $statisticsGet, $value ['count'] );
  974. $falgGet = false;
  975. break;
  976. }
  977. }
  978. if ($falgGet)
  979. array_push ( $statisticsGet, 0 );
  980. }
  981. $statisticsClient = array_reverse ( $statisticsClient );
  982. $statisticsLongle = array_reverse ( $statisticsLongle );
  983. $statisticsGet = array_reverse ( $statisticsGet );
  984. $statisticsDay = array_reverse ( $statisticsDay );
  985. // /
  986. $districtCondition = "";
  987. $topDistrict = $district->get_lvByid ( 0, 0 );
  988. if (! empty ( $sid )) {
  989. $s = $staff->getOne ( array (
  990. 'where' => ' sid=' . $sid,
  991. 'asArray' => true
  992. ) );
  993. $l = $lcategory->find ( array (
  994. 'where' => ' cid in(' . $s ['cid'] . ')',
  995. 'asArray' => true
  996. ) );
  997. if (! empty ( $s ['othercid'] ))
  998. $l = $lcategory->find ( array (
  999. 'where' => ' cid in(' . $s ['cid'] . ',' . $s ['othercid'] . ')',
  1000. 'asArray' => true
  1001. ) );
  1002. if (! empty ( $districtH )) {
  1003. $districtCondition = " and districtid like '" . $districtH . ",%'";
  1004. $sidCondition = "";
  1005. $topDistrict = $district->find ( array (
  1006. 'where' => ' upid=' . $districtH,
  1007. 'asArray' => true
  1008. ) );
  1009. } else {
  1010. $districtCondition = " and districtid like '" . $l [0] ['districtid'] . ",%'";
  1011. $sidCondition = "";
  1012. $topDistrict = $district->find ( array (
  1013. 'where' => ' upid=' . $l [0] ['districtid'],
  1014. 'asArray' => true
  1015. ) );
  1016. }
  1017. $str = array ();
  1018. foreach ( $l as $value ) {
  1019. array_push ( $str, $value ['districtid'] );
  1020. }
  1021. $str = implode ( ",", $str );
  1022. $data ['districtHtml'] = $district->find ( array (
  1023. 'where' => ' id in (' . $str . ')',
  1024. 'asArray' => true
  1025. ) );
  1026. $data ['districtH'] = $l [0] ['districtid'];
  1027. if (! empty ( $districtH ))
  1028. $data ['districtH'] = $districtH;
  1029. }
  1030. // Year(updatetime)=".date('Y')." and Month(updatetime)=".date('m')." and
  1031. if (! empty ( $sid ))
  1032. $districtClient = $action_log->find ( array (
  1033. 'select' => 'city,province,COUNT(*) as count',
  1034. 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=" . $status . $categoryCondition . $sidCondition . $districtCondition,
  1035. 'groupby' => 'province',
  1036. 'asArray' => true
  1037. ) );
  1038. else
  1039. $districtClient = $action_log->find ( array (
  1040. 'select' => 'city,province,COUNT(*) as count',
  1041. 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=" . $status . $categoryCondition . $sidCondition . $districtCondition,
  1042. 'groupby' => 'city',
  1043. 'asArray' => true
  1044. ) );
  1045. $statisticsLend = array ();
  1046. $statisticsCompany = array ();
  1047. if (! empty ( $sid )) {
  1048. foreach ( $topDistrict as $value ) {
  1049. $falgLend = $falgLongle = true;
  1050. foreach ( $districtClient as $v ) {
  1051. if ($value ['name'] == $v ['province']) {
  1052. array_push ( $statisticsLend, array (
  1053. 'value' => $v ['count'],
  1054. 'name' => $value ['name']
  1055. ) );
  1056. $falgLend = false;
  1057. break;
  1058. }
  1059. }
  1060. if ($falgLend)
  1061. array_push ( $statisticsLend, array (
  1062. 'value' => 0,
  1063. 'name' => $value ['name']
  1064. ) );
  1065. }
  1066. } else {
  1067. foreach ( $topDistrict as $value ) {
  1068. $falgLend = $falgLongle = true;
  1069. foreach ( $districtClient as $v ) {
  1070. if ($value ['name'] == $v ['city']) {
  1071. array_push ( $statisticsLend, array (
  1072. 'value' => $v ['count'],
  1073. 'name' => $value ['name']
  1074. ) );
  1075. $falgLend = false;
  1076. break;
  1077. }
  1078. }
  1079. if ($falgLend)
  1080. array_push ( $statisticsLend, array (
  1081. 'value' => 0,
  1082. 'name' => $value ['name']
  1083. ) );
  1084. }
  1085. }
  1086. // print_r($statisticsLend);die;
  1087. $natureList = $action_log->find ( array (
  1088. 'select' => 'cid, COUNT(*) as count,nature',
  1089. 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=" . $status . " and nature !=''" . $categoryCondition . $sidCondition . $districtCondition,
  1090. 'groupby' => 'nature',
  1091. 'asArray' => true
  1092. ) );
  1093. $statisticsNature = array ();
  1094. foreach ( $this->nature as $value ) {
  1095. $flagNature = true;
  1096. foreach ( $natureList as $v ) {
  1097. if ($value == $v ['nature']) {
  1098. array_push ( $statisticsNature, array (
  1099. 'value' => $v ['count'],
  1100. 'name' => $value
  1101. ) );
  1102. $flagNature = false;
  1103. break;
  1104. }
  1105. }
  1106. if ($flagNature)
  1107. array_push ( $statisticsNature, array (
  1108. 'value' => 0,
  1109. 'name' => $value
  1110. ) );
  1111. }
  1112. $data ['statisticsNature'] = json_encode ( $statisticsNature );
  1113. // print_r($statisticsLend);die;
  1114. $data ['statisticsLend'] = json_encode ( $statisticsLend );
  1115. $data ['status'] = $status;
  1116. $data ['statisticsDay'] = json_encode ( $statisticsDay );
  1117. $data ['statisticsClient'] = json_encode ( $statisticsClient );
  1118. $data ['statisticsLongle'] = json_encode ( $statisticsLongle );
  1119. $data ['statisticsGet'] = json_encode ( $statisticsGet );
  1120. $data ['categorylist2'] = $categorylist2;
  1121. $data ['Ssum'] = round ( ($Ssum / $Rsum) * 100 ) . '%';
  1122. $data ['Rsum'] = $Rsum;
  1123. $data ['useL2'] = $useL2;
  1124. $data ['useL'] = $useL;
  1125. $data ['sum'] = $sum;
  1126. $data ['max'] = $max;
  1127. $data ['max2'] = $max2;
  1128. $data ['staffList'] = $staffList;
  1129. $data ['cid'] = $cid;
  1130. $data ['sid'] = $sid;
  1131. $data ['memu'] = "index";
  1132. $data ['staff'] = $this->staff;
  1133. $this->render ( "/indexLongle", $data );
  1134. }
  1135. function index() {
  1136. die ( 'dd' );
  1137. $data ['memu'] = "index";
  1138. $data ['staff'] = $this->staff;
  1139. Doo::loadModel ( 'action_log' );
  1140. $action_log = new action_log ();
  1141. $data ['today'] = explode ( "-", date ( "Y-m-d" ) );
  1142. $str = "";
  1143. if ($this->staff [0] ['isadmin'] != 1) {
  1144. $str = " and (action like '%" . $this->staff [0] ['category'] . "%'";
  1145. $khql = explode ( ",", $this->staff [0] ['othercategory'] );
  1146. if (! empty ( $khql [0] )) {
  1147. foreach ( $khql as $key => $value ) {
  1148. $str .= " or action like '%" . $value . "%'";
  1149. }
  1150. $str .= ")";
  1151. } else
  1152. $str .= ")";
  1153. }
  1154. $data ['actionListNow'] = $action_log->find ( array (
  1155. 'where' => ' updatetime=\'' . date ( "Y-m-d" ) . "'" . $str,
  1156. 'desc' => 'aid',
  1157. 'asArray' => TRUE
  1158. ) );
  1159. $d2 = mktime ( 0, 0, 0, date ( "m" ), date ( "d" ) - 1, date ( "Y" ) );
  1160. $strdate = date ( "Y-m-d", $d2 );
  1161. $data ['day2'] = explode ( "-", $strdate );
  1162. $data ['actionListNow2'] = $action_log->find ( array (
  1163. 'where' => ' updatetime=\'' . $strdate . "'" . $str,
  1164. 'desc' => 'aid',
  1165. 'asArray' => TRUE
  1166. ) );
  1167. $d3 = mktime ( 0, 0, 0, date ( "m" ), date ( "d" ) - 2, date ( "Y" ) );
  1168. $strdate = date ( "Y-m-d", $d3 );
  1169. $data ['day3'] = explode ( "-", $strdate );
  1170. $data ['actionListNow3'] = $action_log->find ( array (
  1171. 'where' => ' updatetime=\'' . $strdate . "'" . $str,
  1172. 'desc' => 'aid',
  1173. 'asArray' => TRUE
  1174. ) );
  1175. $d4 = mktime ( 0, 0, 0, date ( "m" ), date ( "d" ) - 3, date ( "Y" ) );
  1176. $strdate = date ( "Y-m-d", $d4 );
  1177. $data ['day4'] = explode ( "-", $strdate );
  1178. $data ['actionListNow4'] = $action_log->find ( array (
  1179. 'where' => ' updatetime=\'' . $strdate . "'" . $str,
  1180. 'asArray' => TRUE
  1181. ) );
  1182. $d5 = mktime ( 0, 0, 0, date ( "m" ), date ( "d" ) - 4, date ( "Y" ) );
  1183. $strdate = date ( "Y-m-d", $d5 );
  1184. $data ['day5'] = explode ( "-", $strdate );
  1185. $data ['actionListNow5'] = $action_log->find ( array (
  1186. 'where' => ' updatetime=\'' . $strdate . "'" . $str,
  1187. 'asArray' => TRUE
  1188. ) );
  1189. $d6 = mktime ( 0, 0, 0, date ( "m" ), date ( "d" ) - 5, date ( "Y" ) );
  1190. $strdate = date ( "Y-m-d", $d6 );
  1191. $data ['day6'] = explode ( "-", $strdate );
  1192. $data ['actionListNow6'] = $action_log->find ( array (
  1193. 'where' => ' updatetime=\'' . $strdate . "'" . $str,
  1194. 'asArray' => TRUE
  1195. ) );
  1196. $d7 = mktime ( 0, 0, 0, date ( "m" ), date ( "d" ) - 6, date ( "Y" ) );
  1197. $strdate = date ( "Y-m-d", $d7 );
  1198. $data ['day7'] = explode ( "-", $strdate );
  1199. $data ['actionListNow7'] = $action_log->find ( array (
  1200. 'where' => ' updatetime=\'' . $strdate . "'" . $str,
  1201. 'asArray' => TRUE
  1202. ) );
  1203. Doo::loadModel ( 'staff' );
  1204. Doo::loadModel ( 'client_staff' );
  1205. $client_staff = new client_staff ();
  1206. $staff = new staff ();
  1207. $st = $staff->find ( array (
  1208. 'where' => '1',
  1209. 'asArray' => true
  1210. ) );
  1211. foreach ( $st as $key => $value ) {
  1212. $st [$key] ['count'] = $client_staff->count ( array (
  1213. 'where' => 'sid=' . $value ['sid'],
  1214. 'asArray' => true
  1215. ) );
  1216. }
  1217. $data ['staffCount'] = $st;
  1218. $this->render ( "/index", $data );
  1219. }
  1220. function receive() {
  1221. $data ['memu'] = "keyonline";
  1222. $data ['staff'] = $this->staff;
  1223. Doo::loadModel ( 'longle' );
  1224. $longle = new longle ();
  1225. $data ['arrayReceive'] = $longle->getLongleReceive ( $this->staff [0] ['cid'], 1, $this->staff [0] ['othercid'] );
  1226. $this->render ( "/look_receive", $data );
  1227. }
  1228. function doLongleReceive() {
  1229. $arrLid = $this->get_args ( 'lid' ) ? $this->get_args ( 'lid' ) : array ();
  1230. Doo::loadModel ( 'longle_log' );
  1231. Doo::loadModel ( 'longle' );
  1232. foreach ( $arrLid as $key => $value ) {
  1233. $ky = explode ( "-", $value );
  1234. $longle = new longle ();
  1235. $longle_log = new longle_log ();
  1236. $longle->lid = $ky [0];
  1237. $longle->status = 2;
  1238. $longle->statusT = '接收';
  1239. $longle->responsible = $this->staff [0] ['username'];
  1240. // 记录锁状态
  1241. $longle->statuslog = "1,2";
  1242. $longle->update ();
  1243. $longle_log->lid = $ky [0];
  1244. $longle_log->status = 2;
  1245. $longle_log->statusT = '接收';
  1246. $longle_log->responsible = $this->staff [0] ['username'];
  1247. $longle_log->operator = $this->staff [0] ['username'];
  1248. $longle_log->category = $ky [1];
  1249. $longle_log->dateline = date ( "Y-m-d" );
  1250. $longle_log->insert ();
  1251. }
  1252. return "/receive";
  1253. }
  1254. function addClient() {
  1255. $this->get_args ( 'clientname' ) ? $this->get_args ( 'clientname' ) : "";
  1256. $clientname = $this->get_args ( 'clientname' ) ? $this->get_args ( 'clientname' ) : "";
  1257. $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : "";
  1258. $nicename = $this->get_args ( 'nicename' ) ? $this->get_args ( 'nicename' ) : "";
  1259. $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : "";
  1260. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";
  1261. $email = $this->get_args ( 'email' ) ? $this->get_args ( 'email' ) : "";
  1262. $qq = $this->get_args ( 'qq' ) ? $this->get_args ( 'qq' ) : "";
  1263. $tid = $this->get_args ( 'tid' ) ? $this->get_args ( 'tid' ) : "";
  1264. $companyname = $this->get_args ( 'companyname' ) ? $this->get_args ( 'companyname' ) : "";
  1265. $local1 = $this->get_args ( 'lv21' ) ? $this->get_args ( 'lv21' ) : "";
  1266. $local2 = $this->get_args ( 'lv22' ) ? $this->get_args ( 'lv22' ) : "";
  1267. $local3 = $this->get_args ( 'lv23' ) ? $this->get_args ( 'lv23' ) : "";
  1268. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  1269. $fax = $this->get_args ( 'fax' ) ? $this->get_args ( 'fax' ) : "";
  1270. $webservice = $this->get_args ( 'webservice' ) ? $this->get_args ( 'webservice' ) : "";
  1271. $department = $this->get_args ( 'department' ) ? $this->get_args ( 'department' ) : "";
  1272. $position = $this->get_args ( 'position' ) ? $this->get_args ( 'position' ) : "";
  1273. $office = $this->get_args ( 'office' ) ? $this->get_args ( 'office' ) : "";
  1274. $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
  1275. $ride = $this->get_args ( 'ride' ) ? $this->get_args ( 'ride' ) : "";
  1276. $landmarks = $this->get_args ( 'landmarks' ) ? $this->get_args ( 'landmarks' ) : "";
  1277. $priority = $this->get_args ( 'priority' ) ? $this->get_args ( 'priority' ) : "";
  1278. $stay = $this->get_args ( 'stay' ) ? $this->get_args ( 'stay' ) : "";
  1279. $mark = $this->get_args ( 'mark' ) ? $this->get_args ( 'mark' ) : "";
  1280. $clientname = trim ( $clientname );
  1281. $companyname = trim ( $companyname );
  1282. if (empty ( $companyname ))
  1283. return "/contacts";
  1284. if (empty ( $this->staff [0] ['sid'] ))
  1285. return "/contacts";
  1286. if (! empty ( $clientname )) {
  1287. // 相同的公司和客户
  1288. Doo::loadModel ( 'company' );
  1289. $company = new company ();
  1290. Doo::loadModel ( 'client' );
  1291. $client = new client ();
  1292. $redis = new Redis ();
  1293. $redis->connect ( '127.0.0.1', '6379' );
  1294. $cinfo = $client->getClientByNameT ( $clientname );
  1295. if (! empty ( $cinfo )) {
  1296. $ninfo = $company->getCompanyByCompanyname ( $companyname );
  1297. if (! empty ( $ninfo )) {
  1298. foreach ( $cinfo as $key => $value ) { // 问题
  1299. if ($value ['companyid'] == $ninfo [0] ['cid'])
  1300. return "/contacts";
  1301. }
  1302. }
  1303. }
  1304. Doo::loadModel ( 'district' );
  1305. $district = new district ();
  1306. $companyInfo = $company->getOne ( array (
  1307. 'where' => "companyname = '" . $companyname . "'",
  1308. "asArray" => true
  1309. ) );
  1310. // 更新公司信息
  1311. $lv1 = $district->getbyid ( $local1 );
  1312. $lv2 = $district->getbyid ( $local2 );
  1313. $lv3 = $district->getbyid ( $local3 );
  1314. if (empty ( $lv1 ))
  1315. $lv1 [0] ['name'] = "";
  1316. if (empty ( $lv2 ))
  1317. $lv2 [0] ['name'] = "";
  1318. if (empty ( $lv3 ))
  1319. $lv3 [0] ['name'] = "";
  1320. if (! empty ( $local1 ) && ! empty ( $local2 ))
  1321. $company->local = $lv1 [0] ['name'] . "," . $lv2 [0] ['name'] . "," . $lv3 [0] ['name'];
  1322. if (! empty ( $nature ))
  1323. $company->nature = implode ( ',', $nature );
  1324. if (! empty ( $fax ))
  1325. $company->fax = $fax;
  1326. if (! empty ( $webservice ))
  1327. $company->webservice = $webservice;
  1328. if (! empty ( $address ))
  1329. $company->address = $address;
  1330. if (! empty ( $ride ))
  1331. $company->ride = $ride;
  1332. if (! empty ( $landmarks ))
  1333. $company->landmarks = $landmarks;
  1334. if (! empty ( $office ))
  1335. $company->office = $office;
  1336. if (! empty ( $local1 ) && ! empty ( $local2 ))
  1337. $company->district = $local1 . "," . $local2 . "," . $local3;
  1338. if (! empty ( $stay ))
  1339. $company->stay = $stay;
  1340. if (empty ( $companyInfo )) {
  1341. $company->companyname = $companyname;
  1342. $company->staffid = $this->staff [0] ['sid'];
  1343. $cid = $company->insert ();
  1344. } else { // 不编辑公司,地区判断,作为新公司
  1345. // $cid=$companyInfo['cid'];
  1346. //
  1347. // $companyname=$companyInfo['companyname'];
  1348. //
  1349. // $company->cid=$cid;
  1350. //
  1351. // $company->update();
  1352. $diqu = $local1 . "," . $local2 . "," . $local3;
  1353. $cid = $companyInfo ['cid'];
  1354. $company2 = new company ();
  1355. $companyList = $company2->find ( array (
  1356. 'where' => " companyname like '" . $companyname . "'",
  1357. "asArray" => true
  1358. ) );
  1359. $falg = false;
  1360. // print_r($companyList);
  1361. foreach ( $companyList as $key => $value ) {
  1362. if ($value ['district'] != $diqu) {
  1363. $falg = true;
  1364. } elseif ($value ['district'] == $diqu) {
  1365. $falg = false;
  1366. $cid = $value ['cid'];
  1367. break;
  1368. }
  1369. }
  1370. if ($falg) {
  1371. $company->companyname = $companyname;
  1372. $company->staffid = $this->staff [0] ['sid'];
  1373. $cid = $company->insert ();
  1374. }
  1375. }
  1376. Doo::loadModel ( 'client_staff' );
  1377. $client_staff = new client_staff ();
  1378. $client->clientname = $clientname;
  1379. $client->gender = $gender;
  1380. $client->priority = $priority;
  1381. if (! empty ( $nicename ))
  1382. $client->nicename = $nicename;
  1383. if (! empty ( $telephone ))
  1384. $client->telephone = $telephone;
  1385. if (! empty ( $phone ))
  1386. $client->phone = $phone;
  1387. if (! empty ( $email ))
  1388. $client->email = $email;
  1389. if (! empty ( $qq ) && is_numeric ( $qq ))
  1390. $client->qq = $qq;
  1391. $client->companyid = $cid;
  1392. $client->companyname = $companyname;
  1393. $client->district = $local1 . "," . $local2 . "," . $local3;
  1394. // echo $client->district;
  1395. // die;
  1396. if (! empty ( $tid ))
  1397. $client->tag = implode ( ',', $tid );
  1398. if (! empty ( $fax ))
  1399. $client->fax = $fax;
  1400. if (! empty ( $webservice ))
  1401. $client->webservice = $webservice;
  1402. if (! empty ( $department ))
  1403. $client->department = $department;
  1404. if (! empty ( $position ))
  1405. $client->position = $position;
  1406. if (! empty ( $office ))
  1407. $client->office = $office;
  1408. if (! empty ( $address ))
  1409. $client->address = $address;
  1410. if (! empty ( $ride ))
  1411. $client->ride = $ride;
  1412. if (! empty ( $landmarks ))
  1413. $client->landmarks = $landmarks;
  1414. if (! empty ( $stay ))
  1415. $client->stay = $stay;
  1416. if (! empty ( $mark ))
  1417. $client->mark = $mark;
  1418. $id = $client->insert ();
  1419. $client_staff->cid = $id;
  1420. $client_staff->sid = $this->staff [0] ['sid'];
  1421. $client_staff->insert ();
  1422. // 加入地区记录
  1423. Doo::loadModel ( "district_staff" );
  1424. $district_staff = new district_staff ();
  1425. $district_staff->did = $lv1 [0] ['id'];
  1426. $district_staff->sid = $this->staff [0] ['sid'];
  1427. $district_staff->insert ();
  1428. // 日常行为
  1429. Doo::loadModel ( "action_log" );
  1430. $action_log = new action_log ();
  1431. $action_log->action = $this->staff [0] ['category'] . '<b href="javascript:void(0)" onclick="showStaff(\'' . $this->staff [0] ['sid'] . '\')" >' . $this->staff [0] ['username'] . '</b>添加了<a href="javascript:void(0)" onclick="showClick(\'' . $id . '\')">' . $clientname . '</a>(' . $companyname . ')';
  1432. $action_log->sid = $this->staff [0] ['sid'];
  1433. $action_log->cid = $this->staff [0] ['cid'];
  1434. $action_log->updatetime = date ( "Y-m-d" );
  1435. $action_log->time = date ( "H:i" );
  1436. $action_log->status = 1;
  1437. $action_log->districtid = $local1 . "," . $local2 . "," . $local3;
  1438. $action_log->city = $lv1 [0] ['name'];
  1439. $action_log->province = $lv2 [0] ['name'];
  1440. if (isset ( $nature [0] ))
  1441. $action_log->nature = $nature [0];
  1442. $action_log->company = $companyname;
  1443. $action_log->class = $action_log->iconContacts;
  1444. $action_log->insert ();
  1445. // 事实更新信息中心记录数量 需要更新3个redis 内的值
  1446. $categoryCondition = " and cid=" . $this->staff [0] ['cid'];
  1447. $sidCondition = " and sid=" . $this->staff [0] ['sid'];
  1448. // actionlog免查询值 $alCondition='';
  1449. $alCondition = ' aid>' . REMIT . ' and ';
  1450. // 个人添加数量redis值
  1451. $redisKeyCS = date ( 'Y-m-d' ) . 'SC_' . $this->staff [0] ['cid'] . '_' . $this->staff [0] ['sid'];
  1452. $action_log = new action_log ();
  1453. $actionLogClient = $action_log->find ( array (
  1454. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  1455. 'where' => $alCondition . " status=1" . $sidCondition . $categoryCondition . ' and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime)',
  1456. 'groupby' => 'date_format(updatetime,"%m-%d")',
  1457. 'asArray' => true
  1458. ) );
  1459. $statisticsClient = array ();
  1460. for($d = 0; $d <= 29; $d ++) {
  1461. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  1462. $falgClient = true;
  1463. foreach ( $actionLogClient as $value ) {
  1464. if ($value ['updatetime'] == $MD) {
  1465. array_push ( $statisticsClient, $value ['count'] );
  1466. $falgClient = false;
  1467. break;
  1468. }
  1469. }
  1470. if ($falgClient)
  1471. array_push ( $statisticsClient, 0 );
  1472. }
  1473. $statisticsClient = array_reverse ( $statisticsClient );
  1474. $jsc = json_encode ( $statisticsClient );
  1475. $redis->set ( $redisKeyCS, $jsc );
  1476. // 办事处添加数量reids值
  1477. $redisKeyC = date ( 'Y-m-d' ) . 'SC_' . $this->staff [0] ['cid'] . '_';
  1478. $action_log = new action_log ();
  1479. $actionLogClient = $action_log->find ( array (
  1480. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  1481. 'where' => $alCondition . " status=1" . $categoryCondition . ' and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime)',
  1482. 'groupby' => 'date_format(updatetime,"%m-%d")',
  1483. 'asArray' => true
  1484. ) );
  1485. $statisticsClient = array ();
  1486. for($d = 0; $d <= 29; $d ++) {
  1487. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  1488. $falgClient = true;
  1489. foreach ( $actionLogClient as $value ) {
  1490. if ($value ['updatetime'] == $MD) {
  1491. array_push ( $statisticsClient, $value ['count'] );
  1492. $falgClient = false;
  1493. break;
  1494. }
  1495. }
  1496. if ($falgClient)
  1497. array_push ( $statisticsClient, 0 );
  1498. }
  1499. $statisticsClient = array_reverse ( $statisticsClient );
  1500. $jsc = json_encode ( $statisticsClient );
  1501. $redis->set ( $redisKeyC, $jsc );
  1502. // 全员添加数量的redis值
  1503. $redisKey = date ( 'Y-m-d' ) . 'SC__';
  1504. $action_log = new action_log ();
  1505. $actionLogClient = $action_log->find ( array (
  1506. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  1507. 'where' => $alCondition . ' status=1 and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime)',
  1508. 'groupby' => 'date_format(updatetime,"%m-%d")',
  1509. 'asArray' => true
  1510. ) );
  1511. $statisticsClient = array ();
  1512. for($d = 0; $d <= 29; $d ++) {
  1513. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  1514. $falgClient = true;
  1515. foreach ( $actionLogClient as $value ) {
  1516. if ($value ['updatetime'] == $MD) {
  1517. array_push ( $statisticsClient, $value ['count'] );
  1518. $falgClient = false;
  1519. break;
  1520. }
  1521. }
  1522. if ($falgClient)
  1523. array_push ( $statisticsClient, 0 );
  1524. }
  1525. $statisticsClient = array_reverse ( $statisticsClient );
  1526. $jsc = json_encode ( $statisticsClient );
  1527. $redis->set ( $redisKey, $jsc );
  1528. }
  1529. return "/contacts";
  1530. }
  1531. function mycompany() {
  1532. $search = $this->get_args ( 'search' ) ? $this->get_args ( 'search' ) : "";
  1533. $districtLv = $this->get_args ( 'districtLv' ) ? $this->get_args ( 'districtLv' ) : 0;
  1534. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  1535. $lv1 = $this->get_args ( 'lv1' ) ? $this->get_args ( 'lv1' ) : 0;
  1536. $lv2 = $this->get_args ( 'lv2' ) ? $this->get_args ( 'lv2' ) : 0;
  1537. $lv3 = $this->get_args ( 'lv3' ) ? $this->get_args ( 'lv3' ) : 0;
  1538. $tagList = $this->get_args ( 'tag' ) ? $this->get_args ( 'tag' ) : array ();
  1539. if ($lv1 == 0) {
  1540. $lv1 = isset ( $this->params ['lv1'] ) && is_numeric ( $this->params ['lv1'] ) ? $this->params ['lv1'] : 0;
  1541. if ($lv1 != 0)
  1542. $districtLv = 1;
  1543. }
  1544. if ($lv2 == 0) {
  1545. $lv2 = isset ( $this->params ['lv2'] ) && is_numeric ( $this->params ['lv2'] ) ? $this->params ['lv2'] : 0;
  1546. if ($lv2 != 0)
  1547. $districtLv = 2;
  1548. }
  1549. if ($lv3 == 0) {
  1550. $lv3 = isset ( $this->params ['lv3'] ) && is_numeric ( $this->params ['lv3'] ) ? $this->params ['lv3'] : 0;
  1551. if ($lv2 != 0)
  1552. $districtLv = 3;
  1553. }
  1554. if (empty ( $search ))
  1555. $search = urldecode ( isset ( $this->params ['search'] ) ? $this->params ['search'] : "" );
  1556. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  1557. $data ['memu'] = "contacts";
  1558. $data ['staff'] = $this->staff;
  1559. Doo::loadModel ( 'district' );
  1560. Doo::loadModel ( 'company' );
  1561. Doo::loadModel ( 'client' );
  1562. Doo::loadModel ( 'tag' );
  1563. Doo::loadModel ( 'L_category' );
  1564. $lcategory = new L_category ();
  1565. $tag = new tag ();
  1566. $client = new client ();
  1567. $company = new company ();
  1568. $district = new district ();
  1569. Doo::loadModel ( 'tagCompany' );
  1570. $tagCompany = new tagCompany ();
  1571. Doo::loadModel ( 'tagCompanyNexus' );
  1572. $tagCompanyNexus = new tagCompanyNexus ();
  1573. $data ['district2'] = $district->get_lv ( 1 );
  1574. $category = $lcategory->getCategoryById ( $this->staff [0] ['cid'], $this->staff [0] ['othercid'] );
  1575. $cateStr = "";
  1576. $list = array ();
  1577. foreach ( $category as $key => $value ) {
  1578. array_push ( $list, " district like '" . $value ['districtid'] . ",%' " );
  1579. }
  1580. if ($this->staff [0] ['isadmin'] != 1)
  1581. $cateStr = implode ( " or ", $list );
  1582. else
  1583. $cateStr = " 1";
  1584. $size = 300;
  1585. if (! empty ( $nature ))
  1586. $cateStr = " 1";
  1587. $data ['htmllv2'] = array ();
  1588. $data ['htmllv3'] = array ();
  1589. $condition = "";
  1590. if ($districtLv == 1) {
  1591. $condition = "";
  1592. if (! empty ( $lv1 )) {
  1593. $condition = " district like '" . $lv1 . ",%'";
  1594. $data ['htmllv2'] = $district->get_lvByid ( 2, $lv1 );
  1595. }
  1596. }
  1597. if ($districtLv == 2) {
  1598. if (! empty ( $lv2 ))
  1599. $condition = " district like '" . $lv1 . "," . $lv2 . ",%'";
  1600. else
  1601. $condition = " district like '" . $lv1 . ",%'";
  1602. $data ['htmllv2'] = $district->get_lvByid ( 2, $lv1 );
  1603. $data ['htmllv3'] = $district->get_lvByid ( 2, $lv2 );
  1604. }
  1605. if ($districtLv == 3) {
  1606. if (! empty ( $lv3 ))
  1607. $condition = " district like '" . $lv1 . "," . $lv2 . "," . $lv3 . "'";
  1608. else
  1609. $condition = " district like '" . $lv1 . "," . $lv2 . ",%'";
  1610. $data ['htmllv2'] = $district->get_lvByid ( 2, $lv1 );
  1611. $data ['htmllv3'] = $district->get_lvByid ( 2, $lv2 );
  1612. }
  1613. $districtCount = $condition;
  1614. if (! empty ( $condition ))
  1615. $cateStr = $condition;
  1616. if (! empty ( $nature ))
  1617. $cateStr .= " and nature like '%" . $nature . "%'";
  1618. // echo "<div style='display:none'>".$cateStr."</div><br/>";
  1619. $tagSQL = false;
  1620. if (! empty ( $tagList )) {
  1621. $tagSQL = true;
  1622. foreach ( $tagList as $value ) {
  1623. $cateStr .= " and a.tag like '%" . $value . "%' ";
  1624. }
  1625. }
  1626. if ($this->staff [0] ['isadmin'] != 1) {
  1627. $pageinfo = $this->get_Tpage ( "CLD_company", $cateStr, $page, $size, "", $tagSQL );
  1628. } else {
  1629. if ($tagSQL)
  1630. $pageinfo = $this->get_Tpage ( "CLD_company", $cateStr, $page, $size, "", $tagSQL );
  1631. else {
  1632. $total_page = $company->count ( array () );
  1633. $total = intval ( $total_page / $size );
  1634. $pageinfo ['total_page'] = ($total_page % $size) == 0 ? $total : $total + 1;
  1635. }
  1636. }
  1637. $k = "";
  1638. for($i = 1; $i <= $pageinfo ['total_page']; $i ++) {
  1639. if ($page == $i)
  1640. $k .= "<option value='" . $search . ":" . $i . ":" . $lv1 . ":" . $lv2 . ":" . $lv3 . "' selected>第" . $i . "页</option>";
  1641. else
  1642. $k .= "<option value='" . $search . ":" . $i . ":" . $lv1 . ":" . $lv2 . ":" . $lv3 . "'>第" . $i . "页</option>";
  1643. }
  1644. $data ['pageinfo'] = $k;
  1645. $data ['company'] = $company->getCompanyByDistrict ( $this->staff [0] ['sid'], $cateStr, $this->staff [0] ['isadmin'], $page, $size, $tagSQL );
  1646. if ($this->staff [0] ['isadmin'] != 1) {
  1647. $data ['district'] = $district->get_lvByStaffid ( 1, $this->staff [0] ['sid'] );
  1648. } else {
  1649. $data ['district'] = $data ['district2'];
  1650. }
  1651. // 获得标签
  1652. $ClientTagList = $tagCompanyNexus->getTagClientBySid ( $this->staff [0] ['sid'] );
  1653. foreach ( $ClientTagList as $key => $value ) {
  1654. $ClientTagList [$key] ['taginfo'] = $tagCompany->getTagByTidL ( $value ['tag'] );
  1655. }
  1656. foreach ( $data ['company'] as $key => $value ) {
  1657. if (! empty ( $value ['cid'] )) {
  1658. $data ['company'] [$key] ['taginfo'] = array ();
  1659. $data ['company'] [$key] ['tag'] = "";
  1660. foreach ( $ClientTagList as $k => $v ) {
  1661. if ($value ['cid'] == $v ['company']) {
  1662. $data ['company'] [$key] ['taginfo'] = $v ['taginfo'];
  1663. $data ['company'] [$key] ['tag'] = $v ['tag'];
  1664. }
  1665. }
  1666. }
  1667. }
  1668. $comcid = $countL = array ();
  1669. foreach ( $data ['company'] as $key => $value ) {
  1670. array_push ( $comcid, $value ['cid'] );
  1671. }
  1672. $comcid = implode ( ",", $comcid );
  1673. if (! empty ( $comcid ))
  1674. $countL = $client->getCountByCompany ( $comcid );
  1675. foreach ( $data ['company'] as $key => $value ) {
  1676. $data ['company'] [$key] ['count'] = 0;
  1677. foreach ( $countL as $k => $v ) {
  1678. if ($value ['cid'] == $v ['companyid']) {
  1679. $data ['company'] [$key] ['count'] = $v ['count'];
  1680. break;
  1681. }
  1682. }
  1683. }
  1684. $CC1 = "";
  1685. $CC2 = "";
  1686. $CC3 = "";
  1687. $natureHtml = '';
  1688. if (! empty ( $districtCount )) {
  1689. $clientCount = $company->find ( array (
  1690. 'select' => 'district',
  1691. 'where' => "district like '" . $lv1 . ",%'",
  1692. 'asArray' => TRUE
  1693. ) );
  1694. $CC1 = count ( $clientCount );
  1695. if (! empty ( $clientCount ) && ! empty ( $lv2 )) {
  1696. $CC2 = 0;
  1697. foreach ( $clientCount as $key => $value ) {
  1698. if (strpos ( $value ['district'], $lv2 )) {
  1699. $CC2 ++;
  1700. }
  1701. }
  1702. }
  1703. if (! empty ( $clientCount ) && ! empty ( $lv3 )) {
  1704. $CC3 = 0;
  1705. foreach ( $clientCount as $key => $value ) {
  1706. if (strpos ( $value ['district'], $lv3 )) {
  1707. $CC3 ++;
  1708. }
  1709. }
  1710. }
  1711. $clientCount = $company->find ( array (
  1712. 'select' => 'district,nature',
  1713. 'where' => $districtCount,
  1714. 'asArray' => TRUE
  1715. ) );
  1716. $natureCount = array ();
  1717. foreach ( $this->nature as $value ) {
  1718. $natureCount [$value] = 0;
  1719. foreach ( $clientCount as $v ) {
  1720. $ak = explode ( ",", $v ['nature'] );
  1721. foreach ( $ak as $a ) {
  1722. if ($value == $a) {
  1723. $natureCount [$value] ++;
  1724. }
  1725. }
  1726. }
  1727. }
  1728. }
  1729. $natureHtml = '';
  1730. foreach ( $this->nature as $value ) {
  1731. $natureHtml .= '<a href="javascript:void(0)" ';
  1732. if ($value == $nature)
  1733. $natureHtml .= 'class="now"';
  1734. if (isset ( $natureCount [$value] ))
  1735. $natureHtml .= 'onclick="showNature(\'' . $value . '\',this)">' . $value . '(' . $natureCount [$value] . ')</a>';
  1736. else
  1737. $natureHtml .= 'onclick="showNature(\'' . $value . '\',this)">' . $value . '</a>';
  1738. }
  1739. $taglist = $tagCompany->find ( array (
  1740. 'where' => 'sid=' . $this->staff [0] ['sid'],
  1741. 'asArray' => TRUE
  1742. ) );
  1743. if (empty ( $taglist )) {
  1744. for($i = 1; $i <= 7; $i ++) {
  1745. $tag = new tagCompany ();
  1746. $tag->name = "个人标签";
  1747. $tag->sid = $this->staff [0] ['sid'];
  1748. $tag->colorid = $i;
  1749. $tag->insert ();
  1750. }
  1751. }
  1752. $data ['product'] = array ();
  1753. $data ['tagList'] = $tagList;
  1754. $data ['tag'] = $tagCompany->getAllBySid ( $this->staff [0] ['sid'] );
  1755. $data ['natureHtml'] = $natureHtml;
  1756. $data ['CC1'] = $CC1;
  1757. $data ['CC2'] = $CC2;
  1758. $data ['CC3'] = $CC3;
  1759. $data ['lv1'] = $lv1;
  1760. $data ['lv2'] = $lv2;
  1761. $data ['lv3'] = $lv3;
  1762. $data ['districtLv'] = $districtLv;
  1763. $data ['Hnature'] = $nature;
  1764. $data ['nature'] = $this->nature;
  1765. $this->render ( "/contacts_company", $data );
  1766. }
  1767. function contacts() {
  1768. $data ['memu'] = "contacts";
  1769. $data ['staff'] = $this->staff;
  1770. $search = $this->get_args ( 'search' ) ? trim ( $this->get_args ( 'search' ) ) : "";
  1771. if (empty ( $search ))
  1772. $search = urldecode ( isset ( $this->params ['search'] ) ? $this->params ['search'] : "" );
  1773. $lv1 = $this->get_args ( 'lv1' ) ? $this->get_args ( 'lv1' ) : 0;
  1774. $lv2 = $this->get_args ( 'lv2' ) ? $this->get_args ( 'lv2' ) : 0;
  1775. $lv3 = $this->get_args ( 'lv3' ) ? $this->get_args ( 'lv3' ) : 0;
  1776. $lv4 = $this->get_args ( 'lv4' ) ? $this->get_args ( 'lv4' ) : "";
  1777. $tagList = $this->get_args ( 'tag' ) ? $this->get_args ( 'tag' ) : array ();
  1778. $tooltip = $this->get_args ( 'tooltip' ) ? $this->get_args ( 'tooltip' ) : "";
  1779. $districtLv = $this->get_args ( 'districtLv' ) ? $this->get_args ( 'districtLv' ) : 0;
  1780. if ($lv1 == 0) {
  1781. $lv1 = isset ( $this->params ['lv1'] ) && is_numeric ( $this->params ['lv1'] ) ? $this->params ['lv1'] : 0;
  1782. if ($lv1 != 0)
  1783. $districtLv = 1;
  1784. }
  1785. if ($lv2 == 0) {
  1786. $lv2 = isset ( $this->params ['lv2'] ) && is_numeric ( $this->params ['lv2'] ) ? $this->params ['lv2'] : 0;
  1787. if ($lv2 != 0)
  1788. $districtLv = 2;
  1789. }
  1790. if ($lv3 == 0) {
  1791. $lv3 = isset ( $this->params ['lv3'] ) && is_numeric ( $this->params ['lv3'] ) ? $this->params ['lv3'] : 0;
  1792. if ($lv2 != 0)
  1793. $districtLv = 3;
  1794. }
  1795. $sortV = $this->get_args ( 'sortV' ) ? $this->get_args ( 'sortV' ) : "h";
  1796. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  1797. Doo::loadModel ( 'client_staff' );
  1798. Doo::loadModel ( 'client' );
  1799. Doo::loadModel ( 'tag' );
  1800. Doo::loadModel ( 'district' );
  1801. Doo::loadModel ( 'tag_client' );
  1802. Doo::loadModel ( 'L_category' );
  1803. Doo::loadModel ( 'longle' );
  1804. Doo::loadModel ( 'C_tooltip' );
  1805. $c_tooltip = new C_tooltip ();
  1806. $longle = new longle ();
  1807. $client = new client ();
  1808. $category = new L_category ();
  1809. $tagClient = new tag_client ();
  1810. $district = new district ();
  1811. $tag = new tag ();
  1812. $client_staff = new client_staff ();
  1813. $data ['tag'] = $tag->getAllBySid ( $this->staff [0] ['sid'] );
  1814. $data ['district2'] = $district->get_lv ( 1 );
  1815. $page_size = 200;
  1816. $linfo = $category->getCategoryById ( $this->staff [0] ['cid'], $this->staff ['0'] ['othercid'] );
  1817. $staffid = $condition = $a = "";
  1818. if ($this->staff [0] ['isadmin'] != 1) {
  1819. // 加入办事处地区
  1820. $data ['district'] = $district->get_lvByStaffid ( 1, $this->staff [0] ['sid'] );
  1821. if (! empty ( $search ))
  1822. $sch = " and ( address like '%" . $search . "%' or clientname like '%" . $search . "%' or companyname like '%" . $search . "%' or qq like '%" . $search . "%' or telephone like '%" . $search . "%' or phone like '%" . $search . "%')";
  1823. else {
  1824. // or b.district like '".$linfo[0]['districtid']."%'
  1825. $a = " and b.district like '" . $linfo [0] ['districtid'] . "%'";
  1826. if (! empty ( $tooltip ))
  1827. $sch = "";
  1828. $search = urldecode ( isset ( $this->params ['search'] ) ? $this->params ['search'] : "" );
  1829. if (! empty ( $search ))
  1830. $sch = " and ( address like '%" . $search . "%' or clientname like '%" . $search . "%' or companyname like '%" . $search . "%' or qq like '%" . $search . "%' or telephone like '%" . $search . "%' or phone like '%" . $search . "%')";
  1831. else {
  1832. $staffid = $data ['staff'] [0] ['sid'];
  1833. $sqstr = "";
  1834. foreach ( $linfo as $key => $value ) {
  1835. if ($key != 0) {
  1836. $sqstr .= " or b.district like '" . $value ['districtid'] . ",%'";
  1837. }
  1838. }
  1839. $a = "and b.district like '" . $linfo [0] ['districtid'] . ",%'" . $sqstr;
  1840. }
  1841. }
  1842. } else {
  1843. $data ['district'] = $data ['district2'];
  1844. if (! empty ( $search ))
  1845. $sch = " and ( address like '%" . $search . "%' or clientname like '%" . $search . "%' or companyname like '%" . $search . "%' or qq like '%" . $search . "%' or telephone like '%" . $search . "%' or phone like '%" . $search . "%')";
  1846. else {
  1847. $sch = " ";
  1848. $search = urldecode ( isset ( $this->params ['search'] ) ? $this->params ['search'] : "" );
  1849. if (! empty ( $search ))
  1850. $sch = " and ( address like '%" . $search . "%' or clientname like '%" . $search . "%' or companyname like '%" . $search . "%' or qq like '%" . $search . "%' or telephone like '%" . $search . "%' or phone like '%" . $search . "%')";
  1851. }
  1852. }
  1853. $data ['htmllv2'] = $data ['htmllv3'] = array ();
  1854. if ($districtLv == 1) {
  1855. $a = "";
  1856. $condition = "";
  1857. if (! empty ( $lv1 )) {
  1858. $condition .= " and district like '" . $lv1 . ",%'";
  1859. $data ['htmllv2'] = $district->get_lvByid ( 2, $lv1 );
  1860. }
  1861. }
  1862. if ($districtLv == 2) {
  1863. $a = "";
  1864. if (! empty ( $lv2 ))
  1865. $condition .= " and district like '" . $lv1 . "," . $lv2 . ",%'";
  1866. else
  1867. $condition .= " and district like '" . $lv1 . ",%'";
  1868. $data ['htmllv2'] = $district->get_lvByid ( 2, $lv1 );
  1869. $data ['htmllv3'] = $district->get_lvByid ( 2, $lv2 );
  1870. }
  1871. if ($districtLv == 3) {
  1872. $a = "";
  1873. if (! empty ( $lv3 ))
  1874. $condition .= " and district like '" . $lv1 . "," . $lv2 . "," . $lv3 . "'";
  1875. else
  1876. $condition .= " and district like '" . $lv1 . "," . $lv2 . ",%'";
  1877. $data ['htmllv2'] = $district->get_lvByid ( 2, $lv1 );
  1878. $data ['htmllv3'] = $district->get_lvByid ( 2, $lv2 );
  1879. }
  1880. $condition .= $a;
  1881. $districtCount = $condition;
  1882. if (! empty ( $lv4 )) {
  1883. $condition .= " and nature like '%" . $lv4 . "%'";
  1884. }
  1885. $tagSQL = false;
  1886. if (! empty ( $tagList )) {
  1887. $tagSQL = true;
  1888. foreach ( $tagList as $value ) {
  1889. $condition .= " and c.tag like '%" . $value . "%' ";
  1890. }
  1891. $search = "";
  1892. }
  1893. if (! empty ( $search ))
  1894. $condition .= $sch;
  1895. // if(!empty($tooltip))
  1896. // $condition.=" and tooltip like '%".$tooltip."%'";
  1897. $pageinfo = $this->get_page ( "CLD_client_staff", $condition, $page, $page_size, "", "", "", $staffid, $search, $tooltip, $this->staff [0] ['cid'], $tagSQL );
  1898. if ($sortV == "h") { // order by a.cid desc
  1899. $limit = " order by cid desc limit " . $pageinfo ['lower'] . " , " . $page_size . " ";
  1900. }
  1901. if ($sortV == "g") { // order by updatetime desc
  1902. $limit = " limit " . $pageinfo ['lower'] . " , " . $page_size . " ";
  1903. }
  1904. if ($sortV == "f") { // order by updatetime desc
  1905. $limit = " limit " . $pageinfo ['lower'] . " , " . $page_size . " ";
  1906. }
  1907. if ($sortV == "i") { // order by servicetime desc
  1908. $limit = " limit " . $pageinfo ['lower'] . " , " . $page_size . " ";
  1909. }
  1910. // 检索是全局
  1911. $data ['clientInfo'] = $client_staff->getClientByStaff ( $condition, $limit, $staffid, $this->staff [0] ['sid'], $search, $tooltip, $this->staff [0] ['cid'], $tagSQL );
  1912. // 获取其他办事处的客户
  1913. // if(!empty($districtstr)){
  1914. // $buclient=$client->getClientByDistrict($districtstr);
  1915. //
  1916. // foreach ($buclient as $key=>$vlaue){
  1917. //
  1918. // $falg=true;
  1919. //
  1920. // foreach ($data['clientInfo'] as $y=>$v){
  1921. // if($vlaue['clientname']==$v['clientname']&&$vlaue['companyname']==$v['companyname'])
  1922. // $falg=false;
  1923. // }
  1924. // if($falg)
  1925. // array_push($data['clientInfo'], $vlaue);
  1926. // }
  1927. //
  1928. // }
  1929. $k = "";
  1930. for($i = 1; $i <= $pageinfo ['total_page']; $i ++) {
  1931. if ($page == $i)
  1932. $k .= "<option value='" . $search . ":" . $i . ":" . $lv1 . ":" . $lv2 . ":" . $lv3 . "' selected>第" . $i . "页</option>";
  1933. else
  1934. $k .= "<option value='" . $search . ":" . $i . ":" . $lv1 . ":" . $lv2 . ":" . $lv3 . "'>第" . $i . "页</option>";
  1935. }
  1936. $data ['pageinfo'] = $k;
  1937. Doo::loadModel ( 'product' );
  1938. $product = new product ();
  1939. $data ['nature'] = $this->nature;
  1940. $data ['product'] = $product->getProudct ();
  1941. // 获得标签
  1942. $ClientTagList = $tagClient->getTagClientBySid ( $this->staff [0] ['sid'] );
  1943. $toollist = $c_tooltip->find ( array (
  1944. 'where' => 'cateid=' . $this->staff [0] ['cid'],
  1945. 'asArray' => true
  1946. ) );
  1947. // $ToolTipList=$
  1948. foreach ( $ClientTagList as $key => $value ) {
  1949. $ClientTagList [$key] ['taginfo'] = $tag->getTagByTidL ( $value ['tag'] );
  1950. }
  1951. // print_r($ClientTagList);die;
  1952. foreach ( $data ['clientInfo'] as $key => $value ) {
  1953. if (! empty ( $value ['cid'] )) {
  1954. // $tinfo=$tagClient->getTagClientBySCid($value['cid'], $this->staff[0]['sid']);
  1955. $data ['clientInfo'] [$key] ['taginfo'] = array ();
  1956. $data ['clientInfo'] [$key] ['tag'] = "";
  1957. foreach ( $ClientTagList as $k => $v ) {
  1958. // $tag->getTagByTidL($value['tag']);$value['tag'];
  1959. if ($value ['cid'] == $v ['client']) {
  1960. $data ['clientInfo'] [$key] ['taginfo'] = $v ['taginfo'];
  1961. $data ['clientInfo'] [$key] ['tag'] = $v ['tag'];
  1962. }
  1963. }
  1964. // array_pop 可以优化数组
  1965. }
  1966. $data ['clientInfo'] [$key] ['tooltipList'] = array ();
  1967. foreach ( $toollist as $k => $v ) {
  1968. if ($v ['cid'] == $value ['cid']) {
  1969. $data ['clientInfo'] [$key] ['tooltipList'] = explode ( ",", $v ['name'] );
  1970. break;
  1971. } // array_pop 可以优化数组
  1972. }
  1973. // $tl=array();
  1974. // if(!empty($value['tooltip']))
  1975. // $tl=explode(',', $value['tooltip']);
  1976. // $data['clientInfo'][$key]['tooltipList']=$tl;
  1977. $data ['clientInfo'] [$key] ['locount'] = 0; // $longle->count(array('where'=>'clientid='.$value['cid']));
  1978. }
  1979. $CC1 = "";
  1980. $CC2 = "";
  1981. $CC3 = "";
  1982. if (! empty ( $districtCount )) {
  1983. $clientCount = $client->find ( array (
  1984. 'select' => 'district',
  1985. 'where' => "district like '" . $lv1 . ",%'",
  1986. 'asArray' => TRUE
  1987. ) );
  1988. $CC1 = count ( $clientCount );
  1989. if (! empty ( $clientCount ) && ! empty ( $lv2 )) {
  1990. $CC2 = 0;
  1991. foreach ( $clientCount as $key => $value ) {
  1992. if (strpos ( $value ['district'], $lv2 )) {
  1993. $CC2 ++;
  1994. }
  1995. }
  1996. }
  1997. if (! empty ( $clientCount ) && ! empty ( $lv3 )) {
  1998. $CC3 = 0;
  1999. foreach ( $clientCount as $key => $value ) {
  2000. if (strpos ( $value ['district'], $lv3 )) {
  2001. $CC3 ++;
  2002. }
  2003. }
  2004. }
  2005. }
  2006. Doo::loadModel ( 'remind' );
  2007. $remind = new remind ();
  2008. // and date_add(time, INTERVAL day DAY) <= CURDATE()
  2009. $remindList = $remind->find ( array (
  2010. 'where' => "staffID = '" . $this->staff [0] ['sid'] . "' and status=0 ",
  2011. 'asc' => 'date_add(time, INTERVAL day DAY)',
  2012. 'asArray' => TRUE
  2013. ) );
  2014. $rc = 0;
  2015. foreach ( $remindList as $key => $value ) {
  2016. $a = strtotime ( $value ['time'] . " +" . $value ['day'] . " days" );
  2017. $b = strtotime ( date ( 'y-m-d' ) );
  2018. if ($a <= $b) {
  2019. $rc ++;
  2020. $remindList [$key] ['isRemind'] = 1;
  2021. } else
  2022. $remindList [$key] ['isRemind'] = 0;
  2023. $remindList [$key] ['Ctime'] = date ( 'm-d', strtotime ( $value ['time'] ) );
  2024. $remindList [$key] ['Etime'] = date ( 'm-d', strtotime ( $value ['time'] . " +" . $value ['day'] . " days" ) );
  2025. }
  2026. $data ['remindCount'] = $rc;
  2027. $data ['remindList'] = $remindList;
  2028. $data ['CC1'] = $CC1;
  2029. $data ['CC2'] = $CC2;
  2030. $data ['CC3'] = $CC3;
  2031. $data ['lv1'] = $lv1;
  2032. $data ['lv2'] = $lv2;
  2033. $data ['lv3'] = $lv3;
  2034. $data ['lv4'] = $lv4;
  2035. $data ['districtLv'] = $districtLv;
  2036. $data ['tagList'] = $tagList;
  2037. $data ['tooltip'] = $this->tooltip;
  2038. $data ['ttip'] = $tooltip;
  2039. $data ['search'] = $search;
  2040. $data ['totalData'] = $pageinfo ['total_data'];
  2041. // $data['messagehtml']=$html;
  2042. $this->render ( "/contacts_client", $data );
  2043. }
  2044. function remindCL() {
  2045. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2046. Doo::loadModel ( 'remind' );
  2047. $remind = new remind ();
  2048. $remind->status = 1;
  2049. $remind->update ( array (
  2050. 'where' => "staffID = '" . $this->staff [0] ['sid'] . "' and rid=" . $rid,
  2051. 'asArray' => TRUE
  2052. ) );
  2053. return "/contacts";
  2054. }
  2055. function communication() {
  2056. $data ['memu'] = "contacts";
  2057. $data ['staff'] = $this->staff;
  2058. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2059. Doo::loadModel ( 'L_category' );
  2060. $L_category = new L_category ();
  2061. Doo::loadModel ( 'staff' );
  2062. $staff = new staff ();
  2063. Doo::loadModel ( 'staffDynamic' );
  2064. $staffDynamic = new staffDynamic ();
  2065. if (! empty ( $cid ))
  2066. $data ['staffList'] = $staff->getStaffByCid ( $cid );
  2067. else
  2068. $data ['staffList'] = $staff->getStaff ();
  2069. foreach ( $data ['staffList'] as $key => $value ) {
  2070. if (! empty ( $value ['birthday'] )) {
  2071. $dataD = date ( "d", strtotime ( $value ['birthday'] ) );
  2072. if (date ( 'm' ) == date ( "m", strtotime ( $value ['birthday'] ) )) {
  2073. $now = date ( 'd' );
  2074. $post = $dataD - 7; // date("d",mktime(0,0,0,date("m"),date("d")+7,date("Y")));
  2075. if ($now >= $post && $now <= $dataD) {
  2076. $data ['staffList'] [$key] ['birthday'] = "birthday";
  2077. $data ['staffList'] [$key] ['birthDAY'] = date ( "m-d", strtotime ( $value ['birthday'] ) );
  2078. }
  2079. }
  2080. }
  2081. $happy = date ( "m-d", strtotime ( $value ['birthday'] ) );
  2082. if ($happy == date ( 'm-d' )) {
  2083. $SBL = $staffDynamic->getStaffBirthday ( $happy, $value ['sid'] );
  2084. if (empty ( $SBL )) {
  2085. $staffDynamic->content = '<img src="/global/img/cake.gif"><span class="colOrange">今天过生日!</span>';
  2086. $staffDynamic->cid = $value ['cid'];
  2087. $staffDynamic->category = $value ['category'];
  2088. $staffDynamic->time = time ();
  2089. $staffDynamic->sid = $value ['sid'];
  2090. $staffDynamic->staff = $value ['username'];
  2091. $staffDynamic->insert ();
  2092. }
  2093. }
  2094. }
  2095. $sDynaimic = $staffDynamic->getStaffDynamic ();
  2096. foreach ( $sDynaimic as $key => $value ) {
  2097. $time = date ( "Y-m-d", $value ['time'] );
  2098. $timeArray = explode ( '-', $time );
  2099. $sDynaimic [$key] ['year'] = $timeArray [0];
  2100. $sDynaimic [$key] ['month'] = $timeArray [1];
  2101. $sDynaimic [$key] ['day'] = $timeArray [2];
  2102. }
  2103. $data ['sDynaimic'] = $sDynaimic;
  2104. $data ['category'] = $L_category->getCategory ();
  2105. $data ['cid'] = $cid;
  2106. $this->render ( "/staff_contacts", $data );
  2107. }
  2108. function app() {
  2109. $data ['memu'] = "app";
  2110. $data ['staff'] = $this->staff;
  2111. $this->render ( "/app", $data );
  2112. }
  2113. function synClient() {
  2114. if ($this->staff [0] ['isadmin'] != 1) {
  2115. Doo::loadModel ( 'L_category' );
  2116. Doo::loadModel ( 'client_staff' );
  2117. $client_staff = new client_staff ();
  2118. $cate = new L_category ();
  2119. $district = $cate->getOne ( array (
  2120. 'where' => 'cid=' . $this->staff [0] ['cid'],
  2121. 'asArray' => true
  2122. ) );
  2123. $syn = $client_staff->synClient ( $this->staff [0] ['sid'], $district ['districtid'] );
  2124. $bei = $client_staff->find ( array (
  2125. 'where' => "sid = " . $this->staff [0] ['sid'],
  2126. 'asArray' => true
  2127. ) );
  2128. foreach ( $syn as $value ) {
  2129. $falg = true;
  2130. foreach ( $bei as $v ) {
  2131. if (($v ['cid'] == $value ['cid']) && ($v ['sid'] == $this->staff [0] ['sid'])) {
  2132. $falg = false;
  2133. break;
  2134. }
  2135. }
  2136. if ($falg) {
  2137. $client_staff = new client_staff ();
  2138. $client_staff->sid = $this->staff [0] ['sid'];
  2139. $client_staff->cid = $value ['cid'];
  2140. $client_staff->insert ();
  2141. }
  2142. }
  2143. }
  2144. return "/contacts";
  2145. }
  2146. function DoAddTagCompany() {
  2147. $cid = $this->get_args ( 'id' );
  2148. $tid = $this->get_args ( 'tagALD' );
  2149. Doo::loadModel ( 'tagCompanyNexus' );
  2150. $strtid = implode ( ",", $tid );
  2151. foreach ( $cid as $key => $value ) {
  2152. $tagClient = new tagCompanyNexus ();
  2153. $tagClientInfo = $tagClient->getTagClientBySCid ( $value, $this->staff [0] ['sid'] );
  2154. $ar = explode ( ",", $strtid . ',' . $tagClientInfo ['tag'] );
  2155. $re = array_filter ( array_unique ( $ar ) );
  2156. $tagClient->tag = implode ( ",", $re );
  2157. if (! empty ( $tagClientInfo )) {
  2158. $tagClient->tcid = $tagClientInfo ['tcid'];
  2159. $tagClient->update ();
  2160. } else {
  2161. $tagClient->sid = $this->staff [0] ['sid'];
  2162. $tagClient->company = $value;
  2163. $tagClient->insert ();
  2164. }
  2165. }
  2166. header ( "Location: /mycompany" );
  2167. }
  2168. function DoAddTag() {
  2169. $cid = $this->get_args ( 'id' );
  2170. $tooltipAct = $this->get_args ( 'tooltipAct' ) ? $this->get_args ( 'tooltipAct' ) : "";
  2171. Doo::loadModel ( 'client' );
  2172. if (! empty ( $tooltipAct )) {
  2173. $tid = $this->get_args ( 'tooltiplist' );
  2174. $k = implode ( ",", $tid );
  2175. Doo::loadModel ( 'C_tooltip' );
  2176. $s = " and cateid=" . $this->staff [0] ['cid'];
  2177. if (! empty ( $this->staff [0] ['othercid'] )) {
  2178. $othercid = explode ( ",", $this->staff [0] ['othercid'] );
  2179. foreach ( $othercid as $value ) {
  2180. $s .= " or cateid=" . $value;
  2181. }
  2182. }
  2183. foreach ( $cid as $key => $value ) {
  2184. $C_tooltip = new C_tooltip ();
  2185. $tooltip = $C_tooltip->getOne ( array (
  2186. 'where' => 'cid=' . $value . " " . $s,
  2187. 'asArray' => true
  2188. ) );
  2189. if (empty ( $tooltip )) {
  2190. $C_tooltip->cid = $value;
  2191. $C_tooltip->name = $k;
  2192. $C_tooltip->cateid = $this->staff [0] ['cid'];
  2193. $C_tooltip->insert ();
  2194. } else {
  2195. $C_tooltip->tip = $tooltip ['tip'];
  2196. $C_tooltip->name = $k;
  2197. $C_tooltip->update ();
  2198. }
  2199. }
  2200. } else {
  2201. $tid = $this->get_args ( 'tagALD' );
  2202. Doo::loadModel ( 'tag_client' );
  2203. $strtid = implode ( ",", $tid );
  2204. foreach ( $cid as $key => $value ) {
  2205. $tagClient = new tag_client ();
  2206. $tagClientInfo = $tagClient->getTagClientBySCid ( $value, $this->staff [0] ['sid'] );
  2207. $ar = explode ( ",", $strtid . ',' . $tagClientInfo ['tag'] );
  2208. $re = array_filter ( array_unique ( $ar ) );
  2209. $tagClient->tag = implode ( ",", $re );
  2210. if (! empty ( $tagClientInfo )) {
  2211. $tagClient->tcid = $tagClientInfo ['tcid'];
  2212. $tagClient->update ();
  2213. } else {
  2214. $tagClient->sid = $this->staff [0] ['sid'];
  2215. $tagClient->client = $value;
  2216. $tagClient->insert ();
  2217. }
  2218. }
  2219. }
  2220. header ( "Location: /contacts" );
  2221. }
  2222. function ajaxDeleteTag() {
  2223. $cid = $this->get_args ( 'cid' );
  2224. $tid = $this->get_args ( 'tid' );
  2225. Doo::loadModel ( 'tag_client' );
  2226. $tagClient = new tag_client ();
  2227. $tagInfo = $tagClient->getTagClientBySCid ( $cid, $this->staff [0] ['sid'] );
  2228. $tag = str_replace ( $tid, "", $tagInfo ['tag'] );
  2229. $ar = explode ( ',', $tag );
  2230. $tag = implode ( ',', array_filter ( $ar ) );
  2231. $tagClient->tcid = $tagInfo ['tcid'];
  2232. $tagClient->tag = $tag;
  2233. $tagClient->update ();
  2234. }
  2235. function ajaxDeleteTagCompany() {
  2236. $cid = $this->get_args ( 'cid' );
  2237. $tid = $this->get_args ( 'tid' );
  2238. Doo::loadModel ( 'tagCompanyNexus' );
  2239. $tagClient = new tagCompanyNexus ();
  2240. $tagInfo = $tagClient->getTagClientBySCid ( $cid, $this->staff [0] ['sid'] );
  2241. $tag = str_replace ( $tid, "", $tagInfo ['tag'] );
  2242. $ar = explode ( ',', $tag );
  2243. $tag = implode ( ',', array_filter ( $ar ) );
  2244. $tagClient->tcid = $tagInfo ['tcid'];
  2245. $tagClient->tag = $tag;
  2246. $tagClient->update ();
  2247. }
  2248. function deleteToolTip() {
  2249. $cid = $this->get_args ( 'cid' );
  2250. $cateid = $this->get_args ( 'cateid' );
  2251. $name = $this->get_args ( 'name' );
  2252. Doo::loadModel ( "C_tooltip" );
  2253. $tooltip = new C_tooltip ();
  2254. if (! empty ( $cid ) && ! empty ( $cateid ) && ! empty ( $name )) {
  2255. $tool = $tooltip->getOne ( array (
  2256. 'where' => 'cid=' . $cid . ' and cateid=' . $cateid,
  2257. 'asArray' => true
  2258. ) );
  2259. if (! empty ( $tool )) {
  2260. $name = str_replace ( $name, "", $tool ['name'] );
  2261. $name = explode ( ',', $name );
  2262. $name = implode ( ',', array_filter ( $name ) );
  2263. $tooltip->name = $name;
  2264. $tooltip->tip = $tool ['tip'];
  2265. $tooltip->update ();
  2266. }
  2267. }
  2268. }
  2269. function DoEdiTagCompany() {
  2270. $tag_1 = $this->get_args ( 'tag_1' ) ? $this->get_args ( 'tag_1' ) : "";
  2271. $tag_2 = $this->get_args ( 'tag_2' ) ? $this->get_args ( 'tag_2' ) : "";
  2272. $tag_3 = $this->get_args ( 'tag_3' ) ? $this->get_args ( 'tag_3' ) : "";
  2273. $tag_4 = $this->get_args ( 'tag_4' ) ? $this->get_args ( 'tag_4' ) : "";
  2274. $tag_5 = $this->get_args ( 'tag_5' ) ? $this->get_args ( 'tag_5' ) : "";
  2275. $tag_6 = $this->get_args ( 'tag_6' ) ? $this->get_args ( 'tag_6' ) : "";
  2276. $tag_7 = $this->get_args ( 'tag_7' ) ? $this->get_args ( 'tag_7' ) : "";
  2277. $tid_1 = $this->get_args ( 'tid_1' ) ? $this->get_args ( 'tid_1' ) : 0;
  2278. $tid_2 = $this->get_args ( 'tid_2' ) ? $this->get_args ( 'tid_2' ) : 0;
  2279. $tid_3 = $this->get_args ( 'tid_3' ) ? $this->get_args ( 'tid_3' ) : 0;
  2280. $tid_4 = $this->get_args ( 'tid_4' ) ? $this->get_args ( 'tid_4' ) : 0;
  2281. $tid_5 = $this->get_args ( 'tid_5' ) ? $this->get_args ( 'tid_5' ) : 0;
  2282. $tid_6 = $this->get_args ( 'tid_6' ) ? $this->get_args ( 'tid_6' ) : 0;
  2283. $tid_7 = $this->get_args ( 'tid_7' ) ? $this->get_args ( 'tid_7' ) : 0;
  2284. Doo::loadModel ( 'tagCompany' );
  2285. if (! empty ( $tag_1 ) && ! empty ( $tid_1 )) {
  2286. $tag = new tagCompany ();
  2287. $tag->tid = $tid_1;
  2288. $tag->name = $tag_1;
  2289. $tag->update ();
  2290. }
  2291. if (! empty ( $tag_2 ) && ! empty ( $tid_2 )) {
  2292. $tag = new tagCompany ();
  2293. $tag->tid = $tid_2;
  2294. $tag->name = $tag_2;
  2295. $tag->update ();
  2296. }
  2297. if (! empty ( $tag_3 ) && ! empty ( $tid_3 )) {
  2298. $tag = new tagCompany ();
  2299. $tag->tid = $tid_3;
  2300. $tag->name = $tag_3;
  2301. $tag->update ();
  2302. }
  2303. if (! empty ( $tag_4 ) && ! empty ( $tid_4 )) {
  2304. $tag = new tagCompany ();
  2305. $tag->tid = $tid_4;
  2306. $tag->name = $tag_4;
  2307. $tag->update ();
  2308. }
  2309. if (! empty ( $tag_5 ) && ! empty ( $tid_5 )) {
  2310. $tag = new tagCompany ();
  2311. $tag->tid = $tid_5;
  2312. $tag->name = $tag_5;
  2313. $tag->update ();
  2314. }
  2315. if (! empty ( $tag_6 ) && ! empty ( $tid_6 )) {
  2316. $tag = new tagCompany ();
  2317. $tag->tid = $tid_6;
  2318. $tag->name = $tag_6;
  2319. $tag->update ();
  2320. }
  2321. if (! empty ( $tag_7 ) && ! empty ( $tid_7 )) {
  2322. $tag = new tagCompany ();
  2323. $tag->tid = $tid_7;
  2324. $tag->name = $tag_7;
  2325. $tag->update ();
  2326. }
  2327. return "/mycompany";
  2328. }
  2329. function DoEdiTag() {
  2330. $tag_1 = $this->get_args ( 'tag_1' ) ? $this->get_args ( 'tag_1' ) : "";
  2331. $tag_2 = $this->get_args ( 'tag_2' ) ? $this->get_args ( 'tag_2' ) : "";
  2332. $tag_3 = $this->get_args ( 'tag_3' ) ? $this->get_args ( 'tag_3' ) : "";
  2333. $tag_4 = $this->get_args ( 'tag_4' ) ? $this->get_args ( 'tag_4' ) : "";
  2334. $tag_5 = $this->get_args ( 'tag_5' ) ? $this->get_args ( 'tag_5' ) : "";
  2335. $tag_6 = $this->get_args ( 'tag_6' ) ? $this->get_args ( 'tag_6' ) : "";
  2336. $tag_7 = $this->get_args ( 'tag_7' ) ? $this->get_args ( 'tag_7' ) : "";
  2337. $tid_1 = $this->get_args ( 'tid_1' ) ? $this->get_args ( 'tid_1' ) : 0;
  2338. $tid_2 = $this->get_args ( 'tid_2' ) ? $this->get_args ( 'tid_2' ) : 0;
  2339. $tid_3 = $this->get_args ( 'tid_3' ) ? $this->get_args ( 'tid_3' ) : 0;
  2340. $tid_4 = $this->get_args ( 'tid_4' ) ? $this->get_args ( 'tid_4' ) : 0;
  2341. $tid_5 = $this->get_args ( 'tid_5' ) ? $this->get_args ( 'tid_5' ) : 0;
  2342. $tid_6 = $this->get_args ( 'tid_6' ) ? $this->get_args ( 'tid_6' ) : 0;
  2343. $tid_7 = $this->get_args ( 'tid_7' ) ? $this->get_args ( 'tid_7' ) : 0;
  2344. Doo::loadModel ( 'tag' );
  2345. if (! empty ( $tag_1 ) && ! empty ( $tid_1 )) {
  2346. $tag = new tag ();
  2347. $tag->tid = $tid_1;
  2348. $tag->name = $tag_1;
  2349. $tag->update ();
  2350. }
  2351. if (! empty ( $tag_2 ) && ! empty ( $tid_2 )) {
  2352. $tag = new tag ();
  2353. $tag->tid = $tid_2;
  2354. $tag->name = $tag_2;
  2355. $tag->update ();
  2356. }
  2357. if (! empty ( $tag_3 ) && ! empty ( $tid_3 )) {
  2358. $tag = new tag ();
  2359. $tag->tid = $tid_3;
  2360. $tag->name = $tag_3;
  2361. $tag->update ();
  2362. }
  2363. if (! empty ( $tag_4 ) && ! empty ( $tid_4 )) {
  2364. $tag = new tag ();
  2365. $tag->tid = $tid_4;
  2366. $tag->name = $tag_4;
  2367. $tag->update ();
  2368. }
  2369. if (! empty ( $tag_5 ) && ! empty ( $tid_5 )) {
  2370. $tag = new tag ();
  2371. $tag->tid = $tid_5;
  2372. $tag->name = $tag_5;
  2373. $tag->update ();
  2374. }
  2375. if (! empty ( $tag_6 ) && ! empty ( $tid_6 )) {
  2376. $tag = new tag ();
  2377. $tag->tid = $tid_6;
  2378. $tag->name = $tag_6;
  2379. $tag->update ();
  2380. }
  2381. if (! empty ( $tag_7 ) && ! empty ( $tid_7 )) {
  2382. $tag = new tag ();
  2383. $tag->tid = $tid_7;
  2384. $tag->name = $tag_7;
  2385. $tag->update ();
  2386. }
  2387. return "/contacts";
  2388. }
  2389. function ajaxGetLv2() {
  2390. $lv1 = $this->get_args ( 'lv1' ) ? $this->get_args ( 'lv1' ) : 0;
  2391. $s = $this->get_args ( 's' ) ? $this->get_args ( 's' ) : 0;
  2392. if ($lv1 == 0) {
  2393. echo json_encode ( array (
  2394. "success" => false,
  2395. "info" => ""
  2396. ) );
  2397. die ();
  2398. }
  2399. if (! empty ( $lv1 )) {
  2400. Doo::loadModel ( 'district' );
  2401. $district = new district ();
  2402. $district = $district->get_lvByid ( $s, $lv1 );
  2403. echo json_encode ( array (
  2404. "success" => true,
  2405. "info" => $district
  2406. ) );
  2407. }
  2408. }
  2409. function keyonline() {
  2410. $data ['memu'] = "keyonline";
  2411. $data ['staff'] = $this->staff;
  2412. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  2413. if (empty ( $year ))
  2414. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( 'Y' );
  2415. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "";
  2416. if (empty ( $cid ))
  2417. $cid = isset ( $this->params ['cid'] ) ? $this->params ['cid'] : $this->staff [0] ['cid'];
  2418. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  2419. if (empty ( $staff ))
  2420. $staff = isset ( $this->params ['staff'] ) ? $this->params ['staff'] : "";
  2421. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : "";
  2422. if (empty ( $status ))
  2423. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  2424. $search = $this->get_args ( 'search' ) ? $this->get_args ( 'search' ) : "";
  2425. $productW = $this->get_args ( 'product' ) ? $this->get_args ( 'product' ) : "";
  2426. Doo::loadModel ( 'longle' );
  2427. $longle = new longle ();
  2428. $data ['longleArray'] = $longle->getLongleByStatus ( $year, $cid, $staff, $status, $search, $productW );
  2429. // 获取接收锁信息
  2430. // $longle->getLongleByRe($this->staff[0]['cid'],1);
  2431. $othstr = "";
  2432. if (! empty ( $this->staff [0] ['othercid'] ))
  2433. $othstr = " cid in (" . $this->staff [0] ['cid'] . "," . $this->staff [0] ['othercid'] . ")";
  2434. else
  2435. $othstr = " cid in (" . $this->staff [0] ['cid'] . ")";
  2436. $data ['reLongle'] = $longle->count ( array (
  2437. 'where' => $othstr . ' and status=1'
  2438. ) );
  2439. $data ['cid'] = $cid;
  2440. $data ['year'] = $year;
  2441. $data ['staff'] = $staff;
  2442. $data ['status'] = $status;
  2443. $data ['productName'] = $productW;
  2444. Doo::loadModel ( 'L_category' );
  2445. Doo::loadModel ( 'staff' );
  2446. Doo::loadModel ( 'product' );
  2447. $product = new product ();
  2448. $staff = new staff ();
  2449. $L_category = new L_category ();
  2450. $data ['product'] = $product->getProudct ();
  2451. $data ['staffu'] = $staff->getUserById ( $this->staff [0] ['sid'] );
  2452. $data ['category'] = $L_category->getCategory ();
  2453. $data ['staffList'] = $staff->getStaffByCid ( $cid );
  2454. if ($cid == 1)
  2455. $data ['cid'] = $data ['category'] [0] ['cid'];
  2456. $dateHtml = "";
  2457. $now = date ( "Y" );
  2458. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  2459. if ($YEARD <= $now) {
  2460. $dateHtml .= '<option ';
  2461. if ($data ['year'] == $YEARD) {
  2462. $dateHtml .= 'selected ';
  2463. }
  2464. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  2465. }
  2466. }
  2467. $data ['dateHtml'] = $dateHtml;
  2468. $this->render ( "/lock_look", $data );
  2469. }
  2470. function keyStatistics() {
  2471. Doo::loadModel ( 'staff' );
  2472. $staff = new staff ();
  2473. Doo::loadModel ( 'longle' );
  2474. $longle = new longle ();
  2475. $staffCondition = "";
  2476. if ($this->staff [0] ['cid'] != 12)
  2477. $staffCondition = " and cid=" . $this->staff [0] ['cid'];
  2478. $staffList = $staff->find ( array (
  2479. 'where' => "isadmin= 0 " . $staffCondition,
  2480. 'asArray' => TRUE
  2481. ) );
  2482. Doo::db ()->beginTransaction ();
  2483. foreach ( $staffList as $key => $value ) { // not in(1,2)
  2484. $sum = $longle->count ( array (
  2485. 'where' => "status!= 1 and responsible ='" . $value ['username'] . "'",
  2486. 'asArray' => TRUE
  2487. ) );
  2488. $a = $longle->count ( array (
  2489. 'where' => "status!= 2 and status!= 1 and responsible ='" . $value ['username'] . "'",
  2490. 'asArray' => TRUE
  2491. ) );
  2492. $b = $sum - $a;
  2493. $staffList [$key] ['sum'] = $sum;
  2494. $staffList [$key] ['a'] = $a;
  2495. $staffList [$key] ['b'] = $b;
  2496. }
  2497. Doo::db ()->commit ();
  2498. $data ['staff'] = $this->staff;
  2499. $data ['staffList'] = $staffList;
  2500. $data ['memu'] = "keyStatistics";
  2501. $this->render ( "lock_count", $data );
  2502. }
  2503. function addDoLockLog() {
  2504. Doo::loadModel ( 'longle_log' );
  2505. Doo::loadModel ( 'longle' );
  2506. Doo::loadModel ( "action_log" );
  2507. Doo::loadModel ( 'client' );
  2508. $clientobj = new client ();
  2509. $longle = new longle ();
  2510. $longle_log = new longle_log ();
  2511. Doo::loadModel ( 'district' );
  2512. $district = new district ();
  2513. $status = $this->get_args ( 'longleStatus' ) ? $this->get_args ( 'longleStatus' ) : 0;
  2514. $lid = $this->get_args ( 'klid' ) ? $this->get_args ( 'klid' ) : 0;
  2515. if (empty ( $lid ))
  2516. return "/keyonline/";
  2517. $linfo = $longle->getLongleByLid ( $lid );
  2518. if ($status == 0)
  2519. return "/keyonline/" . $lid;
  2520. elseif ($status == 3) {
  2521. $client = $this->get_args ( 'browseClient' ) ? $this->get_args ( 'browseClient' ) : "";
  2522. $client = explode ( '-', $client );
  2523. $product = $this->get_args ( 'browseProduct' ) ? $this->get_args ( 'browseProduct' ) : "";
  2524. $clientname = $clientobj->getClientByName2 ( $client [0], $client [1] );
  2525. if (empty ( $clientname ))
  2526. return "/keyonline/" . $lid;
  2527. if ($client [0] != "") {
  2528. $longle->client = $client [0];
  2529. $longle->clientid = $clientname [0] ['cid'];
  2530. }
  2531. // if($product!="")
  2532. // $longle->product=$product;
  2533. $longle->statusT = "借出";
  2534. $longle_log->client = $client [0];
  2535. $longle_log->clientid = $clientname [0] ['cid'];
  2536. $longle_log->product = $linfo [0] ['product'];
  2537. $longle_log->statusT = "借出";
  2538. // 日常行为
  2539. $action_log = new action_log ();
  2540. $action_log->action = $this->staff [0] ['category'] . '<b href="javascript:void(0)" onclick="showStaff(\'' . $this->staff [0] ['sid'] . '\')">' . $this->staff [0] ['username'] . '</b>借出<a href="javascript:void(0)" onclick="showLook(\'' . $linfo [0] ['key_num'] . '\')">' . $linfo [0] ['key_num'] . '</a>给<a href="javascript:void(0)" onclick="showClick(\'' . $clientname [0] ['cid'] . '\')">' . $client [0] . '</a>(' . $clientname [0] ['companyname'] . ')';
  2541. $action_log->sid = $this->staff [0] ['sid'];
  2542. $action_log->cid = $this->staff [0] ['cid'];
  2543. $action_log->updatetime = date ( "Y-m-d" );
  2544. $action_log->time = date ( "H:i" );
  2545. $action_log->status = 4;
  2546. $action_log->districtid = $clientname [0] ['district'];
  2547. $local = $district->getbyidlist ( $clientname [0] ['district'] );
  2548. $action_log->city = $local [0] ['name'];
  2549. $action_log->province = $local [1] ['name'];
  2550. $action_log->company = $clientname [0] ['companyname'];
  2551. Doo::loadModel ( 'company' );
  2552. $company = new company ();
  2553. $companyInfo = $company->getOne ( array (
  2554. 'where' => ' companyname="' . $clientname [0] ['companyname'] . '"',
  2555. 'asArray' => true
  2556. ) );
  2557. $nature = explode ( ',', $companyInfo ['nature'] );
  2558. $action_log->nature = $nature [0];
  2559. $action_log->class = $action_log->iconBorrow;
  2560. $action_log->insert ();
  2561. } elseif ($status == 4) {
  2562. $product = $this->get_args ( 'sellProduct' ) ? $this->get_args ( 'sellProduct' ) : "";
  2563. $client = $this->get_args ( 'sellClient' ) ? $this->get_args ( 'sellClient' ) : "";
  2564. $client = explode ( '-', $client );
  2565. $clientname = $clientobj->getClientByName2 ( $client [0], $client [1] );
  2566. if (empty ( $clientname ))
  2567. return "/keyonline/" . $lid;
  2568. if ($client [0] != "") {
  2569. $longle->client = $client [0];
  2570. $longle->clientid = $clientname [0] ['cid'];
  2571. }
  2572. // if($product!="")
  2573. // $longle->product=$product;
  2574. $longle->statusT = "销售";
  2575. $longle_log->client = $client [0];
  2576. $longle_log->clientid = $clientname [0] ['cid'];
  2577. $longle_log->product = $linfo [0] ['product'];
  2578. $longle_log->statusT = "销售";
  2579. // 日常行为
  2580. $action_log = new action_log ();
  2581. $action_log->action = $this->staff [0] ['category'] . '<b href="javascript:void(0)" onclick="showStaff(\'' . $this->staff [0] ['sid'] . '\')">' . $this->staff [0] ['username'] . '</b>销售<a href="javascript:void(0)" onclick="showLook(\'' . $linfo [0] ['key_num'] . '\')">' . $linfo [0] ['key_num'] . '</a>给<a href="javascript:void(0)" onclick="showClick(\'' . $clientname [0] ['cid'] . '\')">' . $client [0] . '</a>(' . $clientname [0] ['companyname'] . ')';
  2582. $action_log->sid = $this->staff [0] ['sid'];
  2583. $action_log->cid = $this->staff [0] ['cid'];
  2584. $action_log->updatetime = date ( "Y-m-d" );
  2585. $action_log->time = date ( "H:i" );
  2586. $action_log->status = 5;
  2587. $action_log->districtid = $clientname [0] ['district'];
  2588. $local = $district->getbyidlist ( $clientname [0] ['district'] );
  2589. $action_log->city = $local [0] ['name'];
  2590. $action_log->province = $local [1] ['name'];
  2591. $action_log->company = $clientname [0] ['companyname'];
  2592. Doo::loadModel ( 'company' );
  2593. $company = new company ();
  2594. $companyInfo = $company->getOne ( array (
  2595. 'where' => ' companyname="' . $clientname [0] ['companyname'] . '"',
  2596. 'asArray' => true
  2597. ) );
  2598. $nature = explode ( ',', $companyInfo ['nature'] );
  2599. $action_log->nature = $nature [0];
  2600. $action_log->class = $action_log->iconSell;
  2601. $action_log->insert ();
  2602. } elseif ($status == 5) {
  2603. $product = $this->get_args ( 'newProduct' ) ? $this->get_args ( 'newProduct' ) : "";
  2604. if ($product != "")
  2605. $longle->product = $linfo [0] ['product'] . "+" . $product;
  2606. $longle->statusT = "升级";
  2607. $longle_log->product = $linfo [0] ['product'] . "+" . $product;
  2608. $longle_log->statusT = "升级";
  2609. $longle_log->client = $linfo [0] ['client'];
  2610. $longle_log->clientid = $linfo [0] ['clientid'];
  2611. $clientname = $clientobj->getOne ( array (
  2612. 'where' => "cid= '" . $linfo [0] ['clientid'] . "'",
  2613. 'asArray' => TRUE
  2614. ) );
  2615. // 日常行为
  2616. $action_log = new action_log ();
  2617. $action_log->action = $this->staff [0] ['category'] . '<b href="javascript:void(0)" onclick="showStaff(\'' . $this->staff [0] ['sid'] . '\')" >' . $this->staff [0] ['username'] . '</b>为<a href="javascript:void(0)" onclick="showClick(\'' . $linfo [0] ['clientid'] . '\')">' . $linfo [0] ['client'] . '</a>(' . $clientname ['companyname'] . ')升级为<a href="javascript:void(0)" onclick="showLook(\'' . $linfo [0] ['key_num'] . '\')">' . $linfo [0] ['key_num'] . '</a>';
  2618. $action_log->sid = $this->staff [0] ['sid'];
  2619. $action_log->cid = $this->staff [0] ['cid'];
  2620. $action_log->updatetime = date ( "Y-m-d" );
  2621. $action_log->time = date ( "H:i" );
  2622. $action_log->class = $action_log->iconUpdate;
  2623. $action_log->sid = $this->staff [0] ['sid'];
  2624. $action_log->cid = $this->staff [0] ['cid'];
  2625. $action_log->status = 7;
  2626. $action_log->insert ();
  2627. } elseif ($status == 6) {
  2628. $key_num = $this->get_args ( 'key_num' ) ? $this->get_args ( 'key_num' ) : "";
  2629. $key_num2 = explode ( "-", $key_num );
  2630. $key_num = $key_num2 [0] . "-" . $key_num2 [1];
  2631. // if($key_num!="")
  2632. // $longle->key_num=$key_num;
  2633. // 新锁拷贝记录
  2634. $newLongle = new longle ();
  2635. // $newLongle->product=$linfo[0]['product'];
  2636. $newLongle->statusT = "更换";
  2637. $newLongle->status = 6;
  2638. $newLongle->client = $linfo [0] ['client'];
  2639. $newLongle->clientid = $linfo [0] ['clientid'];
  2640. $newlid = $newLongle->update ( array (
  2641. 'where' => ' key_num= \'' . $key_num . "'"
  2642. ) );
  2643. $longleinfo = $longle->getOne ( array (
  2644. 'where' => ' key_num =\'' . $key_num . "'",
  2645. 'asArray' => true
  2646. ) );
  2647. $longleLog = $longle_log->getOne ( array (
  2648. 'where' => ' lid =' . $linfo [0] ['lid'],
  2649. 'desc' => 'logid',
  2650. 'asArray' => true
  2651. ) );
  2652. // 新记录日志
  2653. $newlongle_log = new longle_log ();
  2654. $newlongle_log->statusT = "更换";
  2655. $newlongle_log->status = 6;
  2656. $newlongle_log->client = $linfo [0] ['client'];
  2657. $newlongle_log->new_key_num = $linfo [0] ['key_num'];
  2658. $newlongle_log->product = $linfo [0] ['product'];
  2659. $newlongle_log->category = $this->staff [0] ['category'];
  2660. $newlongle_log->dateline = date ( "Y-m-d" );
  2661. $newlongle_log->operator = $this->staff [0] ['username'];
  2662. $newlongle_log->lid = $longleinfo ['lid'];
  2663. $newlongle_log->insert ();
  2664. $newlongle_log = new longle_log ();
  2665. $newlongle_log->statusT = $longleLog ['statusT'];
  2666. $newlongle_log->status = $longleLog ['status'];
  2667. $newlongle_log->client = $longleLog ['client'];
  2668. $newlongle_log->new_key_num = $longleLog ['new_key_num'];
  2669. $newlongle_log->product = $longleLog ['product'];
  2670. $newlongle_log->category = $longleLog ['category'];
  2671. $newlongle_log->dateline = $longleLog ['dateline'];
  2672. $newlongle_log->operator = $longleLog ['operator'];
  2673. $newlongle_log->lid = $longleinfo ['lid'];
  2674. $newlongle_log->insert ();
  2675. $newLongle = new longle ();
  2676. $newLongle->statusT = $longleLog ['statusT'];
  2677. $newLongle->status = $longleLog ['status'];
  2678. $newlid = $newLongle->update ( array (
  2679. 'where' => ' key_num= \'' . $key_num . "'"
  2680. ) );
  2681. // 新锁状态拷贝
  2682. $longle->statusT = "更换";
  2683. $longle_log->new_key_num = $key_num;
  2684. $longle_log->statusT = "更换";
  2685. $longle_log->client = $linfo [0] ['client'];
  2686. $clientname = $clientobj->getOne ( array (
  2687. 'where' => "cid= '" . $linfo [0] ['clientid'] . "'",
  2688. 'asArray' => TRUE
  2689. ) );
  2690. // 日常行为
  2691. $action_log = new action_log ();
  2692. $action_log->action = $this->staff [0] ['category'] . '<b href="javascript:void(0)" onclick="showStaff(\'' . $this->staff [0] ['sid'] . '\')">' . $this->staff [0] ['username'] . '</b>为<a href="javascript:void(0)" onclick="showClick(\'' . $linfo [0] ['clientid'] . '\')">' . $linfo [0] ['client'] . '</a>(' . $clientname ['companyname'] . ')更换为<a href="javascript:void(0)" onclick="showLook(\'' . $key_num . '\')">' . $key_num . '</a>(' . $linfo [0] ['key_num'] . ')';
  2693. $action_log->sid = $this->staff [0] ['sid'];
  2694. $action_log->cid = $this->staff [0] ['cid'];
  2695. $action_log->updatetime = date ( "Y-m-d" );
  2696. $action_log->time = date ( "H:i" );
  2697. $action_log->class = $action_log->iconReplace;
  2698. $action_log->sid = $this->staff [0] ['sid'];
  2699. $action_log->cid = $this->staff [0] ['cid'];
  2700. $action_log->status = 8;
  2701. $action_log->insert ();
  2702. } elseif ($status == 7) {
  2703. $longle->statusT = "收回";
  2704. $longle_log->statusT = "收回";
  2705. $longle_log->responsible = $linfo [0] ['responsible'];
  2706. // 日常行为
  2707. $action_log = new action_log ();
  2708. $action_log->action = $this->staff [0] ['category'] . '<b href="javascript:void(0)" onclick="showStaff(\'' . $this->staff [0] ['sid'] . '\')">' . $this->staff [0] ['username'] . '</b>收回<a href="javascript:void(0)">' . $linfo [0] ['client'] . '</a>的<a href="javascript:void(0)" onclick="showLook(\'' . $linfo [0] ['key_num'] . '\')">' . $linfo [0] ['key_num'] . '</a>通过<a href="javascript:void(0)" onclick="showStaff(\'' . $this->staff [0] ['responsible'] . '\')">' . $this->staff [0] ['responsible'] . '</a>';
  2709. $action_log->sid = $this->staff [0] ['sid'];
  2710. $action_log->cid = $this->staff [0] ['cid'];
  2711. $action_log->updatetime = date ( "Y-m-d" );
  2712. $action_log->time = date ( "H:i" );
  2713. $action_log->class = $action_log->iconRecycle;
  2714. $action_log->sid = $this->staff [0] ['sid'];
  2715. $action_log->cid = $this->staff [0] ['cid'];
  2716. $action_log->status = 9;
  2717. $action_log->insert ();
  2718. } elseif ($status == 8) {
  2719. $mark = $this->get_args ( 'mark' ) ? $this->get_args ( 'mark' ) : "";
  2720. if (empty ( $mark )) {
  2721. echo json_encode ( array (
  2722. 'msg' => 2
  2723. ) );
  2724. die ();
  2725. }
  2726. $longle_log->mark = $mark;
  2727. // 日常行为
  2728. $action_log = new action_log ();
  2729. $action_log->action = $this->staff [0] ['category'] . '<b href="javascript:void(0)" onclick="showStaff(\'' . $this->staff [0] ['sid'] . '\')">' . $this->staff [0] ['username'] . '</b>为<a href="javascript:void(0)" onclick="showLook(\'' . $linfo [0] ['key_num'] . '\')">' . $linfo [0] ['key_num'] . '</a>添加新备注。';
  2730. $action_log->sid = $this->staff [0] ['sid'];
  2731. $action_log->cid = $this->staff [0] ['cid'];
  2732. $action_log->updatetime = date ( "Y-m-d" );
  2733. $action_log->time = date ( "H:i" );
  2734. $action_log->sid = $this->staff [0] ['sid'];
  2735. $action_log->cid = $this->staff [0] ['cid'];
  2736. $action_log->status = 10;
  2737. $action_log->class = $action_log->iconLock;
  2738. $action_log->insert ();
  2739. } elseif ($status == 9) {
  2740. $longle->statusT = "赠送";
  2741. $longle_log->statusT = "赠送";
  2742. $client = $this->get_args ( 'giftClient' ) ? $this->get_args ( 'giftClient' ) : "";
  2743. $client = explode ( '-', $client );
  2744. $clientname = $clientobj->getClientByName2 ( $client [0], $client [1] );
  2745. if (empty ( $clientname ))
  2746. return "/keyonline/" . $lid;
  2747. if ($client [0] != "") {
  2748. $longle->client = $client [0];
  2749. $longle->clientid = $clientname [0] ['cid'];
  2750. }
  2751. $longle_log->client = $client [0];
  2752. $longle_log->clientid = $clientname [0] ['cid'];
  2753. // 日常行为
  2754. $action_log = new action_log ();
  2755. $action_log->action = $this->staff [0] ['category'] . '<b href="javascript:void(0)" onclick="showStaff(\'' . $this->staff [0] ['username'] . '\')">' . $this->staff [0] ['username'] . '</b>赠送<a href="javascript:void(0)" onclick="showLook(\'' . $linfo [0] ['key_num'] . '\')">' . $linfo [0] ['key_num'] . '</a>给<a href="javascript:void(0)" onclick="showClick(\'' . $clientname [0] ['cid'] . '\')">' . $client [0] . '</a>(' . $clientname [0] ['companyname'] . ')';
  2756. $action_log->updatetime = date ( "Y-m-d" );
  2757. $action_log->time = date ( "H:i" );
  2758. $action_log->class = $action_log->iconRecycle;
  2759. $action_log->sid = $this->staff [0] ['sid'];
  2760. $action_log->cid = $this->staff [0] ['cid'];
  2761. $action_log->status = 6;
  2762. $action_log->districtid = $clientname [0] ['district'];
  2763. $local = $district->getbyidlist ( $clientname [0] ['district'] );
  2764. $action_log->city = $local [0] ['name'];
  2765. $action_log->province = $local [1] ['name'];
  2766. $action_log->company = $clientname [0] ['companyname'];
  2767. Doo::loadModel ( 'company' );
  2768. $company = new company ();
  2769. $companyInfo = $company->getOne ( array (
  2770. 'where' => ' companyname="' . $clientname [0] ['companyname'] . '"',
  2771. 'asArray' => true
  2772. ) );
  2773. $nature = explode ( ',', $companyInfo ['nature'] );
  2774. $action_log->nature = $nature [0];
  2775. $action_log->insert ();
  2776. }
  2777. // 记录使用过的状态
  2778. $statuslog = $status . "," . $linfo [0] ['statuslog'];
  2779. $ar = explode ( ',', $statuslog );
  2780. $statuslog = implode ( ',', array_unique ( array_filter ( $ar ) ) );
  2781. $longle->statuslog = $statuslog;
  2782. if ($linfo [0] ['status'] <= 2) {
  2783. if ($status >= 4 && $status <= 2) {
  2784. return "/keyonline/" . $lid;
  2785. }
  2786. }
  2787. if ($lid != 0) {
  2788. $longle->lid = $lid;
  2789. if ($status != 8)
  2790. $longle->status = $status;
  2791. // if($status!=8)
  2792. $longle->responsible = $this->staff [0] ['username'];
  2793. $longle->update ();
  2794. }
  2795. $longle_log->lid = $lid;
  2796. $longle_log->status = $status;
  2797. $longle_log->operator = $this->staff [0] ['username'];
  2798. // 责任人
  2799. $longle_log->category = $this->staff [0] ['category'];
  2800. $longle_log->dateline = date ( "Y-m-d" );
  2801. $longle_log->insert ();
  2802. echo json_encode ( array (
  2803. 'msg' => 1
  2804. ) );
  2805. die ();
  2806. // return "/keyonline/".$lid;
  2807. }
  2808. function ajaxGetLongleByName() {
  2809. Doo::loadModel ( 'longle_log' );
  2810. Doo::loadModel ( 'longle' );
  2811. $longle = new longle ();
  2812. $longle_log = new longle_log ();
  2813. $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : "";
  2814. if (empty ( $name )) {
  2815. echo json_encode ( array (
  2816. "success" => false
  2817. ) );
  2818. die ();
  2819. }
  2820. $ky = $longle->getLongleBykeynum ( $name );
  2821. $t = $longle_log->getLongleByLid ( $ky [0] ['lid'] );
  2822. if (isset ( $t [0] ))
  2823. $tk = $t [0];
  2824. else
  2825. $tk = array ();
  2826. $longleLog = $tk;
  2827. $longleLog ['klid'] = $t [0] ['lid'];
  2828. $longleLog ['longle'] = $ky [0];
  2829. $longleLog ['longleLogHtml'] = $this->_getLongleLogHtml ( $t );
  2830. echo json_encode ( $longleLog );
  2831. }
  2832. function ajaxGetLongleN() {
  2833. Doo::loadModel ( 'longle_log' );
  2834. Doo::loadModel ( 'longle' );
  2835. $longle = new longle ();
  2836. $longle_log = new longle_log ();
  2837. $keynum = $this->get_args ( 'keynum' ) ? $this->get_args ( 'keynum' ) : "";
  2838. if (empty ( $keynum )) {
  2839. echo json_encode ( array (
  2840. "success" => false
  2841. ) );
  2842. die ();
  2843. }
  2844. $ky = $longle->getLongleBykeynum ( $keynum );
  2845. if (! empty ( $ky )) {
  2846. $t = $longle_log->getLongleByLid ( $ky [0] ['lid'] );
  2847. if (isset ( $t [0] ))
  2848. $tk = $t [0];
  2849. else
  2850. $tk = array ();
  2851. $longleLog = $tk;
  2852. $longleLog ['klid'] = $ky [0] ['lid'];
  2853. $longleLog ['longle'] = $ky [0];
  2854. $longleLog ['longleLogHtml'] = $this->_getLongleLogHtml ( $t );
  2855. echo json_encode ( $longleLog );
  2856. }
  2857. }
  2858. function ajaxGetLongle() {
  2859. Doo::loadModel ( 'longle_log' );
  2860. Doo::loadModel ( 'longle' );
  2861. $longle = new longle ();
  2862. $longle_log = new longle_log ();
  2863. $lid = $this->get_args ( 'lid' ) ? $this->get_args ( 'lid' ) : 0;
  2864. if ($lid == 0) {
  2865. echo json_encode ( array (
  2866. "success" => false
  2867. ) );
  2868. die ();
  2869. }
  2870. $t = $longle_log->getLongleByLid ( $lid );
  2871. if (isset ( $t [0] ))
  2872. $tk = $t [0];
  2873. else
  2874. $tk = array ();
  2875. $longleLog = $tk;
  2876. $longleLog ['klid'] = $lid;
  2877. $ky = $longle->getLongleByLid ( $lid );
  2878. $longleLog ['longle'] = $ky [0];
  2879. $longleLog ['longleLogHtml'] = $this->_getLongleLogHtml ( $t );
  2880. echo json_encode ( $longleLog );
  2881. }
  2882. function ajaxGetStaffInfo() {
  2883. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  2884. if ($username == "") {
  2885. echo json_encode ( array (
  2886. "success" => false
  2887. ) );
  2888. die ();
  2889. }
  2890. Doo::loadModel ( 'staff' );
  2891. $staff = new staff ();
  2892. $staffInfo = $staff->getOne ( array (
  2893. 'where' => ' username like "' . $username . '"',
  2894. 'asArray' => TRUE
  2895. ) );
  2896. if (empty ( $staffInfo )) {
  2897. echo json_encode ( array (
  2898. "success" => false,
  2899. 'html' => ''
  2900. ) );
  2901. die ();
  2902. }
  2903. $staffHtml = array (
  2904. 'html' => '<div class="contactPanel"><h1>' . $staffInfo ['username'] . '</h1>
  2905. <table><tbody><tr><th>性别</th><td>' . $staffInfo ['gender'] . '</td><th>办事处</th><td>' . $staffInfo ['category'] . '</td></tr>
  2906. <tr><th>手机</th><td>' . $staffInfo ['telephone'] . '</td><th>电话</th><td>' . $staffInfo ['phone'] . '</td></tr>
  2907. <tr><th>QQ</th><td>' . $staffInfo ['qq'] . '</td><th>邮箱</th><td>' . $staffInfo ['email'] . '</td></tr>
  2908. </tbody></table>
  2909. </div>'
  2910. );
  2911. echo json_encode ( $staffHtml );
  2912. }
  2913. function ajaxGetCompanyByAdd() {
  2914. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "";
  2915. if (! empty ( $cid )) {
  2916. Doo::loadModel ( 'company' );
  2917. $company = new company ();
  2918. Doo::loadModel ( 'client' );
  2919. Doo::loadModel ( 'district' );
  2920. $district = new district ();
  2921. $client = new client ();
  2922. $districtInfo = $district->get_lv ( 1 );
  2923. $companyInfo = $client->getClientByCompanyId ( $cid );
  2924. $companyInfo = $companyInfo [0];
  2925. $cInfo = $company->getOne ( array (
  2926. 'where' => "cid = " . $cid,
  2927. 'asArray' => TRUE
  2928. ) );
  2929. $companyInfo ['ride'] = $cInfo ['ride'];
  2930. $companyInfo ['landmarks'] = $cInfo ['landmarks'];
  2931. $companyInfo ['stay'] = $cInfo ['stay'];
  2932. $artld = explode ( ',', $cInfo ['local'] );
  2933. $districtid = explode ( ',', $cInfo ['district'] );
  2934. $html = "";
  2935. $html .= '<select name="lv21" id="lv31" onchange="dislv(\'lv31\',\'32\');"><option value="' . $districtid [0] . '">' . $artld [0] . '</option>';
  2936. // foreach ($districtInfo as $key=>$value){
  2937. //
  2938. // $html.='<option selected value="'.$value['id'].'">'.$value['name'].'</option>';
  2939. // }
  2940. $html .= '</select>&nbsp;';
  2941. $html .= '<span id="mlv32">
  2942. <select id="lv32" name="lv22">
  2943. <option selected value="' . $districtid [1] . '" >' . $artld [1] . '</option>
  2944. </select>
  2945. </span>';
  2946. $html .= '<span id="mlv33">
  2947. <select id="lv33" name="lv23">
  2948. <option selected value="' . $districtid [2] . '" >' . $artld [2] . '</option>
  2949. </select>&nbsp;
  2950. </span>';
  2951. $companyInfo ['dishtml'] = $html;
  2952. $companyInfo ['natureAr'] = $this->nature;
  2953. $companyInfo ['natureArlenght'] = 12;
  2954. echo json_encode ( array (
  2955. "success" => true,
  2956. 'data' => $companyInfo
  2957. ) );
  2958. die ();
  2959. } else
  2960. echo json_encode ( array (
  2961. "success" => false,
  2962. 'data' => ''
  2963. ) );
  2964. die ();
  2965. }
  2966. function doEditCompanyD() {
  2967. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2968. $companyname = $this->get_args ( 'companyname' ) ? $this->get_args ( 'companyname' ) : "";
  2969. $lv21 = $this->get_args ( 'lv21' ) ? $this->get_args ( 'lv21' ) : 0;
  2970. $lv22 = $this->get_args ( 'lv22' ) ? $this->get_args ( 'lv22' ) : 0;
  2971. $lv23 = $this->get_args ( 'lv23' ) ? $this->get_args ( 'lv23' ) : 0;
  2972. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  2973. $fax = $this->get_args ( 'fax' ) ? $this->get_args ( 'fax' ) : "";
  2974. $webservice = $this->get_args ( 'webservice' ) ? $this->get_args ( 'webservice' ) : "";
  2975. $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
  2976. $ride = $this->get_args ( 'ride' ) ? $this->get_args ( 'ride' ) : "";
  2977. $stay = $this->get_args ( 'stay' ) ? $this->get_args ( 'stay' ) : "";
  2978. $landmarks = $this->get_args ( 'landmarks' ) ? $this->get_args ( 'landmarks' ) : "";
  2979. if (empty ( $cid ) || empty ( $companyname )) {
  2980. echo json_encode ( array (
  2981. "success" => false
  2982. ) );
  2983. die ();
  2984. }
  2985. Doo::loadModel ( "company" );
  2986. Doo::loadModel ( "client" );
  2987. $client = new client ();
  2988. $company = new company ();
  2989. $company->cid = $cid;
  2990. if (! empty ( $lv21 ) && ! empty ( $lv22 ) && ! empty ( $lv23 )) {
  2991. Doo::loadModel ( 'district' );
  2992. $district = new district ();
  2993. // 更新公司信息
  2994. $lv1 = $district->getbyid ( $lv21 );
  2995. $lv2 = $district->getbyid ( $lv22 );
  2996. $lv3 = $district->getbyid ( $lv23 );
  2997. $company->district = $lv21 . "," . $lv22 . "," . $lv23;
  2998. $company->local = $lv1 [0] ['name'] . "," . $lv2 [0] ['name'] . "," . $lv3 [0] ['name'];
  2999. }
  3000. if (! empty ( $nature )) {
  3001. $nature = implode ( ",", $nature );
  3002. $company->nature = $nature;
  3003. }
  3004. if (! empty ( $companyname )) {
  3005. $company->companyname = $companyname;
  3006. $client->companyname = $companyname;
  3007. }
  3008. if (! empty ( $fax ))
  3009. $company->fax = $fax;
  3010. if (! empty ( $webservice ))
  3011. $company->webservice = $webservice;
  3012. $company->address = $address;
  3013. $company->ride = $ride;
  3014. $company->stay = $stay;
  3015. $company->landmarks = $landmarks;
  3016. $company->update ();
  3017. $client->update ( array (
  3018. 'where' => ' companyid =' . $cid
  3019. ) );
  3020. echo json_encode ( array (
  3021. "success" => true
  3022. ) );
  3023. die ();
  3024. }
  3025. function ajaxEditCompany() {
  3026. $companyname = $this->get_args ( 'companyId' ) ? $this->get_args ( 'companyId' ) : 0;
  3027. if (! empty ( $companyname )) {
  3028. Doo::loadModel ( 'company' );
  3029. $company = new company ();
  3030. $companyInfo = $company->getOne ( array (
  3031. 'where' => "cid = '" . $companyname . "'",
  3032. 'asArray' => TRUE
  3033. ) );
  3034. if (! empty ( $companyInfo )) {
  3035. Doo::loadModel ( 'district' );
  3036. $district = new district ();
  3037. $districtinfo = $district->get_lv ( 1 );
  3038. $dinfo = $district->getbyidlist ( $companyInfo ['district'] );
  3039. $html = '
  3040. <div class="contactInfo clearfix">
  3041. <div class="header">
  3042. <h1 class="companyName">' . $companyInfo ['companyname'] . '</h1>
  3043. </div>
  3044. </div>
  3045. <div class="lockRecord">
  3046. <div class="contactPanel">
  3047. <table>
  3048. <tbody><tr><th>单位全称</th><td colspan="3"><input type="text" name="companyname" id="companyname" value="' . $companyInfo ['companyname'] . '"></td></tr>
  3049. <tr><th>地区</th><td colspan="3">
  3050. <select name="lv21" id="lv21" onchange="dislv(\'lv21\',22);">
  3051. <option value="0">请选择</option>';
  3052. foreach ( $districtinfo as $key => $value ) {
  3053. if ($value ['id'] == $dinfo [0] ['id'])
  3054. $html .= '<option selected value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  3055. else
  3056. $html .= '<option value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  3057. }
  3058. $html .= '</select>
  3059. <span id="mlv22">
  3060. <select id="lv22">
  3061. <option value="' . $dinfo [1] ['id'] . '">' . $dinfo [1] ['name'] . '</option>
  3062. </select>
  3063. </span>
  3064. <span id="mlv23">
  3065. <select id="lv23">
  3066. <option value="' . $dinfo [2] ['id'] . '">' . $dinfo [2] ['name'] . '</option>
  3067. </select>&nbsp;
  3068. </span>
  3069. </td></tr>
  3070. ';
  3071. $html .= '<tr><th>性质</th><td colspan="3">';
  3072. $ntre = explode ( ",", $companyInfo ['nature'] );
  3073. foreach ( $this->nature as $key => $value ) {
  3074. $falg = true;
  3075. foreach ( $ntre as $k => $v ) {
  3076. if ($value == $v) {
  3077. $falg = false;
  3078. $html .= '<label><input type="checkbox" checked name="nature[]" value="' . $value . '">' . $value . '</label>&nbsp;';
  3079. }
  3080. }
  3081. if ($falg)
  3082. $html .= '<label><input type="checkbox" name="nature[]" value="' . $value . '">' . $value . '</label>&nbsp;';
  3083. }
  3084. $html .= ' </td></tr>
  3085. <tr><th>传真</th><td><input type="text" name="fax" id="fax" value="' . $companyInfo ['fax'] . '"> </td><th>主页</th><td><input type="text" name="webservice" id="webservice" value="' . $companyInfo ['webservice'] . '"> </td></tr>
  3086. <tr><th>单位地址</th><td colspan="3"><input type="text" name="address" id="address" value="' . $companyInfo ['address'] . '"> </td></tr>
  3087. <tr><th>乘车路线</th><td colspan="3"><input type="text" name="ride" id="ride" value="' . $companyInfo ['ride'] . '"> </td></tr>
  3088. <tr><th>地标建筑</th><td colspan="3"><input type="text" name="landmarks" id="landmarks" value="' . $companyInfo ['landmarks'] . '"> </td></tr>
  3089. <tr><th>住宿参考</th><td colspan="3"><input type="text" name="stay" id="stay" value="' . $companyInfo ['stay'] . '"> </td></tr>
  3090. <tr><td colspan="4"><input type="hidden" name="cid" id="cid" value="' . $companyInfo ['cid'] . '"><input type="button" onclick="doCompanyEdit()" class="button" value="确定"><span id="editCompanyD"></span></td></tr>
  3091. </tbody></table>
  3092. <div class="bsAlert bsInfo">单位全称将与该单位已存在的客户进行同步;其他单位信息不会进行同步;<br>单位信息随该单位第一位客户录入,并作为“在这添加客户”的基础数据</div>
  3093. </div>
  3094. </div>
  3095. ';
  3096. echo json_encode ( array (
  3097. "success" => true,
  3098. 'html' => $html
  3099. ) );
  3100. die ();
  3101. }
  3102. } else
  3103. echo json_encode ( array (
  3104. "success" => false,
  3105. 'html' => ''
  3106. ) );
  3107. die ();
  3108. }
  3109. function ajaxGetCompany() {
  3110. $companyname = $this->get_args ( 'companyId' ) ? $this->get_args ( 'companyId' ) : 0;
  3111. if (! empty ( $companyname )) {
  3112. Doo::loadModel ( 'company' );
  3113. $company = new company ();
  3114. $companyInfo = $company->getOne ( array (
  3115. 'where' => "cid = '" . $companyname . "'",
  3116. 'asArray' => TRUE
  3117. ) );
  3118. if (! empty ( $companyInfo )) {
  3119. Doo::loadModel ( 'client' );
  3120. Doo::loadModel ( 'staff' );
  3121. Doo::loadModel ( 'client_staff' );
  3122. Doo::loadModel ( 'longle' );
  3123. $longle = new longle ();
  3124. $client_staff = new client_staff ();
  3125. $staff = new staff ();
  3126. $client = new client ();
  3127. Doo::loadModel ( 'district' );
  3128. $district = new district ();
  3129. $clientlist = $client->getClientByCompanyId ( $companyInfo ['cid'] );
  3130. $department = $client->getDepartment ( $companyInfo ['cid'] );
  3131. Doo::loadModel ( "tagCompanyNexus" );
  3132. Doo::loadModel ( "tagCompany" );
  3133. $tag = new tagCompany ();
  3134. $tag_client = new tagCompanyNexus ();
  3135. $tagId = $tag_client->getTagClientBySCid ( $companyInfo ['cid'], $this->staff [0] ['sid'] );
  3136. $taginfo = $tag->getTagByTidL ( $tagId ['tag'] );
  3137. $taghtml = "";
  3138. foreach ( $taginfo as $key => $value ) {
  3139. $taghtml .= '<span class="contactsTag tagCol-0' . $value ['colorid'] . '">' . $value ['name'] . '</span>';
  3140. }
  3141. $html = '<div class="header">
  3142. <h1 class="companyName"><div class="fR">
  3143. <a class="icon- add" node-syn="show" href="javascript:void(0)" title="同步地址信息">S</a>
  3144. <a href="javascript:void(0)" title="编辑单位" class="icon- edit" onclick="editByCompany(' . $companyInfo ['cid'] . ')" >I</a> | <a title="在这个单位下添加客户" href="javascript:void(0)" class="icon- add" onclick="addClientByCompany(' . $companyInfo ['cid'] . ')" >H</a></div>' . $companyInfo ['companyname'] . '</h1>
  3145. <div class="contactPanel">
  3146. <table>
  3147. <tbody>
  3148. <tr><th>单位地区</th><td><span>' . $companyInfo ['local'] . '</span></td><th>单位性质</th><td>' . $companyInfo ['nature'] . '</td></tr>
  3149. <tr><th>单位地址</th><td colspan="3">' . $companyInfo ['address'] . '</td></tr>
  3150. <tr><th>单位乘车</th><td colspan="3">' . $companyInfo ['ride'] . '</td></tr>
  3151. <tr><th>单位地标</th><td colspan="3">' . $companyInfo ['landmarks'] . '</td></tr>
  3152. <tr><th>单位住宿</th><td colspan="3">' . $companyInfo ['stay'] . '</td></tr>
  3153. <tr><td colspan="4">
  3154. ' . $taghtml . '
  3155. </td></tr>
  3156. <tr><td colspan="4" >
  3157. <a class="button" style="display:none" node-synadd="true" href="javascript:void(0)">确定同步</a>
  3158. <span node-synAdd="msg" class="bsAlert bsSuccess fL hide"></span>
  3159. <span class="hide" id="skop">已选择 <span id="tl">0</span>/<span id="bl">' . sizeof ( $clientlist ) . '</span></span>
  3160. </td>
  3161. </tr>
  3162. </tbody></table></div>
  3163. <h2 class="cate">';
  3164. $html .= '<a href="javascript:void(0)" onclick="departmentC()" class="now">不限</a>';
  3165. foreach ( $department as $key => $value ) {
  3166. if ($value != "")
  3167. $html .= '<a href="javascript:void(0)" onclick="departmentC(\'' . $value ['department'] . '\')">' . $value ['department'] . '</a>';
  3168. }
  3169. $html .= '</h2></div><script>$(".header .cate a").click(function(){
  3170. $(this).addClass("now").siblings("a").removeClass("now");
  3171. });
  3172. </script>';
  3173. $html .= '<div class="lockRecord autoHeightR2" >';
  3174. foreach ( $clientlist as $key => $value ) {
  3175. $scinfo = $client_staff->getClientByCid ( $value ['cid'] );
  3176. $staffinfo = $staff->getUserById ( $scinfo ['sid'] );
  3177. // 客户信息
  3178. $html .= '<div class="contactPanel" id="PART_' . $value ['department'] . '">
  3179. <h1><p class="fR">' . $staffinfo [0] ['category'] . '-<a href="javascript:void(0)" onclick="getStaffInfo(\'' . $staffinfo [0] ['username'] . '\')" >
  3180. ' . $staffinfo [0] ['username'] . '</a></p>
  3181. <input type="checkbox" name="CASYN[]" CAS-NUM="TR" class="hide" value="' . $value ['cid'] . '">
  3182. <a href="javascript:void(0)" onclick="getClientInfo(\'' . $value ['cid'] . '\')" class="clientName">' . $value ['clientname'] . ' </a>
  3183. <i class="icon- sport">' . $value ['priority'] . '</i><a class="icon- edit" title="编辑客户" href="javascript:clientEdit(' . $value ['cid'] . ')">I</a></h1><table>
  3184. <tbody><tr><th>性别</th><td>' . $value ['gender'] . '</td><th>昵称</th><td>' . $value ['nicename'] . '</td></tr>
  3185. <tr><th>部门</th><td>' . $value ['department'] . '</td><th>办公室</th><td>' . $value ['office'] . '</td></tr>
  3186. <tr><th>手机</th><td>' . $value ['telephone'] . '</td><th>电话</th><td>' . $value ['phone'] . '</td></tr>
  3187. <tr><th>QQ</th><td>' . $value ['qq'] . '</td><th>邮箱</th><td>' . $value ['email'] . '</td></tr>
  3188. <tr node-ck=fz ><th>备注</th><td >' . $value ['mark'] . '</td>
  3189. </tr>';
  3190. $longleinfo = $longle->getLongleByClientid ( $value ['cid'] );
  3191. if (empty ( $longleinfo )) {
  3192. $longleinfo = array (
  3193. 0 => array (
  3194. 'lid' => '',
  3195. 'key_num' => '',
  3196. 'product' => '',
  3197. 'statusT' => ''
  3198. )
  3199. );
  3200. }
  3201. $html .= '<tr node-ck=fz ><th>软件锁</th><td colspan="3"><a href="javascript:void(0)" onclick="getLongleLog(' . $longleinfo [0] ['lid'] . ')">' . $longleinfo [0] ['key_num'] . '</a>/' . $longleinfo [0] ['product'] . '/' . $longleinfo [0] ['statusT'] . '</td></tr>';
  3202. $districtList = $district->getbyidlist ( $value ['district'] );
  3203. $localdis = '';
  3204. foreach ( $districtList as $lov ) {
  3205. $localdis .= ' ' . $lov ['name'];
  3206. }
  3207. $html .= '
  3208. <tr node-synCom=pany style="display:none" ><th>客户地区</th><td colspan="4">' . $localdis . '</td></tr>
  3209. <tr node-synCom=pany style="display:none" ><th>客户地址</th><td colspan="4">' . $value ['address'] . '</td></tr>
  3210. <tr node-synCom=pany style="display:none" ><th>客户乘车</th><td colspan="4">' . $value ['ride'] . '</td></tr>
  3211. <tr node-synCom=pany style="display:none" ><th>客户地标</th><td colspan="4">' . $value ['landmarks'] . '</td></tr>
  3212. <tr node-synCom=pany style="display:none" ><th>客户住宿</th><td colspan="4">' . $value ['stay'] . '</td></tr>';
  3213. $html .= '</tbody></table></div>';
  3214. }
  3215. $html .= "</div><script type='text/javascript'>
  3216. $(\"a[node-syn=show]\").click(function() {
  3217. $(\"a[node-synadd='true']\").show();
  3218. $('input[CAS-NUM=TR]').show();
  3219. $('#skop').show();
  3220. $('tr[node-ck=fz]').hide();
  3221. $('tr[node-synCom=pany]').show();
  3222. });
  3223. $(\"input[CAS-NUM='TR']\").click(function() {
  3224. $('#tl').html($('input[CAS-NUM=TR]:checked').length);
  3225. });
  3226. $(\"a[node-synadd='true']\").click(function() {
  3227. var id_array=new Array();
  3228. $('input[CAS-NUM=TR]:checked').each(function(){
  3229. id_array.push($(this).val());
  3230. });
  3231. if(id_array.length==0){
  3232. alert('未选中客户');
  3233. }else{
  3234. var idstr=id_array.join(',');
  3235. var url='/ajaxSetCompanyAddress';
  3236. $.ajax({
  3237. url:url,
  3238. type: 'post',
  3239. cache: false,
  3240. dataType: 'json',
  3241. data: {
  3242. cidString:idstr,
  3243. company:" . $companyInfo ['cid'] . "
  3244. },
  3245. global: true,
  3246. success: function(data){
  3247. if(data.status>0){
  3248. $(\"span[node-synAdd=msg]\").html('同步成功');
  3249. for(var i=0;i<id_array.length;i++){
  3250. $(\"td[node-address=company_\"+id_array[i]+\"]\").html('" . $companyInfo ['address'] . "');
  3251. }
  3252. $(\"a[node-synadd='true']\").hide();
  3253. $('input[CAS-NUM=TR]').hide();
  3254. $('#skop').hide();
  3255. $(\"span[node-synAdd=msg]\").show().delay(2000).fadeOut();
  3256. }else if(data.status==-1){
  3257. $(\"span[node-synAdd=msg]\").html('操作不成功');
  3258. $(\"span[node-synAdd=msg]\").show().delay(2000).fadeOut();
  3259. }else if(data.status==0){
  3260. $(\"span[node-synAdd=msg]\").html('地址已同步过');
  3261. $(\"span[node-synAdd=msg]\").show().delay(2000).fadeOut();
  3262. }
  3263. },
  3264. error:function(err){
  3265. }
  3266. });
  3267. }
  3268. });
  3269. autoFlashHeight();
  3270. </script>";
  3271. echo json_encode ( array (
  3272. "success" => true,
  3273. 'html' => $html
  3274. ) );
  3275. die ();
  3276. }
  3277. } else
  3278. echo json_encode ( array (
  3279. "success" => false,
  3280. 'html' => ''
  3281. ) );
  3282. die ();
  3283. }
  3284. function ajaxSetCompanyAddress() {
  3285. $cidString = $this->get_args ( 'cidString' ) ? $this->get_args ( 'cidString' ) : "";
  3286. $companyId = $this->get_args ( 'company' ) && is_numeric ( $this->get_args ( 'company' ) ) ? $this->get_args ( 'company' ) : 0;
  3287. if (! empty ( $cidString ) && ! empty ( $companyId )) {
  3288. Doo::loadModel ( 'client' );
  3289. $client = new client ();
  3290. Doo::loadModel ( 'company' );
  3291. $company = new company ();
  3292. $cidList = explode ( ',', $cidString );
  3293. foreach ( $cidList as $value ) {
  3294. if (! is_numeric ( $value ))
  3295. die ( 'illegal request3' );
  3296. }
  3297. $companyInfo = $company->getOne ( array (
  3298. 'where' => "cid = '" . $companyId . "'",
  3299. 'asArray' => TRUE
  3300. ) );
  3301. $client->address = $companyInfo ['address'];
  3302. $client->ride = $companyInfo ['ride'];
  3303. $client->landmarks = $companyInfo ['landmarks'];
  3304. $client->stay = $companyInfo ['stay'];
  3305. $client->local = $companyInfo ['local'];
  3306. $client->district = $companyInfo ['district'];
  3307. $falg = $client->update ( array (
  3308. 'where' => 'companyid =' . $companyInfo ['cid'] . ' and cid in (' . $cidString . ')'
  3309. ) );
  3310. echo json_encode ( array (
  3311. 'status' => $falg,
  3312. 'msg' => 'illegal request2'
  3313. ) );
  3314. die ();
  3315. }
  3316. echo json_encode ( array (
  3317. 'status' => - 1,
  3318. 'msg' => 'illegal request'
  3319. ) );
  3320. die ();
  3321. }
  3322. function checkclicomname() { // 地区区分
  3323. $companyname = $this->get_args ( 'companyname' ) ? $this->get_args ( 'companyname' ) : "";
  3324. $clientname = $this->get_args ( 'clientname' ) ? $this->get_args ( 'clientname' ) : "";
  3325. $district1 = $this->get_args ( 'district1' ) ? $this->get_args ( 'district1' ) : 0;
  3326. $district2 = $this->get_args ( 'district2' ) ? $this->get_args ( 'district2' ) : 0;
  3327. $district3 = $this->get_args ( 'district3' ) ? $this->get_args ( 'district3' ) : 0;
  3328. Doo::loadModel ( 'client' );
  3329. $client = new client ();
  3330. $local = $district1 . "," . $district2 . "," . $district3;
  3331. $companyname = trim ( $companyname );
  3332. $clientname = trim ( $clientname );
  3333. $clientinfo = $client->getClientToName ( $clientname, $companyname, $local );
  3334. if (! empty ( $clientinfo )) {
  3335. echo json_encode ( array (
  3336. 'success' => false
  3337. ) );
  3338. } else {
  3339. echo json_encode ( array (
  3340. 'success' => true
  3341. ) );
  3342. }
  3343. }
  3344. function ajaxGetClientInfoN() {
  3345. $clientname = $this->get_args ( 'client' ) ? $this->get_args ( 'client' ) : "";
  3346. if ($clientname == "") {
  3347. echo json_encode ( array (
  3348. "success" => false
  3349. ) );
  3350. die ();
  3351. }
  3352. Doo::loadModel ( 'client' );
  3353. Doo::loadModel ( 'client_staff' );
  3354. Doo::loadModel ( 'longle' );
  3355. Doo::loadModel ( 'company' );
  3356. Doo::loadModel ( 'service_log' );
  3357. $service_log = new service_log ();
  3358. $company = new company ();
  3359. $longle = new longle ();
  3360. $client = new client ();
  3361. $client_staff = new client_staff ();
  3362. $clientInfo = $client->getOne ( array (
  3363. "where" => ' cid like "' . $clientname . '"',
  3364. 'asArray' => TRUE
  3365. ) );
  3366. if (empty ( $clientInfo )) {
  3367. echo json_encode ( array (
  3368. "success" => false,
  3369. 'html' => ''
  3370. ) );
  3371. die ();
  3372. }
  3373. // 获取锁
  3374. $longleInfo = $longle->getLongleByClient ( $clientname );
  3375. $k = "";
  3376. foreach ( $longleInfo as $key => $value ) {
  3377. if ($value ['status'] == 6 || $value ['status'] == 7)
  3378. $k .= '<a href="javascript:void(0)" class="disenable" onclick="getLock(' . $value ['lid'] . ')" >' . $value ['key_num'] . '/' . $value ['product'] . '/' . $value ['statusT'] . '</a>&nbsp; ';
  3379. else
  3380. $k .= '<a href="javascript:void(0)" onclick="getLock(' . $value ['lid'] . ')" >' . $value ['key_num'] . '/' . $value ['product'] . '/' . $value ['statusT'] . '</a>&nbsp; ';
  3381. }
  3382. // 获取办事人
  3383. $staffInfo = $client_staff->getClientByCid ( $clientInfo ['cid'] );
  3384. // 获取公司信息
  3385. $companyInfo = $company->getCompanyByCid ( $clientInfo ['companyid'] );
  3386. $serviceLog = $service_log->getServiceByClientid ( $clientInfo ['cid'] );
  3387. $u = "";
  3388. $order = array (
  3389. "\r\n",
  3390. "\n",
  3391. "\r"
  3392. );
  3393. $replace = '</br>';
  3394. foreach ( $serviceLog as $key => $value ) {
  3395. $datetime = explode ( "-", $value ['date'] );
  3396. $u .= '<div class="infoFlowList">
  3397. <div class="dateTitle">
  3398. <em class="month"><span class="num">' . $datetime ['1'] . '</span><span class="text">-' . $datetime ['2'] . '</span></em>
  3399. <span class="year">' . $datetime ['0'] . '</span>
  3400. </div>
  3401. <ul class="flowList">';
  3402. if ($value ['status'] == 1)
  3403. $u .= '<li class="item iconService">上门服务</li>';
  3404. elseif ($value ['status'] == 2)
  3405. $u .= '<li class="item iconPhone">电话拜访</li>';
  3406. elseif ($value ['status'] == 3)
  3407. $u .= '<li class="item iconOther">其他</li>';
  3408. $u .= '
  3409. <li class="item">' . $value ['category'] . '<a href="javascript:void(0)" onclick="getStaffInfo(\'' . $value ['staffname'] . '\')" >' . $value ['staffname'] . '</a></li>
  3410. <li class="item">
  3411. ' . str_replace ( $order, $replace, $value ['mark'] ) . '
  3412. </li>
  3413. </ul>
  3414. </div>';
  3415. }
  3416. Doo::loadModel ( "tag_client" );
  3417. Doo::loadModel ( "tag" );
  3418. $tag = new tag ();
  3419. $tag_client = new tag_client ();
  3420. $tagId = $tag_client->getTagClientBySCid ( $clientInfo ['cid'], $this->staff [0] ['sid'] );
  3421. $taginfo = $tag->getTagByTidL ( $tagId ['tag'] );
  3422. // $taghtml="";
  3423. //
  3424. // foreach ($taginfo as $key=>$value){
  3425. // $taghtml.='<span class="contactsTag tagCol-0'.$value['colorid'].'">'.$value['name'].'</span>';
  3426. // }
  3427. $mhtml = "";
  3428. $dhtml = "";
  3429. for($month = 1; $month <= 12; $month ++) {
  3430. if (date ( "m" ) == $month)
  3431. $mhtml .= '<option selected value="' . $month . '">' . $month . '月</option>';
  3432. else
  3433. $mhtml .= '<option value="' . $month . '">' . $month . '月</option>';
  3434. }
  3435. for($day = 1; $day <= 31; $day ++) {
  3436. if (date ( "d" ) == $day)
  3437. $dhtml .= '<option selected value="' . $day . '">' . $day . '日</option>';
  3438. else
  3439. $dhtml .= '<option value="' . $day . '">' . $day . '日</option>';
  3440. }
  3441. // $b="";
  3442. // if(!empty($staffInfo))
  3443. // $b='<p class="fR">'.$staffInfo['category'].'-<a href="javascript:void(0)" onclick="getStaffInfo(\''.$staffInfo['username'].'\')" >'.$staffInfo['username'].'</a></p>'.$clientInfo['clientname'].' ';
  3444. //
  3445. $m = "";
  3446. if (! empty ( $companyInfo )) {
  3447. $m = '
  3448. <table width="100%">
  3449. <tbody>
  3450. <tr><th>单位全称</th><td colspan="3"><a href="javascript:void(0)" >' . $companyInfo [0] ['companyname'] . '</a></td></tr>
  3451. <tr><th>地区</th><td>' . $companyInfo [0] ['local'] . '</td><th>部门/职位</th><td>' . $clientInfo ['department'] . '/' . $clientInfo ['position'] . '</td></tr>
  3452. <tr><th>传真</th><td>' . $companyInfo [0] ['fax'] . '</td><th>办公室</th><td>' . $companyInfo [0] ['office'] . '</td></tr>
  3453. <tr><th>单位地址</th><td colspan="3">' . $companyInfo [0] ['address'] . '</td></tr>
  3454. <tr><th>乘车路线</th><td colspan="3">' . $companyInfo [0] ['ride'] . '</td></tr>
  3455. <tr><th>地标建筑</th><td colspan="3">' . $companyInfo [0] ['landmarks'] . '</td></tr>
  3456. <tr><th>参考住宿</th><td colspan="3">' . $clientInfo ['stay'] . '</td></tr>
  3457. <tr><th>单位主页</th><td colspan="3">' . $clientInfo ['webservice'] . '</td></tr>
  3458. </tbody></table>
  3459. ';
  3460. }
  3461. $clientHtml = array (
  3462. 'html' => '
  3463. <div class="modal-dialog ">
  3464. <div class="modal-content">
  3465. <div class="modal-header">
  3466. <h3><span class="fR"><a>' . $staffInfo ['category'] . ' ' . $staffInfo ['username'] . '</a></span>' . $clientInfo ['clientname'] . '</h3>
  3467. </div>
  3468. <div class="modal-body">
  3469. <div class="modalClientTable">
  3470. <table width="100%">
  3471. <tbody><tr><th>性别</th><td>' . $clientInfo ['gender'] . '</td><th>昵称</th><td>' . $clientInfo ['nicename'] . '</td></tr>
  3472. <tr><th>手机</th><td>' . $clientInfo ['telephone'] . '</td><th>QQ</th><td>' . $clientInfo ['qq'] . '</td></tr>
  3473. <tr><th>电话</th><td>' . $clientInfo ['phone'] . '</td><th>邮箱</th><td>' . $clientInfo ['email'] . '</td></tr>
  3474. <tr><th>软件锁</th><td colspan="3">' . $k . '</td></tr>
  3475. <tr><td colspan="4">
  3476. </td></tr>
  3477. </tbody>
  3478. </table>
  3479. ' . $m . '
  3480. <div class="clearfix">
  3481. ' . $u . '
  3482. </div>
  3483. </div>
  3484. </div>
  3485. <div class="modal-footer">
  3486. <a href="javascript:void(0)" onclick="closeClick()" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a>
  3487. </div>
  3488. </div></div>
  3489. '
  3490. );
  3491. echo json_encode ( $clientHtml );
  3492. }
  3493. function ajaxGetClientInfo() {
  3494. $clientname = $this->get_args ( 'client' ) ? $this->get_args ( 'client' ) : "";
  3495. if ($clientname == "") {
  3496. echo json_encode ( array (
  3497. "success" => false
  3498. ) );
  3499. die ();
  3500. }
  3501. Doo::loadModel ( 'client' );
  3502. Doo::loadModel ( 'client_staff' );
  3503. Doo::loadModel ( 'longle' );
  3504. Doo::loadModel ( 'company' );
  3505. Doo::loadModel ( 'service_log' );
  3506. Doo::loadModel ( "district" );
  3507. $district = new district ();
  3508. $service_log = new service_log ();
  3509. $company = new company ();
  3510. $longle = new longle ();
  3511. $client = new client ();
  3512. $client_staff = new client_staff ();
  3513. $nameStr = explode ( ",", $clientname );
  3514. // $clientname=$nameStr[1];
  3515. if (! empty ( $nameStr [0] )) {
  3516. $clientInfo = $client->getOne ( array (
  3517. "where" => ' cid = "' . $nameStr [0] . '"',
  3518. 'asArray' => TRUE
  3519. ) );
  3520. } elseif (! empty ( $nameStr [1] ))
  3521. $clientInfo = $client->getOne ( array (
  3522. "where" => ' clientname = "' . $nameStr [1] . '"',
  3523. 'asArray' => TRUE
  3524. ) );
  3525. else
  3526. $clientInfo = array ();
  3527. if (empty ( $clientInfo )) {
  3528. echo json_encode ( array (
  3529. "success" => false,
  3530. 'html' => ''
  3531. ) );
  3532. die ();
  3533. }
  3534. // 获取锁
  3535. $longleInfo = $longle->getLongleByClientid ( $clientInfo ['cid'] );
  3536. $k = "";
  3537. foreach ( $longleInfo as $key => $value ) {
  3538. if ($value ['status'] == 6 || $value ['status'] == 7)
  3539. $k .= '<a href="javascript:void(0)" class="disenable" onclick="getLock(' . $value ['lid'] . ')" >' . $value ['key_num'] . '/' . $value ['product'] . '/' . $value ['statusT'] . '</a>&nbsp; ';
  3540. else
  3541. $k .= '<a href="javascript:void(0)" onclick="getLock(' . $value ['lid'] . ')" >' . $value ['key_num'] . '/' . $value ['product'] . '/' . $value ['statusT'] . '</a>&nbsp; ';
  3542. }
  3543. // 获取办事人
  3544. $staffInfo = $client_staff->getClientByCid ( $clientInfo ['cid'] );
  3545. $b = "";
  3546. if (! empty ( $staffInfo ))
  3547. $b = '<p class="fR">' . $staffInfo ['category'] . '-<a href="javascript:void(0)" onclick="getStaffInfo(\'' . $staffInfo ['username'] . '\')" >' . $staffInfo ['username'] . '</a></p>' . $clientInfo ['clientname'] . '<i class="icon- sport">' . $clientInfo ['priority'] . '</i>';
  3548. // 获取公司信息
  3549. $companyInfo = $company->getCompanyByCid ( $clientInfo ['companyid'] );
  3550. $serviceLog = $service_log->getServiceByClientid ( $clientInfo ['cid'] );
  3551. $local = $district->getbyidlist ( $clientInfo ['district'] );
  3552. if (! isset ( $local [1] ))
  3553. $local [1] ['name'] = "";
  3554. if (! isset ( $local [2] ))
  3555. $local [2] ['name'] = "";
  3556. $m = "";
  3557. if (! empty ( $companyInfo )) {
  3558. $m = '<div class="contactPanel">
  3559. <table>
  3560. <tbody>
  3561. <tr><th>单位全称</th><td colspan="3"><a href="javascript:void(0)" onclick="getCompany(\'' . $companyInfo [0] ['cid'] . '\')">' . $companyInfo [0] ['companyname'] . '</a></td></tr>
  3562. <tr><th>单位主页</th><td colspan="3">' . $clientInfo ['webservice'] . '</td></tr>
  3563. <tr><th>客户地区</th><td>' . $local [0] ['name'] . ',' . $local [1] ['name'] . ',' . $local [2] ['name'] . '</td><th>部门/职位</th><td>' . $clientInfo ['department'] . '/' . $clientInfo ['position'] . '</td></tr>
  3564. <tr><th>客户传真</th><td>' . $clientInfo ['fax'] . '</td><th>办公室</th><td>' . $clientInfo ['office'] . '</td></tr>
  3565. <tr><th>客户地址</th><td colspan="3">' . $clientInfo ['address'] . '</td></tr>
  3566. <tr><th>客户乘车</th><td colspan="3">' . $clientInfo ['ride'] . '</td></tr>
  3567. <tr><th>客户地标</th><td colspan="3">' . $clientInfo ['landmarks'] . '</td></tr>
  3568. <tr><th>客户住宿</th><td colspan="3">' . $clientInfo ['stay'] . '</td></tr>
  3569. </tbody></table>
  3570. </div>';
  3571. }
  3572. $u = "";
  3573. $order = array (
  3574. "\r\n",
  3575. "\n",
  3576. "\r"
  3577. );
  3578. $replace = '</br>';
  3579. foreach ( $serviceLog as $key => $value ) {
  3580. $datetime = explode ( "-", $value ['date'] );
  3581. $u .= '<div class="infoFlowList">
  3582. <div class="dateTitle">
  3583. <em class="month"><span class="num">' . $datetime ['1'] . '</span><span class="text">-' . $datetime ['2'] . '</span></em>
  3584. <span class="year">' . $datetime ['0'] . '</span>
  3585. </div>
  3586. <ul class="flowList">';
  3587. if ($value ['status'] == 1)
  3588. $u .= '<li class="item iconService">上门服务<';
  3589. elseif ($value ['status'] == 2)
  3590. $u .= '<li class="item iconPhone">电话拜访<';
  3591. elseif ($value ['status'] == 3)
  3592. $u .= '<li class="item iconOther">其他<';
  3593. $u .= $value ['category'] . '<a href="javascript:void(0)" onclick="getStaffInfo(\'' . $value ['staffname'] . '\')" >' . $value ['staffname'] . '</a></li>
  3594. <li class="item">
  3595. ' . str_replace ( $order, $replace, $value ['mark'] ) . '
  3596. </li>
  3597. </ul>
  3598. </div>';
  3599. }
  3600. Doo::loadModel ( "tag_client" );
  3601. Doo::loadModel ( "tag" );
  3602. $tag = new tag ();
  3603. $tag_client = new tag_client ();
  3604. $tagId = $tag_client->getTagClientBySCid ( $clientInfo ['cid'], $this->staff [0] ['sid'] );
  3605. $taginfo = $tag->getTagByTidL ( $tagId ['tag'] );
  3606. $taghtml = "";
  3607. foreach ( $taginfo as $key => $value ) {
  3608. $taghtml .= '<span class="contactsTag tagCol-0' . $value ['colorid'] . '">' . $value ['name'] . '</span>';
  3609. }
  3610. $mhtml = "";
  3611. $dhtml = "";
  3612. $yhtml = "";
  3613. for($year = 2020; $year >= 2004; $year --) {
  3614. if (date ( "Y" ) == $year)
  3615. $yhtml .= '<option selected value="' . $year . '">' . $year . '年</option>';
  3616. else
  3617. $yhtml .= '<option value="' . $year . '">' . $year . '年</option>';
  3618. }
  3619. for($month = 1; $month <= 12; $month ++) {
  3620. if (date ( "m" ) == $month)
  3621. $mhtml .= '<option selected value="' . $month . '">' . $month . '月</option>';
  3622. else
  3623. $mhtml .= '<option value="' . $month . '">' . $month . '月</option>';
  3624. }
  3625. for($day = 1; $day <= 31; $day ++) {
  3626. if (date ( "d" ) == $day)
  3627. $dhtml .= '<option selected value="' . $day . '">' . $day . '日</option>';
  3628. else
  3629. $dhtml .= '<option value="' . $day . '">' . $day . '日</option>';
  3630. }
  3631. $clientHtml = array (
  3632. 'html' => '<div class="contactInfo clearfix">
  3633. <div class="contactPanel">
  3634. <h1>' . $b . '<a data-original-title="编辑客户" data-toggle="ctooltip" data-placement="right" href="javascript:clientEdit(' . $clientInfo ['cid'] . ')" class="icon- edit">I</a></h1>
  3635. <table>
  3636. <tbody><tr><th>性别</th><td>' . $clientInfo ['gender'] . '</td><th>昵称</th><td>' . $clientInfo ['nicename'] . '</td></tr>
  3637. <tr><th>手机</th><td>' . $clientInfo ['telephone'] . '</td><th>QQ</th><td>' . $clientInfo ['qq'] . '</td></tr>
  3638. <tr><th>电话</th><td>' . $clientInfo ['phone'] . '</td><th>邮箱</th><td>' . $clientInfo ['email'] . '</td></tr>
  3639. <tr><th>软件锁</th><td colspan="3">' . $k . '</td></tr>
  3640. <tr><th>备注</th><td colspan="3">' . $clientInfo ['mark'] . '</td></tr>
  3641. <tr><td colspan="4">
  3642. ' . $taghtml . '
  3643. </td></tr>
  3644. </tbody></table>
  3645. </div>
  3646. ' . $m . '
  3647. </div>
  3648. <div class="lockRecord autoHeightR1" >
  3649. <!--添加记录按钮-->
  3650. <div class="addRecord addRecordButton clearfix" >
  3651. <a href="#" onclick="slideupInfo(this)">+ 打开添加服务记录</a>
  3652. </div>
  3653. <!--添加记录-->
  3654. <div class="addRecord addRecordForm clearfix hide">
  3655. <a onclick="slidedownInfo(this)" class="fR slidedownInfo">- 关闭添加记录</a>
  3656. <form name="lk" action="/addServiceLog" method="post" >
  3657. <div class="control-group">
  3658. <div class="controls">
  3659. <label class="radio inline">
  3660. <input type="radio" name="logstatus" id="status" checked value="2">电话拜访
  3661. </label>
  3662. <label class="radio inline">
  3663. <input type="radio" name="logstatus" id="status" value="1" >上门服务
  3664. </label>
  3665. <label class="radio inline">
  3666. <input type="radio" name="logstatus" id="status" value="3">其他
  3667. </label>
  3668. </div>
  3669. </div>
  3670. <div class="control-group">
  3671. <div class="controls">时间:
  3672. <select name="y" id="y">
  3673. ' . $yhtml . '
  3674. </select>
  3675. <select name="m" id="m">
  3676. ' . $mhtml . '
  3677. </select>
  3678. <select name="d" id="d">
  3679. ' . $dhtml . '
  3680. </select>
  3681. </div>
  3682. </div>
  3683. <link href="' . WEB_SITE_GLOBAL . 'css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
  3684. <!--添加记录-备注-->
  3685. <!--<div class="control-group">
  3686. <div class="controls">
  3687. <select name="date" id="date">
  3688. <option value="2013">2013</option>
  3689. </select>
  3690. </div>
  3691. </div>-->
  3692. <div class="control-group">
  3693. <div class="controls" onclick="slideupInfo()">
  3694. <textarea name="mark" id="mark" style="width:95%" rows="5"></textarea>
  3695. <div class="bsAlert bsWarning"><b>含泪告知:</b>客户记录暂时无法修改!删除!,添加时请谨慎。点击确定添加成功后,信息会立即出现在下方!注意咯,别猛戳‘确定添加’导致重复添加了哦~</div>
  3696. </div>
  3697. </div>
  3698. <div class="control-group">
  3699. <div class="controls">
  3700. <div style="display:inline-block;margin-right:10px"><label><input name="Remind" onclick="reFK()" type="checkbox" value="1"> 添加提醒</label></div>
  3701. <span id="reHL" class="hide">
  3702. <div>
  3703. 限期:
  3704. <input type="date" name="time" id="dtp_input2" value="" class="hide"/>
  3705. </div>
  3706. <div>
  3707. 备注:<input id="remark" name="remark" type="text"></span>
  3708. </div>
  3709. </div>
  3710. <div class="control-group">
  3711. <div class="controls clearfix">
  3712. <input type="button" value="确定添加" id="conSer" onclick="aServiceLog(\'' . $this->staff [0] ['category'] . '\',\'' . $this->staff [0] ['username'] . '\',' . $clientInfo ['cid'] . ')" class="button"></input>
  3713. <div id="load"></div>
  3714. </div>
  3715. </div>
  3716. </div>
  3717. </form>
  3718. </div>
  3719. <!--添加记录按钮-->
  3720. <!--记录列表-->
  3721. <div id="kl"></div>
  3722. ' . $u . '
  3723. <script type="text/javascript">autoFlashHeight();</script> </div>'
  3724. );
  3725. echo json_encode ( $clientHtml );
  3726. }
  3727. function ajaxGetCompanyInfo() {
  3728. }
  3729. function checkClient() {
  3730. $searchDbInforItem = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : "";
  3731. $searchDbInforItem = explode ( '-', $searchDbInforItem );
  3732. if (! empty ( $searchDbInforItem )) {
  3733. Doo::loadModel ( 'client' );
  3734. $client = new client ();
  3735. $clientInfo = $client->getClientByName2 ( $searchDbInforItem [0], $searchDbInforItem [1] );
  3736. if (! empty ( $clientInfo ))
  3737. echo json_encode ( array (
  3738. "success" => true
  3739. ) );
  3740. else
  3741. echo json_encode ( array (
  3742. "success" => false
  3743. ) );
  3744. } else {
  3745. echo json_encode ( array (
  3746. "success" => false
  3747. ) );
  3748. }
  3749. }
  3750. function searchClient() {
  3751. $searchDbInforItem = $this->get_args ( 'searchDbInforItem' ) ? $this->get_args ( 'searchDbInforItem' ) : "";
  3752. if (! empty ( $searchDbInforItem )) {
  3753. Doo::loadModel ( 'client' );
  3754. $client = new client ();
  3755. $clientInfo = $client->getClientByName ( $searchDbInforItem );
  3756. echo json_encode ( $clientInfo );
  3757. } else {
  3758. echo json_encode ( array (
  3759. 0 => array (
  3760. 'clientname' => ''
  3761. )
  3762. ) );
  3763. }
  3764. }
  3765. function searchCompany() {
  3766. $searchDbInforItem = $this->get_args ( 'searchDbInforItem' ) ? $this->get_args ( 'searchDbInforItem' ) : "";
  3767. if (! empty ( $searchDbInforItem )) {
  3768. Doo::loadModel ( 'company' );
  3769. $company = new company ();
  3770. $clientInfo = $company->searchCompany ( $searchDbInforItem );
  3771. echo json_encode ( $clientInfo );
  3772. } else {
  3773. echo json_encode ( array (
  3774. 0 => array (
  3775. 'companyname' => '',
  3776. 'local' => ''
  3777. )
  3778. ) );
  3779. }
  3780. }
  3781. function checkCompany() {
  3782. $searchDbInforItem = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : "";
  3783. $searchDbInforItem = explode ( '-', $searchDbInforItem );
  3784. $this->nature ['naturelenght'] = 15;
  3785. Doo::loadModel ( 'district' );
  3786. $district = new district ();
  3787. $d = $district->get_lv ( 1 );
  3788. $html = '<option vlaue="0">请选择</option>';
  3789. foreach ( $d as $key => $value ) {
  3790. $html .= '<option value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  3791. }
  3792. $this->nature ['district'] = $html;
  3793. if (! empty ( $searchDbInforItem )) {
  3794. Doo::loadModel ( 'company' );
  3795. $company = new company ();
  3796. if (! isset ( $searchDbInforItem [1] )) {
  3797. echo json_encode ( array (
  3798. "success" => false,
  3799. 'nature' => $this->nature
  3800. ) );
  3801. die ();
  3802. }
  3803. $clientInfo = $company->getCompanyByName ( $searchDbInforItem [0], $searchDbInforItem [1] );
  3804. if (! empty ( $clientInfo ))
  3805. echo json_encode ( array (
  3806. "success" => true,
  3807. 'data' => $clientInfo
  3808. ) );
  3809. else
  3810. echo json_encode ( array (
  3811. "success" => false,
  3812. 'nature' => $this->nature
  3813. ) );
  3814. } else {
  3815. echo json_encode ( array (
  3816. "success" => false,
  3817. 'nature' => $this->nature
  3818. ) );
  3819. }
  3820. }
  3821. function checkLongle() {
  3822. $searchDbInforItem = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : "";
  3823. $searchDbInforItem = explode ( ' ', $searchDbInforItem );
  3824. if (! empty ( $searchDbInforItem )) {
  3825. Doo::loadModel ( 'longle' );
  3826. $longle = new longle ();
  3827. $clientInfo = $longle->getLongleBykeynum ( $searchDbInforItem [0] );
  3828. if (! empty ( $clientInfo ))
  3829. echo json_encode ( array (
  3830. "success" => true
  3831. ) );
  3832. else
  3833. echo json_encode ( array (
  3834. "success" => false
  3835. ) );
  3836. } else {
  3837. echo json_encode ( array (
  3838. "success" => false
  3839. ) );
  3840. }
  3841. }
  3842. function searchLongle() {
  3843. $searchDbInforItem = $this->get_args ( 'searchDbInforItem' ) ? $this->get_args ( 'searchDbInforItem' ) : "";
  3844. if (! empty ( $searchDbInforItem )) {
  3845. Doo::loadModel ( 'longle' );
  3846. $longle = new longle ();
  3847. $longleInfo = $longle->getLongleBykeynum2 ( $searchDbInforItem );
  3848. echo json_encode ( $longleInfo );
  3849. } else {
  3850. echo json_encode ( array (
  3851. 0 => array (
  3852. 'clientname' => ''
  3853. )
  3854. ) );
  3855. }
  3856. }
  3857. function updateChangeCompany() {
  3858. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3859. $clientID = $this->get_args ( 'clientID' ) ? $this->get_args ( 'clientID' ) : 0;
  3860. $companyname = $this->get_args ( 'companyname' ) ? $this->get_args ( 'companyname' ) : "";
  3861. Doo::loadModel ( 'company' );
  3862. Doo::loadModel ( 'client' );
  3863. $client = new client ();
  3864. $company = new company ();
  3865. $companyname = explode ( "-", $companyname );
  3866. if (isset ( $companyname [1] ))
  3867. $k = $company->getCompanyByName ( $companyname [0], $companyname [1] );
  3868. else
  3869. $k = array ();
  3870. if (! empty ( $cid ) && ! empty ( $k ) && ! empty ( $clientID )) {
  3871. $client->cid = $clientID;
  3872. $client->companyid = $cid;
  3873. $client->companyname = $companyname [0];
  3874. $client->update ();
  3875. } else {
  3876. $local1 = $this->get_args ( 'lv21' ) ? $this->get_args ( 'lv21' ) : 0;
  3877. $local2 = $this->get_args ( 'lv22' ) ? $this->get_args ( 'lv22' ) : 0;
  3878. $local3 = $this->get_args ( 'lv23' ) ? $this->get_args ( 'lv23' ) : 0;
  3879. Doo::loadModel ( 'district' );
  3880. $district = new district ();
  3881. // 更新公司信息
  3882. $lv1 = $district->getbyid ( $local1 );
  3883. $lv2 = $district->getbyid ( $local2 );
  3884. $lv3 = $district->getbyid ( $local3 );
  3885. if (empty ( $local1 ) || empty ( $local2 ))
  3886. return "/";
  3887. if (! empty ( $local1 ) && ! empty ( $local2 ))
  3888. $company->local = $lv1 [0] ['name'] . "," . $lv2 [0] ['name'] . "," . $lv3 [0] ['name'];
  3889. if (! empty ( $local1 ) && ! empty ( $local2 ))
  3890. $company->district = $local1 . "," . $local2 . "," . $local3;
  3891. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  3892. $fax = $this->get_args ( 'fax' ) ? $this->get_args ( 'fax' ) : "";
  3893. $webservice = $this->get_args ( 'webservice' ) ? $this->get_args ( 'webservice' ) : "";
  3894. $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
  3895. $landmarks = $this->get_args ( 'landmarks' ) ? $this->get_args ( 'landmarks' ) : "";
  3896. $stay = $this->get_args ( 'stay' ) ? $this->get_args ( 'stay' ) : "";
  3897. $ride = $this->get_args ( 'ride' ) ? $this->get_args ( 'ride' ) : "";
  3898. $nature = implode ( ",", $nature );
  3899. $company->companyname = $companyname [0];
  3900. $company->ride = $ride;
  3901. $company->fax = $fax;
  3902. $company->webservice = $webservice;
  3903. $company->address = $address;
  3904. $company->landmarks = $landmarks;
  3905. $company->stay = $stay;
  3906. $company->nature = $nature;
  3907. $cid = $company->insert ();
  3908. $client->cid = $clientID;
  3909. $client->companyid = $cid;
  3910. $client->companyname = $companyname [0];
  3911. $client->update ();
  3912. }
  3913. return "/contacts";
  3914. }
  3915. function AddClientInfo() { // 不编辑公司
  3916. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3917. $clientname = $this->get_args ( 'clientname' ) ? $this->get_args ( 'clientname' ) : "";
  3918. $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : "";
  3919. $nicename = $this->get_args ( 'nicename' ) ? $this->get_args ( 'nicename' ) : "";
  3920. $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : "";
  3921. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";
  3922. $email = $this->get_args ( 'email' ) ? $this->get_args ( 'email' ) : "";
  3923. $unit = $this->get_args ( 'unit' ) ? $this->get_args ( 'unit' ) : "";
  3924. $fax = $this->get_args ( 'fax' ) ? $this->get_args ( 'fax' ) : "";
  3925. $webservice = $this->get_args ( 'webservice' ) ? $this->get_args ( 'webservice' ) : "";
  3926. $department = $this->get_args ( 'department' ) ? $this->get_args ( 'department' ) : "";
  3927. $position = $this->get_args ( 'position' ) ? $this->get_args ( 'position' ) : "";
  3928. $office = $this->get_args ( 'office' ) ? $this->get_args ( 'office' ) : "";
  3929. $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
  3930. $ride = $this->get_args ( 'ride' ) ? $this->get_args ( 'ride' ) : "";
  3931. $landmarks = $this->get_args ( 'landmarks' ) ? $this->get_args ( 'landmarks' ) : "";
  3932. $qq = $this->get_args ( 'qq' ) ? $this->get_args ( 'qq' ) : "";
  3933. $priority = $this->get_args ( 'priority' ) ? $this->get_args ( 'priority' ) : 5;
  3934. $stay = $this->get_args ( 'stay' ) ? $this->get_args ( 'stay' ) : "";
  3935. $mark = $this->get_args ( 'mark' ) ? $this->get_args ( 'mark' ) : "";
  3936. $lv21 = $this->get_args ( 'lv21' ) ? $this->get_args ( 'lv21' ) : "";
  3937. $lv22 = $this->get_args ( 'lv22' ) ? $this->get_args ( 'lv22' ) : "";
  3938. $lv23 = $this->get_args ( 'lv23' ) ? $this->get_args ( 'lv23' ) : "";
  3939. if (! empty ( $cid ) && ! empty ( $clientname )) {
  3940. Doo::loadModel ( 'client' );
  3941. Doo::loadModel ( 'district' );
  3942. $district = new district ();
  3943. $client = new client ();
  3944. $client->cid = $cid;
  3945. $client->clientname = $clientname;
  3946. $client->gender = $gender;
  3947. $client->nicename = $nicename;
  3948. $client->telephone = $telephone;
  3949. $client->phone = $phone;
  3950. $client->email = $email;
  3951. // if(!empty($unit)){
  3952. // $client->unit=$unit;
  3953. // $client->companyname=$unit;
  3954. // }
  3955. if (! empty ( $lv21 ) && ! empty ( $lv22 ) && ! empty ( $lv23 )) {
  3956. $client->district = $lv21 . "," . $lv22 . "," . $lv23;
  3957. }
  3958. if (! empty ( $client->district )) {
  3959. $districtList = $district->find ( array (
  3960. 'where' => 'id in(' . $client->district . ')',
  3961. 'asArray' => true
  3962. ) );
  3963. $jsonString = array ();
  3964. foreach ( $districtList as $value ) {
  3965. array_push ( $jsonString, $value ['name'] );
  3966. }
  3967. $jsonString = implode ( ",", $jsonString );
  3968. if (! empty ( $jsonString ))
  3969. $client->local = $jsonString;
  3970. }
  3971. $client->fax = $fax;
  3972. $client->webservice = $webservice;
  3973. $client->department = $department;
  3974. $client->position = $position;
  3975. $client->office = $office;
  3976. $client->address = $address;
  3977. $client->ride = $ride;
  3978. $client->landmarks = $landmarks;
  3979. $client->qq = $qq;
  3980. $client->stay = $stay;
  3981. $client->priority = $priority;
  3982. $client->mark = $mark;
  3983. $client->updatetime = time ();
  3984. $client->update ();
  3985. // Doo::loadModel ( 'company' );
  3986. // $company = new company();
  3987. // $companyid=$client->getOne(array('where'=>' cid='.$cid,'asArray'=>true));
  3988. // $company->office=$office;
  3989. // $company->fax=$fax;
  3990. // $company->address=$address;
  3991. // $company->ride=$ride;
  3992. // $company->landmarks=$landmarks;
  3993. // $company->cid=$companyid['companyid'];
  3994. // if(!empty($unit)){
  3995. // $company->companyname=$unit;
  3996. // }
  3997. // $company->update();
  3998. $clientInfo = $client->getOne ( array (
  3999. 'where' => ' cid=' . $cid,
  4000. 'asArray' => true
  4001. ) );
  4002. // 日常行为
  4003. Doo::loadModel ( "action_log" );
  4004. $action_log = new action_log ();
  4005. $action_log->action = $this->staff [0] ['category'] . '<b href="javascript:void(0)" onclick="showStaff(\'' . $this->staff [0] ['sid'] . '\')" >' . $this->staff [0] ['username'] . '</b>编辑了<a href="javascript:void(0)" onclick="showClick(\'' . $cid . '\')">' . $clientname . '</a>(' . $clientInfo ['companyname'] . ')';
  4006. $action_log->sid = $this->staff [0] ['sid'];
  4007. $action_log->cid = $this->staff [0] ['cid'];
  4008. $action_log->updatetime = date ( "Y-m-d" );
  4009. $action_log->time = date ( "H:i" );
  4010. $action_log->class = $action_log->iconContacts;
  4011. $action_log->status = 2;
  4012. $action_log->districtid = $clientInfo ['district'];
  4013. $local = $district->getbyidlist ( $clientInfo ['district'] );
  4014. $action_log->city = $local [0] ['name'];
  4015. $action_log->province = $local [1] ['name'];
  4016. $action_log->company = $clientInfo ['companyname'];
  4017. Doo::loadModel ( 'company' );
  4018. $company = new company ();
  4019. $companyInfo = $company->getOne ( array (
  4020. 'where' => ' companyname="' . $clientInfo ['companyname'] . '"',
  4021. 'asArray' => true
  4022. ) );
  4023. $nature = explode ( ',', $companyInfo ['nature'] );
  4024. $action_log->nature = $nature [0];
  4025. $action_log->insert ();
  4026. echo json_encode ( array (
  4027. "success" => true
  4028. ) );
  4029. die ();
  4030. } else
  4031. echo json_encode ( array (
  4032. "success" => false
  4033. ) );
  4034. die ();
  4035. }
  4036. function ajaxClientInfo() {
  4037. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4038. if (! empty ( $cid )) {
  4039. Doo::loadModel ( 'client' );
  4040. Doo::loadModel ( 'company' );
  4041. $company = new company ();
  4042. $client = new client ();
  4043. $info = $client->getOne ( array (
  4044. 'where' => ' cid=' . $cid,
  4045. 'asArray' => true
  4046. ) );
  4047. $cinfo = $company->getOne ( array (
  4048. 'where' => ' cid=' . $info ['companyid'],
  4049. 'asArray' => true
  4050. ) );
  4051. Doo::loadModel ( 'district' );
  4052. $district = new district ();
  4053. $districtLv1 = $district->get_lv ( 1 );
  4054. $info ['districtList'] = $district->getbyidlist ( $info ['district'] );
  4055. $optionHtml = '<option vlaue="0">请选择</option>';
  4056. foreach ( $districtLv1 as $key => $value ) {
  4057. if ($value ['name'] == $info ['districtList'] [0] ['name'])
  4058. $optionHtml .= '<option selected value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  4059. else
  4060. $optionHtml .= '<option value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  4061. }
  4062. $info ['districtLv1'] = $optionHtml;
  4063. $info ['companyInfo'] = $cinfo;
  4064. echo json_encode ( array (
  4065. "success" => true,
  4066. 'html' => $info
  4067. ) );
  4068. die ();
  4069. } else
  4070. echo json_encode ( array (
  4071. "success" => false,
  4072. 'html' => ''
  4073. ) );
  4074. die ();
  4075. }
  4076. /**
  4077. * 为客户添加服务日志
  4078. */
  4079. function ajaxAddServiceLog() {
  4080. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : "";
  4081. $clientid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "";
  4082. $mark = $this->get_args ( 'mark' ) ? $this->get_args ( 'mark' ) : "";
  4083. $m = $this->get_args ( 'm' ) ? $this->get_args ( 'm' ) : "";
  4084. $d = $this->get_args ( 'd' ) ? $this->get_args ( 'd' ) : "";
  4085. $y = $this->get_args ( 'y' ) ? $this->get_args ( 'y' ) : date ( "Y" );
  4086. $Remind = $this->get_args ( 'Remind' ) ? $this->get_args ( 'Remind' ) : 0;
  4087. $time = $this->get_args ( 'time' ) ? $this->get_args ( 'time' ) : 0;
  4088. $remark = $this->get_args ( 'remark' ) ? $this->get_args ( 'remark' ) : "";
  4089. if (! empty ( $status ) && ! empty ( $clientid )) {
  4090. Doo::loadModel ( 'service_log' );
  4091. Doo::loadModel ( 'client_staff' );
  4092. Doo::loadModel ( 'client' );
  4093. Doo::loadModel ( 'district' );
  4094. $district = new district ();
  4095. $client = new client ();
  4096. $clientStaff = new client_staff ();
  4097. $service_log = new service_log ();
  4098. $service_log->status = $status;
  4099. $service_log->clientid = $clientid;
  4100. $service_log->mark = htmlspecialchars ( $mark );
  4101. $service_log->date = $y . "-" . $m . "-" . $d;
  4102. $service_log->category = $this->staff [0] ['category'];
  4103. $service_log->staffname = $this->staff [0] ['username'];
  4104. $service_log->staffid = $this->staff [0] ['sid'];
  4105. $service_log->insert ();
  4106. // 日常行为
  4107. Doo::loadModel ( "action_log" );
  4108. Doo::loadModel ( "client" );
  4109. $client = new client ();
  4110. // 记录服务时间
  4111. $client->cid = $clientid;
  4112. $client->servicetime = time ();
  4113. $client->update ();
  4114. $action_log = new action_log ();
  4115. $clientInfo = $client->getOne ( array (
  4116. 'where' => ' cid=' . $clientid,
  4117. 'asArray' => TRUE
  4118. ) );
  4119. $action_log->action = $this->staff [0] ['category'] . '<b href="javascript:void(0)" onclick="showStaff(\'' . $this->staff [0] ['sid'] . '\')">' . $this->staff [0] ['username'] . '</b>为<a href="javascript:void(0)" onclick="showClick(\'' . $clientid . '\')">' . $clientInfo ['clientname'] . '</a>(' . $clientInfo ['companyname'] . ')添加新客户记录。';
  4120. $action_log->sid = $this->staff [0] ['sid'];
  4121. $action_log->cid = $this->staff [0] ['cid'];
  4122. $action_log->updatetime = date ( "Y-m-d" );
  4123. $action_log->time = date ( "H:i" );
  4124. $action_log->status = 3;
  4125. $action_log->districtid = $clientInfo ['district'];
  4126. $local = $district->getbyidlist ( $clientInfo ['district'] );
  4127. $action_log->city = $local [0] ['name'];
  4128. $action_log->province = $local [1] ['name'];
  4129. $action_log->company = $clientInfo ['companyname'];
  4130. Doo::loadModel ( 'company' );
  4131. $company = new company ();
  4132. $companyInfo = $company->getOne ( array (
  4133. 'where' => ' companyname="' . $clientInfo ['companyname'] . '"',
  4134. 'asArray' => true
  4135. ) );
  4136. $nature = explode ( ',', $companyInfo ['nature'] );
  4137. $action_log->nature = $nature [0];
  4138. $action_log->class = $action_log->iconContacts;
  4139. $action_log->insert ();
  4140. // 更新信息中心服务日志统计数量
  4141. $redis = new Redis ();
  4142. $redis->connect ( '127.0.0.1', '6379' );
  4143. $categoryCondition = " and cid=" . $this->staff [0] ['cid'];
  4144. $sidCondition = " and sid=" . $this->staff [0] ['sid'];
  4145. // actionlog免查询值 $alCondition='';
  4146. $alCondition = ' aid>' . REMIT . ' and ';
  4147. // 个人服务日志数量redis值
  4148. $redisKeyCS = date ( 'Y-m-d' ) . 'SL_' . $this->staff [0] ['cid'] . '_' . $this->staff [0] ['sid'];
  4149. $action_log = new action_log ();
  4150. $actionLogLongle = $action_log->find ( array (
  4151. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  4152. 'where' => $alCondition . " status=3 " . $categoryCondition . $sidCondition . " and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) ",
  4153. 'groupby' => 'date_format(updatetime,"%m-%d")',
  4154. 'asArray' => true
  4155. ) );
  4156. $statisticsLongle = array ();
  4157. for($d = 0; $d <= 29; $d ++) {
  4158. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  4159. $falgLongle = true;
  4160. foreach ( $actionLogLongle as $value ) {
  4161. if ($value ['updatetime'] == $MD) {
  4162. array_push ( $statisticsLongle, $value ['count'] );
  4163. $falgLongle = false;
  4164. break;
  4165. }
  4166. }
  4167. if ($falgLongle)
  4168. array_push ( $statisticsLongle, 0 );
  4169. }
  4170. $statisticsLongle = array_reverse ( $statisticsLongle );
  4171. $jsl = json_encode ( $statisticsLongle );
  4172. $redis->set ( $redisKeyCS, $jsl );
  4173. // 办事处服务日志数量reids值
  4174. $redisKeyC = date ( 'Y-m-d' ) . 'SL_' . $this->staff [0] ['cid'] . '_';
  4175. $action_log = new action_log ();
  4176. $actionLogLongle = $action_log->find ( array (
  4177. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  4178. 'where' => $alCondition . " status=3 " . $categoryCondition . " and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) ",
  4179. 'groupby' => 'date_format(updatetime,"%m-%d")',
  4180. 'asArray' => true
  4181. ) );
  4182. $statisticsLongle = array ();
  4183. for($d = 0; $d <= 29; $d ++) {
  4184. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  4185. $falgLongle = true;
  4186. foreach ( $actionLogLongle as $value ) {
  4187. if ($value ['updatetime'] == $MD) {
  4188. array_push ( $statisticsLongle, $value ['count'] );
  4189. $falgLongle = false;
  4190. break;
  4191. }
  4192. }
  4193. if ($falgLongle)
  4194. array_push ( $statisticsLongle, 0 );
  4195. }
  4196. $statisticsLongle = array_reverse ( $statisticsLongle );
  4197. $jsl = json_encode ( $statisticsLongle );
  4198. $redis->set ( $redisKeyC, $jsl );
  4199. // 全员处服务日志数量的redis值
  4200. $redisKey = date ( 'Y-m-d' ) . 'SL__';
  4201. $action_log = new action_log ();
  4202. $actionLogLongle = $action_log->find ( array (
  4203. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  4204. 'where' => $alCondition . " status=3 and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) ",
  4205. 'groupby' => 'date_format(updatetime,"%m-%d")',
  4206. 'asArray' => true
  4207. ) );
  4208. $statisticsLongle = array ();
  4209. for($d = 0; $d <= 29; $d ++) {
  4210. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  4211. $falgLongle = true;
  4212. foreach ( $actionLogLongle as $value ) {
  4213. if ($value ['updatetime'] == $MD) {
  4214. array_push ( $statisticsLongle, $value ['count'] );
  4215. $falgLongle = false;
  4216. break;
  4217. }
  4218. }
  4219. if ($falgLongle)
  4220. array_push ( $statisticsLongle, 0 );
  4221. }
  4222. $statisticsLongle = array_reverse ( $statisticsLongle );
  4223. $jsl = json_encode ( $statisticsLongle );
  4224. $redis->set ( $redisKey, $jsl );
  4225. if (! empty ( $Remind )) {
  4226. Doo::loadModel ( 'remind' );
  4227. $remindObj = new remind ();
  4228. $datetime1 = new DateTime ( date ( 'Y-m-d' ) );
  4229. $datetime2 = new DateTime ( $time );
  4230. $interval = $datetime1->diff ( $datetime2 );
  4231. $remindObj->day = $interval->format ( '%a' );
  4232. $remindObj->remark = $remark;
  4233. $remindObj->time = date ( "Y-m-d" );
  4234. $remindObj->clientName = $clientInfo ['clientname'];
  4235. $remindObj->clientID = $clientid;
  4236. $remindObj->companyName = $clientInfo ['companyname'];
  4237. $remindObj->companyID = $companyInfo ['cid'];
  4238. $remindObj->staffID = $this->staff [0] ['sid'];
  4239. if ($status == 1)
  4240. $remindObj->class = "iconService";
  4241. if ($status == 2)
  4242. $remindObj->class = "iconPhone";
  4243. if ($status == 3)
  4244. $remindObj->class = "iconOther";
  4245. $remindObj->insert ();
  4246. }
  4247. echo json_encode ( array (
  4248. "success" => true,
  4249. 'html' => ''
  4250. ) );
  4251. die ();
  4252. } else
  4253. echo json_encode ( array (
  4254. "success" => false,
  4255. 'html' => ''
  4256. ) );
  4257. die ();
  4258. }
  4259. function _getLongleLogHtml($longleLog = array()) {
  4260. $html = "";
  4261. foreach ( $longleLog as $key => $value ) {
  4262. $dateline = explode ( "-", $value ['dateline'] );
  4263. $html .= '<div class="infoFlowList">
  4264. <div class="dateTitle">
  4265. <em class="month"><span class="num">' . $dateline [1] . '</span><span class="text">-' . $dateline [2] . '</span></em>
  4266. <span class="year">' . $dateline [0] . '</span>
  4267. </div>
  4268. ';
  4269. // 备注
  4270. if ($value ['status'] == 8) {
  4271. $html .= '
  4272. <ul class="flowList">
  4273. <li class="item iconLock">备注<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')" >' . $value ['operator'] . '</a></li>
  4274. <li class="item">' . $value ['mark'] . '</li>
  4275. </ul>';
  4276. // 生成
  4277. } elseif ($value ['status'] == 1) {
  4278. $html .= '<ul class="flowList">
  4279. <li class="item iconGenerate">生成<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')" >' . $value ['operator'] . '</a></li>
  4280. </ul>';
  4281. // 接收
  4282. } elseif ($value ['status'] == 2) {
  4283. $html .= '<ul class="flowList">
  4284. <li class="item iconReceive">接收<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')" >' . $value ['operator'] . '</a></li>
  4285. </ul>';
  4286. // 借出
  4287. } elseif ($value ['status'] == 3) {
  4288. $html .= '<ul class="flowList">
  4289. <li class="item iconBorrow">借出<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')" >' . $value ['operator'] . '</a></li>
  4290. <li class="item">' . $value ['product'] . '</li>
  4291. <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\'' . $value ['clientid'] . "," . $value ['client'] . '\')" >' . $value ['client'] . '</a></li>
  4292. </ul>';
  4293. // 销售
  4294. } elseif ($value ['status'] == 4) {
  4295. $html .= '<ul class="flowList">
  4296. <li class="item iconSell">销售<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')" >' . $value ['operator'] . '</a></li>
  4297. <li class="item">' . $value ['product'] . '</li>
  4298. <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\'' . $value ['clientid'] . "," . $value ['client'] . '\')" >' . $value ['client'] . '</a></li>
  4299. </ul>';
  4300. // 升级
  4301. } elseif ($value ['status'] == 5) {
  4302. $html .= '<ul class="flowList">
  4303. <li class="item iconUpdate">升级<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')" >' . $value ['operator'] . '</a></li>
  4304. <li class="item">' . $value ['product'] . '</li>
  4305. <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\'' . $value ['clientid'] . "," . $value ['client'] . '\')" >' . $value ['client'] . '</a></li>
  4306. </ul>';
  4307. // 更换
  4308. } elseif ($value ['status'] == 6) {
  4309. $html .= '<ul class="flowList">
  4310. <li class="item iconReplace">更换<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')">' . $value ['operator'] . '</a></li>
  4311. <li class="item"><a href="javascript:void(0);" onclick="getLockByName(\'' . $value ['new_key_num'] . '\')">' . $value ['new_key_num'] . '</a>
  4312. <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\'' . $value ['clientid'] . "," . $value ['client'] . '\')" >' . $value ['client'] . '</a></li>
  4313. </ul>';
  4314. // 回收
  4315. } elseif ($value ['status'] == 7) {
  4316. Doo::loadModel ( 'staff' );
  4317. $staff = new staff ();
  4318. $staffinfo = $staff->getOne ( array (
  4319. 'where' => ' username like "' . $value ['responsible'] . '"',
  4320. 'asArray' => true
  4321. ) );
  4322. if (empty ( $staffinfo ))
  4323. $staffinfo ['category'] = "";
  4324. $html .= '<ul class="flowList">
  4325. <li class="item iconRecycle">收回<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')">' . $value ['operator'] . '</a></li>
  4326. <li class="item">' . $staffinfo ['category'] . '<a href="javascript:void(0);" id="ajaxStaff" data="' . $value ['responsible'] . '">' . $value ['responsible'] . '</a></li>
  4327. </ul>';
  4328. } elseif ($value ['status'] == 9) {
  4329. $html .= '<ul class="flowList">
  4330. <li class="item iconGif">赠送 &lt; ' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')">' . $value ['operator'] . '</a></li>
  4331. <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\'' . $value ['clientid'] . "," . $value ['client'] . '\')" >' . $value ['client'] . '</a></li>
  4332. </ul>';
  4333. }
  4334. $html .= '</div>';
  4335. }
  4336. return $html;
  4337. }
  4338. function adminLock() {
  4339. $emsg = isset ( $this->params ['emsg'] ) ? $this->params ['emsg'] : "";
  4340. $data ['emsg'] = "";
  4341. if ($emsg != "")
  4342. $data ['emsg'] = "请填写完整的数据";
  4343. $data ['memu'] = "keyonline";
  4344. $data ['staff'] = $this->staff;
  4345. if ($this->staff [0] ['isadmin'] != 1)
  4346. return "/adminmyinfo";
  4347. Doo::loadModel ( 'L_category' );
  4348. $L_category = new L_category ();
  4349. $data ['category'] = $L_category->getCategory ();
  4350. $data ['time'] = time ();
  4351. $this->render ( "/admin/admin_addlock", $data );
  4352. }
  4353. function adminAddLock() {
  4354. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4355. $path = $this->get_args ( 'path' ) ? $this->get_args ( 'path' ) : "";
  4356. if ($cid != 0 && $path != "") {
  4357. Doo::loadModel ( 'longle' );
  4358. Doo::loadModel ( 'L_category' );
  4359. $L_category = new L_category ();
  4360. Doo::loadModel ( 'longle_log' );
  4361. $exlArray = $this->_format_excel_to_array ( DOO::conf ()->SITE_PATH . "upload/" . iconv ( "UTF-8", "GB2312", $path ) );
  4362. // print_r($exlArray);die;
  4363. // echo json_encode($exlArray);die;
  4364. $category = $L_category->getCategoryById ( $cid );
  4365. foreach ( $exlArray as $key => $value ) {
  4366. // 锁记录
  4367. $longle = new longle ();
  4368. $longle->key_num = str_replace ( "'", "", $value ['key_num'] );
  4369. $longle->product = str_replace ( "'", "", $value ['product'] );
  4370. $longle->make_day = $value ['make_day'];
  4371. $longle->alloted_time = $value ['alloted_time'];
  4372. $longle->status = 1;
  4373. $longle->statusT = "生成";
  4374. $longle->cid = $cid;
  4375. $longle->category = $category [0] ['title'];
  4376. $longle->SerialNumber = $value ['SerialNumber'];
  4377. $longle->version = $value ['version'];
  4378. $lid = $longle->insert ();
  4379. // 锁日志记录
  4380. $longle_log = new longle_log ();
  4381. $longle_log->lid = $lid;
  4382. $longle_log->status = 1;
  4383. $longle_log->statusT = "生成";
  4384. $longle_log->operator = $this->staff [0] ['username'];
  4385. $longle_log->product = $longle->product;
  4386. $longle_log->category = $this->staff [0] ['category'];
  4387. $longle_log->dateline = date ( "Y-m-d" );
  4388. $id = $longle_log->insert ();
  4389. }
  4390. // 记录日常行为
  4391. Doo::loadModel ( "action_log" );
  4392. $action_log = new action_log ();
  4393. $action_log->action = '总部<b href="javascript:void(0)" onclick="showStaff(\'' . $this->staff [0] ['sid'] . '\')" >' . $this->staff [0] ['username'] . '</b>生成<a href="javascript:void(0)" onclick="showLook(\'' . str_replace ( "'", "", $exlArray [0] ['key_num'] ) . '\')">' . str_replace ( "'", "", $exlArray [0] ['key_num'] ) . '</a>等<b>' . count ( $exlArray ) . '</b>个锁';
  4394. $action_log->sid = $this->staff [0] ['sid'];
  4395. $action_log->cid = $this->staff [0] ['cid'];
  4396. $action_log->class = $action_log->iconGenerate;
  4397. $action_log->updatetime = date ( "Y-m-d" );
  4398. $action_log->time = date ( "H:i" );
  4399. $action_log->status = 11;
  4400. $action_log->insert ();
  4401. return "/keyonline";
  4402. } else
  4403. return "/adminlock/error";
  4404. }
  4405. function avatarCM() {
  4406. $vid = isset ( $this->params ['vid'] ) ? $this->params ['vid'] : 0;
  4407. if (! empty ( $vid )) {
  4408. Doo::loadModel ( "verify" );
  4409. $verify = new verify ();
  4410. Doo::loadModel ( 'staff' );
  4411. $staff = new staff ();
  4412. $list = $verify->getOne ( array (
  4413. 'where' => 'vid=' . $vid,
  4414. 'asArray' => true
  4415. ) );
  4416. if (empty ( $list ))
  4417. return "/adminverify";
  4418. $avatar = json_decode ( $list ['staff'] );
  4419. foreach ( $avatar as $key => $value ) {
  4420. $uinfo = $staff->getOne ( array (
  4421. 'where' => 'sid=' . $value [0],
  4422. 'asArray' => true
  4423. ) );
  4424. $avatar [$key] ['2'] = $uinfo ['avatar'];
  4425. }
  4426. $verify->staff = json_encode ( $avatar );
  4427. $verify->update ( array (
  4428. 'where' => 'vid=' . $vid
  4429. ) );
  4430. }
  4431. return "/adminverify";
  4432. }
  4433. function adminmyinfo() {
  4434. $data ['memu'] = "adminmyinfo";
  4435. $data ['staff'] = $this->staff;
  4436. $birArray = explode ( '-', $this->staff [0] ['birthday'] );
  4437. $data ['year'] = $birArray [0];
  4438. $year = date ( 'Y' );
  4439. $yearHtml = "";
  4440. for(; $year >= 1900; $year --) {
  4441. $yearHtml .= '<option ';
  4442. if ($data ['year'] == $year)
  4443. $yearHtml .= 'selected';
  4444. $yearHtml .= ' value="' . $year . '">' . $year . '</option>';
  4445. }
  4446. $data ['yearHtml'] = $yearHtml;
  4447. $data ['month'] = 01;
  4448. $data ['day'] = 01;
  4449. if (isset ( $birArray [1] )) {
  4450. $data ['month'] = $birArray [1];
  4451. $data ['day'] = $birArray [2];
  4452. }
  4453. $data ['msg'] = urldecode ( $this->params ['msg'] );
  4454. $this->render ( "/admin/admin_myinfo", $data );
  4455. }
  4456. function updateMyinfo() {
  4457. $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : 0;
  4458. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : 0;
  4459. $email = $this->get_args ( 'email' ) ? $this->get_args ( 'email' ) : "";
  4460. $qq = is_numeric ( $this->get_args ( 'qq' ) ) ? $_POST ['qq'] : 0;
  4461. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4462. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4463. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : "";
  4464. $position = $this->get_args ( 'position' ) ? $this->get_args ( 'position' ) : "";
  4465. $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : "男";
  4466. $oldpassword = $this->get_args ( 'oldpassword' ) ? $this->get_args ( 'oldpassword' ) : "";
  4467. $newpassword = $this->get_args ( 'newpassword' ) ? $this->get_args ( 'newpassword' ) : "";
  4468. $rnewpassword = $this->get_args ( 'rnewpassword' ) ? $this->get_args ( 'rnewpassword' ) : "";
  4469. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  4470. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  4471. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  4472. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  4473. Doo::loadModel ( 'staff' );
  4474. $staff = new staff ();
  4475. Doo::loadModel ( 'staffDynamic' );
  4476. $staffDynamic = new staffDynamic ();
  4477. $staff->sid = $this->staff [0] ['sid'];
  4478. if (! empty ( $remittanceName ))
  4479. $staff->remittanceName = $remittanceName;
  4480. if (! empty ( $bankName ))
  4481. $staff->bankName = $bankName;
  4482. if (! empty ( $bankNumber ))
  4483. $staff->bankNumber = $bankNumber;
  4484. if (! empty ( $coupletNumber ))
  4485. $staff->coupletNumber = $coupletNumber;
  4486. $content = "";
  4487. $ext = "更新了他的";
  4488. if ($telephone != 0 && $this->staff [0] ['telephone'] != $telephone) {
  4489. $staff->telephone = $telephone;
  4490. $content .= "<b>手机</b>&nbsp;";
  4491. }
  4492. if ($phone != 0 && $this->staff [0] ['phone'] != $phone) {
  4493. $staff->phone = $phone;
  4494. $content .= "<b>电话</b>&nbsp;";
  4495. }
  4496. if ($qq != 0 && $this->staff [0] ['qq'] != $qq) {
  4497. $staff->qq = $qq;
  4498. $content .= "<b>QQ</b>&nbsp;";
  4499. }
  4500. if ($year != 2014) {
  4501. $staff->birthday = $year . "-" . $month . "-" . $day;
  4502. $content .= "<b>生日</b>&nbsp;";
  4503. }
  4504. if ($email != "" && filter_var ( $email, FILTER_VALIDATE_EMAIL ) && $this->staff [0] ['email'] != $email) {
  4505. $staff->email = $email;
  4506. $content .= "<b>邮箱</b>&nbsp;";
  4507. }
  4508. if (! empty ( $position )) {
  4509. $staff->position = $position;
  4510. $content .= "<b>职位</b>&nbsp;";
  4511. }
  4512. $staff->gender = $gender;
  4513. $msg = "更新成功";
  4514. if ($this->staff [0] ['passwork'] == md5 ( $oldpassword )) {
  4515. if ($newpassword == $rnewpassword && (! empty ( $newpassword )))
  4516. $staff->passwork = md5 ( $newpassword );
  4517. else
  4518. $msg = "密码不一致";
  4519. } else {
  4520. if ($oldpassword != "")
  4521. $msg = "密码错误";
  4522. }
  4523. if (! empty ( $content )) {
  4524. $staffDynamic->content = $ext . $content;
  4525. $staffDynamic->cid = $this->staff [0] ['cid'];
  4526. $staffDynamic->category = $this->staff [0] ['category'];
  4527. $staffDynamic->time = time ();
  4528. $staffDynamic->sid = $this->staff [0] ['sid'];
  4529. $staffDynamic->staff = $this->staff [0] ['username'];
  4530. $staffDynamic->insert ();
  4531. }
  4532. $staff->update ( array (
  4533. 'where' => ' sid=' . $this->staff [0] ['sid']
  4534. ) );
  4535. return "/adminmyinfo/" . $msg;
  4536. }
  4537. function admincontacts() {
  4538. $data ['memu'] = "admincontacts";
  4539. $data ['staff'] = $this->staff;
  4540. Doo::loadModel ( 'L_category' );
  4541. Doo::loadModel ( 'staff' );
  4542. $staff = new staff ();
  4543. $L_category = new L_category ();
  4544. $this->render ( "/admin/admin_addContacts", $data );
  4545. }
  4546. /**
  4547. * 微信通知设置
  4548. */
  4549. function notificationConf() {
  4550. Doo::loadModel ( "notificationConf" );
  4551. $notificationConf = new notificationConf ();
  4552. $detail = $notificationConf->getNotificationConfBySid ( $this->staff [0] ['sid'] );
  4553. $rule = json_decode ( $detail ['conf'], true );
  4554. $data ['rule'] = $rule;
  4555. $data ['memu'] = "notificationConf";
  4556. $data ['staff'] = $this->staff;
  4557. $this->render ( "/admin/invoiceNotificationConf", $data );
  4558. }
  4559. function ajaxSetNotificationConf() {
  4560. $notificationType = $this->get_args ( 'notificationType' ) ? $this->get_args ( 'notificationType' ) : "";
  4561. $notificationValue = $this->get_args ( 'notificationValue' ) ? $this->get_args ( 'notificationValue' ) : '';
  4562. if (! empty ( $notificationType ) && ! empty ( $notificationValue ) && ! empty ( $this->staff [0] ['sid'] )) {
  4563. Doo::loadModel ( "notificationConf" );
  4564. $notificationConf = new notificationConf ();
  4565. $detail = $notificationConf->getNotificationConfBySid ( $this->staff [0] ['sid'] );
  4566. if (empty ( $detail )) {
  4567. $rule = array (
  4568. $notificationType => $notificationValue
  4569. );
  4570. $rule = json_encode ( $rule );
  4571. $item = array (
  4572. 'sid' => $this->staff [0] ['sid'],
  4573. 'conf' => $rule
  4574. );
  4575. $notificationConf->addNotification ( $item );
  4576. } else {
  4577. $rule = json_decode ( $detail ['conf'], true );
  4578. $rule [$notificationType] = $notificationValue;
  4579. $rule = json_encode ( $rule );
  4580. $item = array (
  4581. 'nid' => $detail ['nid'],
  4582. 'conf' => $rule
  4583. );
  4584. $notificationConf->setNotificationByCondition ( $item );
  4585. }
  4586. echo json_encode ( array (
  4587. 'status' => 1,
  4588. 'msgType' => $notificationType,
  4589. 'msg' => ''
  4590. ) );
  4591. die ();
  4592. }
  4593. echo json_encode ( array (
  4594. 'status' => 2,
  4595. 'msgType' => $notificationType,
  4596. 'msg' => 'illegal request'
  4597. ) );
  4598. die ();
  4599. }
  4600. function eMailTask() {
  4601. Doo::loadModel ( 'tag' );
  4602. $tag = new tag ();
  4603. Doo::loadModel ( 'district' );
  4604. $district = new district ();
  4605. $tagList = $tag->getAllBySid ( $this->staff [0] ['sid'] );
  4606. $districtList = $district->get_lv ( 1 );
  4607. $data ['tagList'] = $tagList;
  4608. $data ['districtList'] = $districtList;
  4609. $data ['memu'] = "eMailTask";
  4610. $data ['staff'] = $this->staff;
  4611. $data ['mailMemu'] = 'eMailTask';
  4612. $data ['nature'] = $this->nature;
  4613. $this->render ( "/mail_create", $data );
  4614. }
  4615. function eMialCenter() {
  4616. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4617. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 0;
  4618. Doo::loadModel ( 'eMailList' );
  4619. $eMailList = new eMailList ();
  4620. Doo::loadModel ( 'tag' );
  4621. $tag = new tag ();
  4622. Doo::loadModel ( 'staff' );
  4623. $staff = new staff ();
  4624. $dateCondition = "status!=2 and Year(date) =" . $year;
  4625. if (! empty ( $month ))
  4626. $dateCondition = "Year(date) =" . $year . " and Month(date) = " . $month;
  4627. $mailList = $eMailList->find ( array (
  4628. 'where' => $dateCondition,
  4629. 'asc' => 'status',
  4630. 'desc' => 'elid',
  4631. 'asArray' => true
  4632. ) );
  4633. foreach ( $mailList as $key => $value ) {
  4634. $mailList [$key] ['clientName2'] = $mailList [$key] ['clientName3'] = array ();
  4635. $mailList [$key] ['clientName'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName'] ) ), true );
  4636. if (! empty ( $value ['clientName2'] ))
  4637. $mailList [$key] ['clientName2'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName2'] ) ), true );
  4638. if (! empty ( $value ['clientName3'] ))
  4639. $mailList [$key] ['clientName3'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName3'] ) ), true );
  4640. $mailList [$key] ['illegalEmail'] = json_decode ( $value ['illegalEmail'], true );
  4641. $mailList [$key] ['sendEmail'] = json_decode ( $value ['sendEmail'], true );
  4642. $mailList [$key] ['clientCount'] = count ( $mailList [$key] ['clientName'] ) + count ( $mailList [$key] ['clientName2'] ) + count ( $mailList [$key] ['clientName3'] );
  4643. $mailList [$key] ['tag'] = array ();
  4644. $kks = $staff->getOne ( array (
  4645. 'where' => 'username like "' . $value ['staffName'] . '"',
  4646. 'asArray' => true
  4647. ) );
  4648. $mailList [$key] ['category'] = $kks ['category'];
  4649. if (! empty ( $value ['tag'] ))
  4650. $mailList [$key] ['tag'] = $tag->find ( array (
  4651. 'where' => 'tid in ( ' . $value ['tag'] . ') ',
  4652. 'asArray' => true
  4653. ) );
  4654. }
  4655. $dateHtml = "";
  4656. $now = date ( "Y" );
  4657. for($YEARD = 2014; $YEARD <= 2050; $YEARD ++) {
  4658. if ($YEARD <= $now) {
  4659. $dateHtml .= '<option ';
  4660. if ($year == $YEARD)
  4661. $dateHtml .= ' selected ';
  4662. $dateHtml .= ' value="' . $YEARD . '">' . $YEARD . '</option>';
  4663. }
  4664. }
  4665. $monthHtml = '<option value="0">所有月份</option>';
  4666. for($i = 1; $i <= 12; $i ++) {
  4667. $monthHtml .= '<option ';
  4668. if ($i == $month)
  4669. $monthHtml .= ' selected ';
  4670. $monthHtml .= ' value="' . $i . '">' . $i . '</option>';
  4671. }
  4672. $data ['monthHtml'] = $monthHtml;
  4673. $data ['dateHtml'] = $dateHtml;
  4674. $data ['mailList'] = $mailList;
  4675. $data ['memu'] = "eMailTask";
  4676. $data ['staff'] = $this->staff;
  4677. $data ['mailMemu'] = 'eMialCenter';
  4678. $data ['nature'] = $this->nature;
  4679. $this->render ( "/mailCenter", $data );
  4680. }
  4681. function authMail() {
  4682. $elid = isset ( $this->params ['elid'] ) ? $this->params ['elid'] : 0;
  4683. if (! empty ( $elid )) {
  4684. Doo::loadModel ( 'eMailList' );
  4685. $eMailList = new eMailList ();
  4686. $eMailList->examine = 2;
  4687. $eMailList->mark = $this->staff [0] ['username'] . "已同意";
  4688. $eMailList->update ( array (
  4689. 'where' => 'elid=' . $elid,
  4690. 'asArray' => true
  4691. ) );
  4692. }
  4693. return '/eMialCenter';
  4694. }
  4695. function editMailView() {
  4696. $elid = isset ( $this->params ['elid'] ) ? $this->params ['elid'] : 0;
  4697. Doo::loadModel ( 'tag' );
  4698. $tag = new tag ();
  4699. Doo::loadModel ( 'district' );
  4700. $district = new district ();
  4701. Doo::loadModel ( 'eMailList' );
  4702. $eMList = new eMailList ();
  4703. $mail = $eMList->getOne ( array (
  4704. 'where' => 'elid =' . $elid . '',
  4705. 'asArray' => true
  4706. ) );
  4707. if (empty ( $mail ))
  4708. return "/eMailList";
  4709. $mail ['tagList'] = explode ( ",", $mail ['tag'] );
  4710. $tagList = $tag->getAllBySid ( $this->staff [0] ['sid'] );
  4711. $districtList = $district->get_lv ( 1 );
  4712. $tagHtml = '';
  4713. foreach ( $tagList as $key => $value ) {
  4714. $tagHtml .= '<label><span data-original-title="' . $value ['name'] . '" data-toggle="ctooltip" data-placement="right" class="contactsTag tagCol-0' . $value ['colorid'] . '">
  4715. <input type="checkbox" name="tagId[]"';
  4716. foreach ( $mail ['tagList'] as $k => $v ) {
  4717. if ($value ['tid'] == $v) {
  4718. $tagHtml .= ' checked ';
  4719. break;
  4720. }
  4721. }
  4722. $tagHtml .= ' value="' . $value ['tid'] . '"></span></label>';
  4723. }
  4724. $districtHtml = '';
  4725. foreach ( $districtList as $key => $value ) {
  4726. $districtHtml .= '<option value="' . $value ['id'] . '"';
  4727. if ($value ['id'] == $mail ['districtId'])
  4728. $districtHtml .= 'selected';
  4729. $districtHtml .= '>' . $value ['name'] . '</option>';
  4730. }
  4731. $natureHtml = '';
  4732. $natList = explode ( ",", $mail ['nature'] );
  4733. foreach ( $this->nature as $key => $value ) {
  4734. $natureHtml .= '<label><input type="checkbox" name="nature[]" ';
  4735. foreach ( $natList as $k => $v ) {
  4736. if ($value == $v) {
  4737. $natureHtml .= ' checked ';
  4738. break;
  4739. }
  4740. }
  4741. $natureHtml .= 'value="' . $value . '">' . $value . '</label>';
  4742. }
  4743. $data ['natureHtml'] = $natureHtml;
  4744. $data ['districtHtml'] = $districtHtml;
  4745. $data ['tagHtml'] = $tagHtml;
  4746. $data ['mail'] = $mail;
  4747. $data ['tagList'] = $tagList;
  4748. $data ['districtList'] = $districtList;
  4749. $data ['memu'] = "eMailTask";
  4750. $data ['staff'] = $this->staff;
  4751. $data ['mailMemu'] = 'eMailList';
  4752. $data ['nature'] = $this->nature;
  4753. $this->render ( "/mailEdit", $data );
  4754. }
  4755. function editEmail() {
  4756. $title = $this->get_args ( 'title' ) ? $this->get_args ( 'title' ) : "";
  4757. $skin = $this->get_args ( 'skin' ) ? $this->get_args ( 'skin' ) : "";
  4758. $content = isset ( $_POST ['content'] ) ? $_POST ['content'] : "";
  4759. $tagId = $this->get_args ( 'tagId' ) ? $this->get_args ( 'tagId' ) : array ();
  4760. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : array ();
  4761. $natureNULL = $this->get_args ( 'natureNULL' ) ? $this->get_args ( 'natureNULL' ) : "";
  4762. $did = $this->get_args ( 'did' ) ? $this->get_args ( 'did' ) : "";
  4763. $stype = $this->get_args ( 'stype' ) ? $this->get_args ( 'stype' ) : "";
  4764. $elid = $this->get_args ( 'elid' ) ? $this->get_args ( 'elid' ) : "";
  4765. if (! empty ( $title ) && ! empty ( $elid ) && (! empty ( $tagId ) || ! empty ( $did ))) {
  4766. Doo::loadModel ( 'eMailList' );
  4767. $eMailList = new eMailList ();
  4768. $etid = $eMailList->getOne ( array (
  4769. 'select' => 'etid,annexName,annex',
  4770. 'where' => 'elid=' . $elid,
  4771. 'asArray' => true
  4772. ) );
  4773. Doo::loadModel ( 'eMailTemplate' );
  4774. $eMailTemplate = new eMailTemplate ();
  4775. Doo::loadModel ( 'eMailJournal' );
  4776. $eMailJournal = new eMailJournal ();
  4777. if ($natureNULL != 'NULL') {
  4778. if (empty ( $tagId ) && ! empty ( $did ) && empty ( $nature ))
  4779. die ( '请选择性质' );
  4780. }
  4781. // annex
  4782. $annexPath = "";
  4783. $annexEXT = $this->_GetFileEXT ( $_FILES ["annex"] ["name"] );
  4784. $annexName = "";
  4785. if (isset ( $_FILES ['annex'] ['name'] )) {
  4786. if ((($annexEXT == "doc") || ($annexEXT == "xls") || ($annexEXT == "pdf") || ($annexEXT == "ppt") || ($annexEXT == "txt") || ($annexEXT == "smr") || ($annexEXT == "spu") || ($annexEXT == "zip") || ($annexEXT == "rar") || ($annexEXT == "jpg") || ($annexEXT == "png")) && ($_FILES ["annex"] ["size"] < 10485760)) {
  4787. $path = DOO::conf ()->SITE_PATH . "upload/emailAnnex/";
  4788. if (! file_exists ( $path . $_FILES ["annex"] ["name"] )) {
  4789. $fileName = time () . "." . $annexEXT;
  4790. $annexName = $_FILES ['annex'] ['name'];
  4791. $annexPath = $path . $fileName;
  4792. move_uploaded_file ( $_FILES ["annex"] ["tmp_name"], $annexPath );
  4793. $annexPath = $this->webPath . $fileName;
  4794. }
  4795. }
  4796. }
  4797. if (! empty ( $annexPath )) {
  4798. $annexHtml = '<table style="width:100%;margin:10px 0">
  4799. <thead>
  4800. <tr>
  4801. <th align="left" colspan="2" style="background-color:ff6501;color:#fff;font-size:16px;padding:5px">下载附件:</th>
  4802. </tr>
  4803. </thead>
  4804. <tbody>
  4805. <tr>
  4806. <td style="padding:5px"><a href="' . $annexPath . '" target="_blank" style="font-size:16px">' . $annexName . '</a></td>
  4807. <td>&nbsp;</td>
  4808. </tr>
  4809. </tbody>
  4810. </table>';
  4811. } elseif (! empty ( $etid ['annexName'] ) && empty ( $annexPath ))
  4812. $annexHtml = $etid ['annex'];
  4813. $smartcostMail = 'smartcost_mail_1';
  4814. $info = "";
  4815. // html template
  4816. if ($skin == 1) {
  4817. $html = '<div><table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  4818. <tbody><tr><td align="center"><table style="margin:20px;background-color:#fff;box-shadow:0px 1px 6px rgba(0, 0, 0, 0.3);width:60%;" cellpadding="0" cellspacing="0" align="center">
  4819. <tbody><tr>
  4820. <td style="background-color:#ff6501;padding:20px 0 25px;" align="center">
  4821. <span style="vertical-align:bottom;font-size:20px;color:#fff;">' . $title . '</span>
  4822. </td></tr><tr><td>
  4823. <table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;border-top:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  4824. <tbody><tr><td style="padding: 0 40px;" align="left">
  4825. <p style="margin-top:40px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
  4826. </td></tr><tr><td style="padding: 0 40px;" align="left">
  4827. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>' . $this->staff [0] ['username'] . '</b>:</p>
  4828. <p style="margin-top:0px;margin-bottom:20px;color:#383838;font-size:16px;line-height:32px;">
  4829. ' . $content . '</p>
  4830. </td></tr>
  4831. <tr><td align="left" style="padding: 0 40px;background:#fff">
  4832. ' . $annexHtml . '
  4833. </td></tr>
  4834. <tr> <td style="padding: 20px 40px;border-top:1px dashed #ddd" align="left">
  4835. <p style="margin-bottom:10px;color:#383838;font-size:16px;line-height:22px;border-left:2px solid #FF6501;padding-left:5px">
  4836. 纵横公路造价软件' . $this->staff [0] ['category'] . '办事处</p>
  4837. <table>
  4838. <tr><th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td></tr>
  4839. <tr><th align="right">联系人:</th><td>' . $this->staff [0] ['username'] . '</td></tr>
  4840. <tr><th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr>
  4841. <tr><th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td></tr>
  4842. <tr><th align="right">邮箱:</th><td>' . $this->staff [0] ['email'] . '</td></tr>
  4843. </table></td></tr></tbody></table></td></tr><tr>
  4844. <td style="padding: 0 40px;background-color:#383838;"><p style="color:#fff;padding:10px 0;text-align:center;margin:0">珠海纵横创新软件有限公司 <a href="http://www.smartcost.com.cn" style="color:#fff;text-decoration: underline;">smartcost.com.cn</a></p></td>
  4845. </tr></tbody></table></td></tr></tbody></table></div>';
  4846. $info = '<table><tr><th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td></tr>
  4847. <tr><th align="right">联系人:</th><td>' . $this->staff [0] ['username'] . '</td></tr>
  4848. <tr><th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr>
  4849. <tr><th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td></tr>
  4850. <tr><th align="right">邮箱:</th><td>' . $this->staff [0] ['email'] . '</td></tr></table>';
  4851. } elseif ($skin == 2) {
  4852. $smartcostMail = 'smartcost_mail_2';
  4853. $html = '<table cellspacing="0" cellpadding="0" style="background-color:#e4e4e4; width:100%;"><tbody><tr><td>
  4854. <table align="center" cellspacing="0" cellpadding="0" style="background-color:#f8f8f8; width:640px;margin-bottom:20px">
  4855. <tbody><tr><td align="left" style="background-color:#e4e4e4;"><p style="margin-top:10px;margin-bottom:10px;color:#999;font-size:16px;line-height:32px;">
  4856. <b><span name="titleHtml">' . $title . '</span></b></p></td>
  4857. </tr><tr><td><table align="center" cellspacing="0" cellpadding="0" style="border:1px solid #ddd;"><tbody><tr>
  4858. <td align="center" style="background-color:#EEF2F5;padding:20px 0 "><a style="text-decoration:none;" href="http://www.teambition.com/" target="_blank"><img width="291px" height="46" src="http://zonghengvideo.qiniudn.com/maillogo1.png"></a></td>
  4859. </tr><tr><td align="center" style="background-color:#fff;"><img width="640" height="191" src="http://zonghengvideo.qiniudn.com/hero.jpg"></td>
  4860. </tr><tr><td align="left" style="background-color:#fff;padding:40px;border-bottom:1px solid #ddd;">
  4861. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
  4862. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>' . $this->staff [0] ['username'] . '</b>:</p>
  4863. <p name="contentHtml" style="margin-top:0px;margin-bottom:15px;color:#383838;font-size:16px;line-height:32px;">' . $content . '</p></td>
  4864. </tr>
  4865. <tr><td align="left" style="padding: 0 40px;background:#fff">
  4866. ' . $annexHtml . '
  4867. </td></tr>
  4868. <tr><td style="padding: 10px 0;background:#EEF2F5"><table><tbody><tr>
  4869. <td style="font-size:14pxl;color:#333;padding:0 20px"><b>纵横公路造价软件' . $this->staff [0] ['category'] . '办事处</b><br>' . $this->staff [0] ['username'] . '</td>
  4870. <td><table><tbody><tr style="font-size:12px;color:#666">
  4871. <th align="right">电话:</th><td style="padding:0 20px 0 0">' . $this->staff [0] ['phone'] . '</td>
  4872. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr><tr style="font-size:12px;color:#666">
  4873. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  4874. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  4875. </tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr>
  4876. <td style="padding: 0 40px;background-color:#383838;"><p style="color:#fff;padding:10px 0;text-align:center;margin:0;font-size:12px">珠海纵横创新软件有限公司 <a href="http://www.smartcost.com.cn" style="color:#fff;text-decoration:underline;">smartcost.com.cn</a></p></td>
  4877. </tr></tbody></table></td></tr></tbody> </table>';
  4878. $info = '<table><tbody><tr style="font-size:12px;color:#666">
  4879. <th align="right">电话:</th><td style="padding:0 20px 0 0">' . $this->staff [0] ['phone'] . '</td>
  4880. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr><tr style="font-size:12px;color:#666">
  4881. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  4882. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  4883. </tr></tbody></table>';
  4884. } else {
  4885. $smartcostMail = 'smartcost_mail_3';
  4886. $html = '<table cellspacing="0" cellpadding="0" style="background-color:#ECF0E1; width:100%">
  4887. <tbody>
  4888. <tr>
  4889. <td>
  4890. <table align="center" cellspacing="0" cellpadding="0" style="width:698px;margin-bottom:30px;margin-top:30px;">
  4891. <tbody>
  4892. <tr>
  4893. <td>
  4894. <table align="center" cellspacing="0" cellpadding="0" style="border:1px solid #ccc;width:100%;border-top:none">
  4895. <tbody>
  4896. <tr>
  4897. <td align="right" style="background:#fff url(http://zonghengvideo.qiniudn.com/mail3-top-bg.png) no-repeat top center;padding:30px 20px 20px 20px;border-bottom:1px solid #E9EBE2;">
  4898. <div style="position:relative;text-align:right">
  4899. <b style="font-size:24px;color:#8A9F98;z-index:999"><span name="titleHtml">' . $title . '</span></b>
  4900. <div style="width:80px;height:80px;position:absolute;top:0;left:0"><img src="http://zonghengvideo.qiniudn.com/zonghenglogo.png"></div>
  4901. </div>
  4902. </td>
  4903. </tr>
  4904. <tr>
  4905. <td align="left" style="background-color:#fff;padding:40px;border-bottom:1px solid #ddd;">
  4906. <p style="margin-top:0px;margin-bottom:10px;color:#666;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
  4907. <p style="margin-top:0px;margin-bottom:10px;color:#666;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>' . $this->staff [0] ['username'] . '</b>:</p>
  4908. <p name="contentHtml" style="margin-top:0px;margin-bottom:15px;color:#666;font-size:16px;line-height:32px;">' . $content . '</p></td>
  4909. </tr>
  4910. <tr><td align="left" style="padding: 0 40px;background:#fff">
  4911. ' . $annexHtml . '
  4912. </td></tr>
  4913. <tr>
  4914. <td style="padding: 10px 0 0;background:#F6F6F6;">
  4915. <table>
  4916. <tbody><tr>
  4917. <td style="font-size:14pxl;color:#666;padding:0 20px"><b>纵横公路造价软件' . $this->staff [0] ['category'] . '办事处</b><br>' . $this->staff [0] ['username'] . '<br><a href="http://www.smartcost.com.cn" style="color:#666;font-size:12px;text-decoration:underline;">smartcost.com.cn</a></td>
  4918. <td>
  4919. <table style="width:100%">
  4920. <tbody><tr style="font-size:12px;color:#496781">
  4921. <th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td>
  4922. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td>
  4923. </tr>
  4924. <tr style="font-size:12px;color:#496781">
  4925. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  4926. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  4927. </tr>
  4928. </tbody></table>
  4929. </td>
  4930. </tr>
  4931. </tbody></table>
  4932. </td>
  4933. </tr>
  4934. <tr>
  4935. <td style="background:#F6F6F6 url(http://zonghengvideo.qiniudn.com/mail3-bottom-bg.png) no-repeat bottom center;"><p style="color:#fff;padding:0 0 20px;text-align:center;margin:0;font-size:12px"></p></td>
  4936. </tr>
  4937. </tbody>
  4938. </table></td>
  4939. </tr>
  4940. </tbody>
  4941. </table></td>
  4942. </tr>
  4943. </tbody>
  4944. </table>';
  4945. $info = '<table><tr style="font-size:12px;color:#496781"><th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td>
  4946. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr><tr style="font-size:12px;color:#496781">
  4947. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  4948. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td></tr></table>
  4949. ';
  4950. }
  4951. Doo::loadModel ( 'tag_client' );
  4952. $tagClient = new tag_client ();
  4953. Doo::loadModel ( 'client' );
  4954. $client = new client ();
  4955. Doo::loadModel ( 'company' );
  4956. $company = new company ();
  4957. $eMailTemplate->title = $title;
  4958. $eMailTemplate->skin = $skin;
  4959. $eMailTemplate->content = $content;
  4960. if (! empty ( $tagId ))
  4961. $eMailTemplate->tag = implode ( ",", $tagId );
  4962. $eMailTemplate->staffId = $this->staff [0] ['sid'];
  4963. $eMailTemplate->staffName = $this->staff [0] ['username'];
  4964. $eMailTemplate->status = 0;
  4965. $eMailTemplate->html = $html;
  4966. if (! empty ( $annexPath )) {
  4967. $eMailTemplate->annex = $annexPath;
  4968. $eMailTemplate->annexName = $annexName;
  4969. }
  4970. $etid = $eMailTemplate->update ( array (
  4971. 'where' => 'etid=' . $etid ['etid']
  4972. ) );
  4973. // create email list
  4974. $tagCondition = "";
  4975. $tagArray = array ();
  4976. foreach ( $tagId as $value ) {
  4977. array_push ( $tagArray, " tag like '%" . $value . "%' " );
  4978. }
  4979. if (! empty ( $tagArray ))
  4980. $tagCondition = ' and (' . implode ( " or ", $tagArray ) . ')';
  4981. $clientList = $tagClient->find ( array (
  4982. 'select' => 'client',
  4983. 'where' => 'sid=' . $this->staff [0] ['sid'] . $tagCondition,
  4984. 'asArray' => true
  4985. ) );
  4986. $clientArray = array ();
  4987. foreach ( $clientList as $value ) {
  4988. array_push ( $clientArray, $value ['client'] );
  4989. }
  4990. $clientEmailList = array ();
  4991. if (! empty ( $clientArray ))
  4992. $clientEmailList = $client->find ( array (
  4993. 'select' => 'email,cid,nicename as clientname,companyname',
  4994. 'where' => 'cid in (' . implode ( ",", $clientArray ) . ')',
  4995. 'asArray' => true
  4996. ) );
  4997. //
  4998. if ($stype == 2) {
  4999. // 获取性质相关数据
  5000. $cidList = '';
  5001. if ($natureNULL == '') {
  5002. $nD = array ();
  5003. foreach ( $nature as $key => $value ) {
  5004. array_push ( $nD, ' nature like "' . $value . '"' );
  5005. // $nD=' nature like "'.$value.'"';
  5006. }
  5007. $nD = implode ( ' or ', $nD );
  5008. $companycid = $company->find ( array (
  5009. 'select' => 'cid',
  5010. 'where' => $nD,
  5011. 'asArray' => true
  5012. ) );
  5013. $cidList = array ();
  5014. foreach ( $companycid as $key => $value ) {
  5015. array_push ( $cidList, $value ['cid'] );
  5016. }
  5017. $cidList = implode ( ',', $cidList );
  5018. if (! empty ( $cidList ))
  5019. $cidList = ' and companyid in (' . $cidList . ')';
  5020. else
  5021. $cidList = '';
  5022. }
  5023. // 'select'=>'email,cid,nicename as clientname,companyname,district'
  5024. $clientEmailList = $client->find ( array (
  5025. 'select' => 'email,cid,nicename as clientname,companyname,district',
  5026. 'where' => 'district like "' . $did . ',%" ' . $cidList,
  5027. 'asArray' => true
  5028. ) );
  5029. }
  5030. // ;datediff(curdate(), 'date')>=10
  5031. $eMailJournal->delete ( array (
  5032. 'where' => "datediff(curdate(), date)>=7"
  5033. ) );
  5034. $eMailJournal->delete ( array (
  5035. 'where' => 'DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(date)'
  5036. ) );
  5037. $checkMail = $eMailJournal->find ( array (
  5038. 'where' => 'DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(date)',
  5039. ' groupby' => 'email',
  5040. 'asArray' => true
  5041. ) );
  5042. $emailNameList = $emailArray = $illegalEmail = $sendEmail = array ();
  5043. Doo::db ()->beginTransaction ();
  5044. foreach ( $clientEmailList as $value ) {
  5045. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  5046. if (! empty ( $checkMail )) {
  5047. $falg = true;
  5048. foreach ( $checkMail as $v ) {
  5049. if ($v ['email'] == $value ['email']) {
  5050. $Bdate = strtotime ( $v ['date'] ) + 7 * 24 * 3600;
  5051. if ($Bdate <= time ()) {
  5052. array_push ( $emailArray, $value ['email'] );
  5053. array_push ( $emailNameList, $value );
  5054. $eMailJournal->date = date ( "Y-m-d" );
  5055. $eMailJournal->update ( array (
  5056. 'where' => 'ejid=' . $v ['ejid']
  5057. ) );
  5058. } else {
  5059. array_push ( $sendEmail, $value );
  5060. }
  5061. $falg = false;
  5062. break;
  5063. }
  5064. }
  5065. if ($falg) {
  5066. array_push ( $emailArray, $value ['email'] );
  5067. array_push ( $emailNameList, $value );
  5068. $eMailJournal->clientId = $value ['cid'];
  5069. $eMailJournal->status = 1;
  5070. $eMailJournal->email = $value ['email'];
  5071. $eMailJournal->date = date ( "Y-m-d" );
  5072. $eMailJournal->insert ();
  5073. }
  5074. } else {
  5075. array_push ( $emailArray, $value ['email'] );
  5076. array_push ( $emailNameList, $value );
  5077. $eMailJournal->clientId = $value ['cid'];
  5078. $eMailJournal->status = 1;
  5079. $eMailJournal->email = $value ['email'];
  5080. $eMailJournal->date = date ( "Y-m-d" );
  5081. $eMailJournal->insert ();
  5082. }
  5083. } else {
  5084. array_push ( $illegalEmail, $value );
  5085. }
  5086. }
  5087. Doo::db ()->commit ();
  5088. // echo json_encode($illegalEmail);
  5089. // json_encode(array_slice($illegalEmail,0,100))
  5090. // $kk=gzcompress();
  5091. // $ll=gzuncompress($kk);
  5092. // ."</br>".strlen($kk)."</br>".strlen($ll);die;
  5093. $size = floor ( count ( $emailArray ) / 3 );
  5094. if (! empty ( $emailArray )) {
  5095. if (count ( $emailArray ) < 3) {
  5096. $list = array (
  5097. 0 => $emailArray,
  5098. 1 => array (),
  5099. 2 => array ()
  5100. );
  5101. } else
  5102. $list = array_chunk ( $emailArray, $size );
  5103. } else
  5104. $list = array (
  5105. 0 => array (),
  5106. 1 => array (),
  5107. 2 => array ()
  5108. );
  5109. $emailJson = array ();
  5110. foreach ( $list as $value ) {
  5111. $em = array ();
  5112. foreach ( $value as $v ) {
  5113. array_push ( $em, $v );
  5114. }
  5115. array_push ( $emailJson, $em );
  5116. }
  5117. $size = floor ( count ( $emailNameList ) / 3 );
  5118. if (! empty ( $emailNameList )) {
  5119. if (count ( $emailNameList ) < 3) {
  5120. $list = array (
  5121. 0 => $emailNameList,
  5122. 1 => array (),
  5123. 2 => array ()
  5124. );
  5125. } else
  5126. $list = array_chunk ( $emailNameList, $size );
  5127. } else
  5128. $list = array (
  5129. 0 => array (),
  5130. 1 => array (),
  5131. 2 => array ()
  5132. );
  5133. $emailNameJson = array ();
  5134. foreach ( $list as $value ) {
  5135. $em = array ();
  5136. foreach ( $value as $v ) {
  5137. array_push ( $em, $v );
  5138. }
  5139. array_push ( $emailNameJson, $em );
  5140. }
  5141. //
  5142. $eMailList->date = date ( "Y-m-d" );
  5143. $eMailList->clientEmail = base64_encode ( gzcompress ( json_encode ( $emailJson [0] ) ) );
  5144. $eMailList->clientEmail2 = base64_encode ( gzcompress ( json_encode ( $emailJson [1] ) ) );
  5145. $eMailList->clientEmail3 = base64_encode ( gzcompress ( json_encode ( $emailJson [2] ) ) );
  5146. $eMailList->clientName = base64_encode ( gzcompress ( json_encode ( $emailNameJson [0] ) ) );
  5147. $eMailList->clientName2 = base64_encode ( gzcompress ( json_encode ( $emailNameJson [1] ) ) );
  5148. $eMailList->clientName3 = base64_encode ( gzcompress ( json_encode ( $emailNameJson [2] ) ) );
  5149. $eMailList->illegalEmail = json_encode ( array_slice ( $illegalEmail, 0, 100 ) ); // json_encode($illegalEmail);
  5150. $eMailList->sendEmail = json_encode ( $sendEmail );
  5151. $eMailList->templateName = $smartcostMail;
  5152. $eMailList->eTitle = $title;
  5153. $eMailList->html = $html;
  5154. $eMailList->content = $content;
  5155. $eMailList->info = $info;
  5156. if (! empty ( $annexName )) {
  5157. $eMailList->annex = $annexHtml;
  5158. $eMailList->annexName = $annexName;
  5159. }
  5160. if ($stype == 1) {
  5161. $eMailList->tag = implode ( ",", $tagId );
  5162. $eMailList->districtId = "";
  5163. $eMailList->nature = "";
  5164. }
  5165. if ($stype == 2) {
  5166. $eMailList->districtId = $did;
  5167. $eMailList->nature = implode ( ",", $nature );
  5168. $eMailList->tag = "";
  5169. }
  5170. $eMailList->update ( array (
  5171. 'where' => 'elid=' . $elid
  5172. ) );
  5173. return "/eMailList";
  5174. }
  5175. return "/eMailTask";
  5176. }
  5177. function createEmail() {
  5178. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  5179. $title = $this->get_args ( 'title' ) ? $this->get_args ( 'title' ) : "";
  5180. $skin = $this->get_args ( 'skin' ) ? $this->get_args ( 'skin' ) : "";
  5181. $content = isset ( $_POST ['content'] ) ? $_POST ['content'] : "";
  5182. $tagId = $this->get_args ( 'tagId' ) ? $this->get_args ( 'tagId' ) : array ();
  5183. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : array ();
  5184. $natureNULL = $this->get_args ( 'natureNULL' ) ? $this->get_args ( 'natureNULL' ) : "";
  5185. $did = $this->get_args ( 'did' ) ? $this->get_args ( 'did' ) : "";
  5186. $stype = $this->get_args ( 'stype' ) ? $this->get_args ( 'stype' ) : "";
  5187. if (! empty ( $title ) && (! empty ( $tagId ) || ! empty ( $did ))) {
  5188. Doo::loadModel ( 'eMailTemplate' );
  5189. $eMailTemplate = new eMailTemplate ();
  5190. Doo::loadModel ( 'eMailJournal' );
  5191. $eMailJournal = new eMailJournal ();
  5192. if ($natureNULL != 'NULL') {
  5193. if (empty ( $tagId ) && ! empty ( $did ) && empty ( $nature )) {
  5194. header ( 'Content-Type:text/html;charset=utf-8' );
  5195. die ( '请选择性质' );
  5196. }
  5197. }
  5198. // annex
  5199. $annexPath = "";
  5200. $annexEXT = $this->_GetFileEXT ( $_FILES ["annex"] ["name"] );
  5201. $annexName = "";
  5202. if (isset ( $_FILES ['annex'] ['name'] )) {
  5203. if ((($annexEXT == "doc") || ($annexEXT == "xls") || ($annexEXT == "pdf") || ($annexEXT == "ppt") || ($annexEXT == "txt") || ($annexEXT == "smr") || ($annexEXT == "spu") || ($annexEXT == "zip") || ($annexEXT == "rar") || ($annexEXT == "jpg") || ($annexEXT == "png")) && ($_FILES ["annex"] ["size"] < 10485760)) {
  5204. $path = DOO::conf ()->SITE_PATH . "upload/emailAnnex/";
  5205. if (! file_exists ( $path . $_FILES ["annex"] ["name"] )) {
  5206. $fileName = time () . "." . $annexEXT;
  5207. $annexName = $_FILES ['annex'] ['name'];
  5208. $annexPath = $path . $fileName;
  5209. move_uploaded_file ( $_FILES ["annex"] ["tmp_name"], $annexPath );
  5210. $annexPath = $this->webPath . $fileName;
  5211. }
  5212. }
  5213. }
  5214. $annexHtml = '<table style="width:100%;margin:10px 0">
  5215. <thead>
  5216. <tr>
  5217. <th align="left" colspan="2">下载附件:</th>
  5218. </tr>
  5219. </thead>
  5220. <tbody>
  5221. <tr>
  5222. <td><a href="' . $annexPath . '" target="_blank">' . $annexName . '</a></td>
  5223. <td>&nbsp;</td>
  5224. </tr>
  5225. </tbody>
  5226. </table>';
  5227. $smartcostMail = 'smartcost_mail_1';
  5228. $info = "";
  5229. // html template
  5230. if ($skin == 1) {
  5231. $html = '<div><table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  5232. <tbody><tr><td align="center"><table style="margin:20px;background-color:#fff;box-shadow:0px 1px 6px rgba(0, 0, 0, 0.3);width:60%;" cellpadding="0" cellspacing="0" align="center">
  5233. <tbody><tr>
  5234. <td style="background-color:#ff6501;padding:20px 0 25px;" align="center">
  5235. <span style="vertical-align:bottom;font-size:20px;color:#fff;">' . $title . '</span>
  5236. </td></tr><tr><td>
  5237. <table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;border-top:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  5238. <tbody><tr><td style="padding: 0 40px;" align="left">
  5239. <p style="margin-top:40px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
  5240. </td></tr><tr><td style="padding: 0 40px;" align="left">
  5241. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>' . $this->staff [0] ['username'] . '</b>:</p>
  5242. <p style="margin-top:0px;margin-bottom:20px;color:#383838;font-size:16px;line-height:32px;">
  5243. ' . $content . '</p>
  5244. </td></tr>
  5245. <tr><td align="left" style="padding: 0 40px;background:#fff">
  5246. ' . $annexHtml . '
  5247. </td></tr>
  5248. <tr> <td style="padding: 20px 40px;border-top:1px dashed #ddd" align="left">
  5249. <p style="margin-bottom:10px;color:#383838;font-size:16px;line-height:22px;border-left:2px solid #FF6501;padding-left:5px">
  5250. 纵横公路造价软件' . $this->staff [0] ['category'] . '办事处</p>
  5251. <table>
  5252. <tr><th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td></tr>
  5253. <tr><th align="right">联系人:</th><td>' . $this->staff [0] ['username'] . '</td></tr>
  5254. <tr><th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr>
  5255. <tr><th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td></tr>
  5256. <tr><th align="right">邮箱:</th><td>' . $this->staff [0] ['email'] . '</td></tr>
  5257. </table></td></tr></tbody></table></td></tr><tr>
  5258. <td style="padding: 0 40px;background-color:#383838;"><p style="color:#fff;padding:10px 0;text-align:center;margin:0">珠海纵横创新软件有限公司 <a href="http://www.smartcost.com.cn" style="color:#fff;text-decoration: underline;">smartcost.com.cn</a></p></td>
  5259. </tr></tbody></table></td></tr></tbody></table></div>';
  5260. $info = '<table><tr><th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td></tr>
  5261. <tr><th align="right">联系人:</th><td>' . $this->staff [0] ['username'] . '</td></tr>
  5262. <tr><th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr>
  5263. <tr><th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td></tr>
  5264. <tr><th align="right">邮箱:</th><td>' . $this->staff [0] ['email'] . '</td></tr></table>';
  5265. } elseif ($skin == 2) {
  5266. $smartcostMail = 'smartcost_mail_2';
  5267. $html = '<table cellspacing="0" cellpadding="0" style="background-color:#e4e4e4; width:100%;"><tbody><tr><td>
  5268. <table align="center" cellspacing="0" cellpadding="0" style="background-color:#f8f8f8; width:640px;margin-bottom:20px">
  5269. <tbody><tr><td align="left" style="background-color:#e4e4e4;"><p style="margin-top:10px;margin-bottom:10px;color:#999;font-size:16px;line-height:32px;">
  5270. <b><span name="titleHtml">' . $title . '</span></b></p></td>
  5271. </tr><tr><td><table align="center" cellspacing="0" cellpadding="0" style="border:1px solid #ddd;"><tbody><tr>
  5272. <td align="center" style="background-color:#EEF2F5;padding:20px 0 "><a style="text-decoration:none;" href="http://www.teambition.com/" target="_blank"><img width="291px" height="46" src="http://zonghengvideo.qiniudn.com/maillogo1.png"></a></td>
  5273. </tr><tr><td align="center" style="background-color:#fff;"><img width="640" height="191" src="http://zonghengvideo.qiniudn.com/hero.jpg"></td>
  5274. </tr><tr><td align="left" style="background-color:#fff;padding:40px;border-bottom:1px solid #ddd;">
  5275. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
  5276. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>' . $this->staff [0] ['username'] . '</b>:</p>
  5277. <p name="contentHtml" style="margin-top:0px;margin-bottom:15px;color:#383838;font-size:16px;line-height:32px;">' . $content . '</p></td>
  5278. </tr>
  5279. <tr><td align="left" style="padding: 0 40px;background:#fff">
  5280. ' . $annexHtml . '
  5281. </td></tr>
  5282. <tr><td style="padding: 10px 0;background:#EEF2F5"><table><tbody><tr>
  5283. <td style="font-size:14pxl;color:#333;padding:0 20px"><b>纵横公路造价软件' . $this->staff [0] ['category'] . '办事处</b><br>' . $this->staff [0] ['username'] . '</td>
  5284. <td><table><tbody><tr style="font-size:12px;color:#666">
  5285. <th align="right">电话:</th><td style="padding:0 20px 0 0">' . $this->staff [0] ['phone'] . '</td>
  5286. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr><tr style="font-size:12px;color:#666">
  5287. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5288. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  5289. </tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr>
  5290. <td style="padding: 0 40px;background-color:#383838;"><p style="color:#fff;padding:10px 0;text-align:center;margin:0;font-size:12px">珠海纵横创新软件有限公司 <a href="http://www.smartcost.com.cn" style="color:#fff;text-decoration:underline;">smartcost.com.cn</a></p></td>
  5291. </tr></tbody></table></td></tr></tbody> </table>';
  5292. $info = '<table><tbody><tr style="font-size:12px;color:#666">
  5293. <th align="right">电话:</th><td style="padding:0 20px 0 0">' . $this->staff [0] ['phone'] . '</td>
  5294. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr><tr style="font-size:12px;color:#666">
  5295. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5296. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  5297. </tr></tbody></table>';
  5298. } else {
  5299. $smartcostMail = 'smartcost_mail_3';
  5300. $html = '<table cellspacing="0" cellpadding="0" style="background-color:#ECF0E1; width:100%">
  5301. <tbody>
  5302. <tr>
  5303. <td>
  5304. <table align="center" cellspacing="0" cellpadding="0" style="width:698px;margin-bottom:30px;margin-top:30px;">
  5305. <tbody>
  5306. <tr>
  5307. <td>
  5308. <table align="center" cellspacing="0" cellpadding="0" style="border:1px solid #ccc;width:100%;border-top:none">
  5309. <tbody>
  5310. <tr>
  5311. <td align="right" style="background:#fff url(http://zonghengvideo.qiniudn.com/mail3-top-bg.png) no-repeat top center;padding:30px 20px 20px 20px;border-bottom:1px solid #E9EBE2;">
  5312. <div style="position:relative;text-align:right">
  5313. <b style="font-size:24px;color:#8A9F98;z-index:999"><span name="titleHtml">' . $title . '</span></b>
  5314. <div style="width:80px;height:80px;position:absolute;top:0;left:0"><img src="http://zonghengvideo.qiniudn.com/zonghenglogo.png"></div>
  5315. </div>
  5316. </td>
  5317. </tr>
  5318. <tr>
  5319. <td align="left" style="background-color:#fff;padding:40px;border-bottom:1px solid #ddd;">
  5320. <p style="margin-top:0px;margin-bottom:10px;color:#666;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
  5321. <p style="margin-top:0px;margin-bottom:10px;color:#666;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>' . $this->staff [0] ['username'] . '</b>:</p>
  5322. <p name="contentHtml" style="margin-top:0px;margin-bottom:15px;color:#666;font-size:16px;line-height:32px;">' . $content . '</p></td>
  5323. </tr>
  5324. <tr><td align="left" style="padding: 0 40px;background:#fff">
  5325. ' . $annexHtml . '
  5326. </td></tr>
  5327. <tr>
  5328. <td style="padding: 10px 0 0;background:#F6F6F6;">
  5329. <table>
  5330. <tbody><tr>
  5331. <td style="font-size:14pxl;color:#666;padding:0 20px"><b>纵横公路造价软件' . $this->staff [0] ['category'] . '办事处</b><br>' . $this->staff [0] ['username'] . '<br><a href="http://www.smartcost.com.cn" style="color:#666;font-size:12px;text-decoration:underline;">smartcost.com.cn</a></td>
  5332. <td>
  5333. <table style="width:100%">
  5334. <tbody><tr style="font-size:12px;color:#496781">
  5335. <th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td>
  5336. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td>
  5337. </tr>
  5338. <tr style="font-size:12px;color:#496781">
  5339. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5340. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  5341. </tr>
  5342. </tbody></table>
  5343. </td>
  5344. </tr>
  5345. </tbody></table>
  5346. </td>
  5347. </tr>
  5348. <tr>
  5349. <td style="background:#F6F6F6 url(http://zonghengvideo.qiniudn.com/mail3-bottom-bg.png) no-repeat bottom center;"><p style="color:#fff;padding:0 0 20px;text-align:center;margin:0;font-size:12px"></p></td>
  5350. </tr>
  5351. </tbody>
  5352. </table></td>
  5353. </tr>
  5354. </tbody>
  5355. </table></td>
  5356. </tr>
  5357. </tbody>
  5358. </table>';
  5359. $info = '<table><tr style="font-size:12px;color:#496781"><th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td>
  5360. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr><tr style="font-size:12px;color:#496781">
  5361. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5362. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td></tr></table>
  5363. ';
  5364. }
  5365. $eMailTemplate->title = $title;
  5366. $eMailTemplate->skin = $skin;
  5367. $eMailTemplate->content = $content;
  5368. if (! empty ( $tagId ))
  5369. $eMailTemplate->tag = implode ( ",", $tagId );
  5370. $eMailTemplate->staffId = $this->staff [0] ['sid'];
  5371. $eMailTemplate->staffName = $this->staff [0] ['username'];
  5372. $eMailTemplate->status = 0;
  5373. $eMailTemplate->html = $html;
  5374. $eMailTemplate->annex = $annexPath;
  5375. $eMailTemplate->annexName = $annexName;
  5376. $etid = $eMailTemplate->insert ();
  5377. // create email list
  5378. Doo::loadModel ( 'tag_client' );
  5379. $tagClient = new tag_client ();
  5380. Doo::loadModel ( 'client' );
  5381. $client = new client ();
  5382. Doo::loadModel ( 'eMailList' );
  5383. $eMailList = new eMailList ();
  5384. Doo::loadModel ( 'company' );
  5385. $company = new company ();
  5386. $tagCondition = "";
  5387. $tagArray = array ();
  5388. foreach ( $tagId as $value ) {
  5389. array_push ( $tagArray, " tag like '%" . $value . "%' " );
  5390. }
  5391. if (! empty ( $tagArray ))
  5392. $tagCondition = ' and (' . implode ( " or ", $tagArray ) . ')';
  5393. $clientList = $tagClient->find ( array (
  5394. 'select' => 'client',
  5395. 'where' => 'sid=' . $this->staff [0] ['sid'] . $tagCondition,
  5396. 'asArray' => true
  5397. ) );
  5398. $clientArray = array ();
  5399. foreach ( $clientList as $value ) {
  5400. array_push ( $clientArray, $value ['client'] );
  5401. }
  5402. $clientEmailList = array ();
  5403. if (! empty ( $clientArray ))
  5404. $clientEmailList = $client->find ( array (
  5405. 'select' => 'email,cid,nicename as clientname,companyname',
  5406. 'where' => 'cid in (' . implode ( ",", $clientArray ) . ')',
  5407. 'asArray' => true
  5408. ) );
  5409. //
  5410. if ($stype == 2) {
  5411. // 获取性质相关数据
  5412. $cidList = '';
  5413. if ($natureNULL == '') {
  5414. $nD = array ();
  5415. foreach ( $nature as $key => $value ) {
  5416. array_push ( $nD, ' nature like "' . $value . '"' );
  5417. // $nD=' nature like "'.$value.'"';
  5418. }
  5419. $nD = implode ( ' or ', $nD );
  5420. $companycid = $company->find ( array (
  5421. 'select' => 'cid',
  5422. 'where' => $nD,
  5423. 'asArray' => true
  5424. ) );
  5425. $cidList = array ();
  5426. foreach ( $companycid as $key => $value ) {
  5427. array_push ( $cidList, $value ['cid'] );
  5428. }
  5429. $cidList = implode ( ',', $cidList );
  5430. if (! empty ( $cidList ))
  5431. $cidList = ' and companyid in (' . $cidList . ')';
  5432. else
  5433. $cidList = '';
  5434. }
  5435. // 'select'=>'email,cid,nicename as clientname,companyname,district'
  5436. $clientEmailList = $client->find ( array (
  5437. 'select' => 'email,cid,nicename as clientname,companyname,district',
  5438. 'where' => 'district like "' . $did . ',%" ' . $cidList,
  5439. 'asArray' => true
  5440. ) );
  5441. }
  5442. // ;datediff(curdate(), 'date')>=10
  5443. $eMailJournal->delete ( array (
  5444. 'where' => "datediff(curdate(), date)>=7"
  5445. ) );
  5446. $checkMail = $eMailJournal->find ( array (
  5447. 'where' => 'DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(date)',
  5448. ' groupby' => 'email',
  5449. 'asArray' => true
  5450. ) );
  5451. $emailNameList = $emailArray = $illegalEmail = $sendEmail = array ();
  5452. Doo::db ()->beginTransaction ();
  5453. foreach ( $clientEmailList as $value ) {
  5454. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  5455. if (! empty ( $checkMail )) {
  5456. $falg = true;
  5457. foreach ( $checkMail as $v ) {
  5458. if ($v ['email'] == $value ['email']) {
  5459. $Bdate = strtotime ( $v ['date'] ) + 7 * 24 * 3600;
  5460. if ($Bdate <= time ()) {
  5461. array_push ( $emailArray, $value ['email'] );
  5462. array_push ( $emailNameList, $value );
  5463. $eMailJournal->date = date ( "Y-m-d" );
  5464. $eMailJournal->update ( array (
  5465. 'where' => 'ejid=' . $v ['ejid']
  5466. ) );
  5467. } else {
  5468. array_push ( $sendEmail, $value );
  5469. }
  5470. $falg = false;
  5471. break;
  5472. }
  5473. }
  5474. if ($falg) {
  5475. array_push ( $emailArray, $value ['email'] );
  5476. array_push ( $emailNameList, $value );
  5477. $eMailJournal->clientId = $value ['cid'];
  5478. $eMailJournal->status = 1;
  5479. $eMailJournal->email = $value ['email'];
  5480. $eMailJournal->date = date ( "Y-m-d" );
  5481. // $eMailJournal->insert();
  5482. }
  5483. } else {
  5484. array_push ( $emailArray, $value ['email'] );
  5485. array_push ( $emailNameList, $value );
  5486. $eMailJournal->clientId = $value ['cid'];
  5487. $eMailJournal->status = 1;
  5488. $eMailJournal->email = $value ['email'];
  5489. $eMailJournal->date = date ( "Y-m-d" );
  5490. // $eMailJournal->insert();
  5491. }
  5492. } else {
  5493. array_push ( $illegalEmail, $value );
  5494. }
  5495. }
  5496. Doo::db ()->commit ();
  5497. // echo json_encode($illegalEmail);
  5498. // json_encode(array_slice($illegalEmail,0,100))
  5499. // $kk=gzcompress();
  5500. // $ll=gzuncompress($kk);
  5501. // ."</br>".strlen($kk)."</br>".strlen($ll);die;
  5502. $size = floor ( count ( $emailArray ) / 3 );
  5503. if (! empty ( $emailArray )) {
  5504. if (count ( $emailArray ) < 3) {
  5505. $list = array (
  5506. 0 => $emailArray,
  5507. 1 => array (),
  5508. 2 => array ()
  5509. );
  5510. } else
  5511. $list = array_chunk ( $emailArray, $size );
  5512. } else
  5513. $list = array (
  5514. 0 => array (),
  5515. 1 => array (),
  5516. 2 => array ()
  5517. );
  5518. $emailJson = array ();
  5519. foreach ( $list as $value ) {
  5520. $em = array ();
  5521. foreach ( $value as $v ) {
  5522. array_push ( $em, $v );
  5523. }
  5524. array_push ( $emailJson, $em );
  5525. }
  5526. $size = floor ( count ( $emailNameList ) / 3 );
  5527. if (! empty ( $emailNameList )) {
  5528. if (count ( $emailNameList ) < 3) {
  5529. $list = array (
  5530. 0 => $emailNameList,
  5531. 1 => array (),
  5532. 2 => array ()
  5533. );
  5534. } else
  5535. $list = array_chunk ( $emailNameList, $size );
  5536. } else
  5537. $list = array (
  5538. 0 => array (),
  5539. 1 => array (),
  5540. 2 => array ()
  5541. );
  5542. $emailNameJson = array ();
  5543. foreach ( $list as $value ) {
  5544. $em = array ();
  5545. foreach ( $value as $v ) {
  5546. array_push ( $em, $v );
  5547. }
  5548. array_push ( $emailNameJson, $em );
  5549. }
  5550. //
  5551. $eMailList->date = date ( "Y-m-d" );
  5552. $eMailList->clientEmail = base64_encode ( gzcompress ( json_encode ( $emailJson [0] ) ) );
  5553. $eMailList->clientEmail2 = base64_encode ( gzcompress ( json_encode ( $emailJson [1] ) ) );
  5554. $eMailList->clientEmail3 = base64_encode ( gzcompress ( json_encode ( $emailJson [2] ) ) );
  5555. $eMailList->clientName = base64_encode ( gzcompress ( json_encode ( $emailNameJson [0] ) ) );
  5556. $eMailList->clientName2 = base64_encode ( gzcompress ( json_encode ( $emailNameJson [1] ) ) );
  5557. $eMailList->clientName3 = base64_encode ( gzcompress ( json_encode ( $emailNameJson [2] ) ) );
  5558. $eMailList->illegalEmail = json_encode ( array_slice ( $illegalEmail, 0, 100 ) ); // json_encode($illegalEmail);
  5559. $eMailList->sendEmail = json_encode ( $sendEmail );
  5560. $eMailList->etid = $etid;
  5561. $eMailList->templateName = $smartcostMail;
  5562. $eMailList->eTitle = $title;
  5563. $eMailList->html = $html;
  5564. $eMailList->content = $content;
  5565. $eMailList->info = $info;
  5566. if (! empty ( $annexName ))
  5567. $eMailList->annex = $annexHtml;
  5568. $eMailList->annexName = $annexName;
  5569. $eMailList->staffId = $this->staff [0] ['sid'];
  5570. $eMailList->staffName = $this->staff [0] ['username'];
  5571. if ($stype == 1)
  5572. $eMailList->tag = implode ( ",", $tagId );
  5573. if ($stype == 2) {
  5574. $eMailList->districtId = $did;
  5575. $eMailList->nature = implode ( ",", $nature );
  5576. }
  5577. $eMailList->insert ();
  5578. // 创建邮件地址
  5579. // 'http://sendcloud.sohu.com/webapi/list_member.add.json';
  5580. // print_r($emailJson);
  5581. // die;
  5582. return "/eMailList";
  5583. }
  5584. return "/eMailTask";
  5585. }
  5586. function eMailList() {
  5587. Doo::loadModel ( 'eMailList' );
  5588. $eMailList = new eMailList ();
  5589. Doo::loadModel ( 'tag' );
  5590. $tag = new tag ();
  5591. $mailList = $eMailList->find ( array (
  5592. 'where' => 'staffId=' . $this->staff [0] ['sid'],
  5593. 'desc' => 'elid',
  5594. 'asArray' => true
  5595. ) );
  5596. foreach ( $mailList as $key => $value ) {
  5597. $mailList [$key] ['clientName2'] = $mailList [$key] ['clientName3'] = array ();
  5598. $mailList [$key] ['clientName'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName'] ) ), true );
  5599. if (! empty ( $value ['clientName2'] ))
  5600. $mailList [$key] ['clientName2'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName2'] ) ), true );
  5601. if (! empty ( $value ['clientName3'] ))
  5602. $mailList [$key] ['clientName3'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName3'] ) ), true );
  5603. $mailList [$key] ['illegalEmail'] = json_decode ( $value ['illegalEmail'], true );
  5604. $mailList [$key] ['sendEmail'] = json_decode ( $value ['sendEmail'], true );
  5605. $mailList [$key] ['clientCount'] = count ( $mailList [$key] ['clientName'] ) + count ( $mailList [$key] ['clientName2'] ) + count ( $mailList [$key] ['clientName3'] );
  5606. $mailList [$key] ['tag'] = array ();
  5607. if (! empty ( $value ['tag'] ))
  5608. $mailList [$key] ['tag'] = $tag->find ( array (
  5609. 'where' => 'tid in ( ' . $value ['tag'] . ') ',
  5610. 'asArray' => true
  5611. ) );
  5612. }
  5613. $data ['mailList'] = $mailList;
  5614. $data ['memu'] = "eMailTask";
  5615. $data ['staff'] = $this->staff;
  5616. $data ['mailMemu'] = 'eMailList';
  5617. $this->render ( "/mail_list", $data );
  5618. }
  5619. function showEmailContent() {
  5620. $elid = isset ( $this->params ['elid'] ) ? $this->params ['elid'] : 0;
  5621. Doo::loadModel ( 'eMailList' );
  5622. $eMList = new eMailList ();
  5623. $isSend = $eMList->getOne ( array (
  5624. 'where' => 'elid =' . $elid . '',
  5625. 'asArray' => true
  5626. ) );
  5627. echo htmlspecialchars ( $isSend ['content'] );
  5628. }
  5629. function postEmail() {
  5630. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  5631. $elid = isset ( $this->params ['elid'] ) ? $this->params ['elid'] : 0;
  5632. $send = isset ( $this->params ['send'] ) ? $this->params ['send'] : 0;
  5633. Doo::loadModel ( 'eMailList' );
  5634. $eMList = new eMailList ();
  5635. if (! empty ( $elid )) {
  5636. $isSend = $eMList->getOne ( array (
  5637. 'select' => 'send' . $send,
  5638. 'where' => 'elid =' . $elid . ' and status=0 and send' . $send . '=1',
  5639. 'asArray' => true
  5640. ) );
  5641. if (! empty ( $isSend ))
  5642. die ( '这批邮件已经发送' );
  5643. if ($send == 1)
  5644. $send = '';
  5645. $eMailList = $eMList->getOne ( array (
  5646. 'select' => 'eTitle,staffName,clientName' . $send . ' as clientName,clientEmail' . $send . ' as clientEmail,annex,info,content,templateName',
  5647. 'where' => 'elid =' . $elid . ' and status=0',
  5648. 'asArray' => true
  5649. ) );
  5650. if ($send == "")
  5651. $send = 1;
  5652. $sql = "update `CLD_eMailList` set send" . $send . "='1' where elid = '" . $elid . "'";
  5653. Doo::db ()->query ( $sql );
  5654. $isSend = $eMList->getOne ( array (
  5655. 'where' => 'elid =' . $elid . ' and status=0 and send1=1 and send2=1 and send3=1',
  5656. 'asArray' => true
  5657. ) );
  5658. if (! empty ( $isSend )) {
  5659. $sql = "update `CLD_eMailList` set status='2' where elid = '" . $elid . "'";
  5660. Doo::db ()->query ( $sql );
  5661. }
  5662. $toFormatMail = array ();
  5663. $sub = array ();
  5664. // file_put_contents("test.txt", "This is another something.<br/>", FILE_APPEND);
  5665. // sleep(4);
  5666. // die;
  5667. $toMail = json_decode ( gzuncompress ( base64_decode ( $eMailList ['clientEmail'] ) ), true );
  5668. // $toMailCount=count($toMail);
  5669. $subMail = json_decode ( gzuncompress ( base64_decode ( $eMailList ['clientName'] ) ), true );
  5670. $chunkMail = array_chunk ( $toMail, 80 );
  5671. $chunkSubMail = array_chunk ( $subMail, 80 );
  5672. $vii = 0;
  5673. foreach ( $chunkMail as $key => $value ) {
  5674. $l = $s = $c = $i = $cate = $con = $annex = array ();
  5675. $toFormatMail ['to'] = $value;
  5676. $cn = $chunkSubMail [$key];
  5677. foreach ( $cn as $v ) {
  5678. array_push ( $l, $eMailList ['eTitle'] );
  5679. array_push ( $s, $eMailList ['staffName'] );
  5680. array_push ( $c, $v ['clientname'] );
  5681. array_push ( $annex, $eMailList ['annex'] );
  5682. array_push ( $i, $eMailList ['info'] );
  5683. // array_push($con, $eMailList['content']);
  5684. array_push ( $cate, $this->staff [0] ['category'] );
  5685. }
  5686. $sub ['%eTitle%'] = $l;
  5687. $sub ['%staffName%'] = $s;
  5688. $sub ['%clientName%'] = $c;
  5689. $sub ['%category%'] = $cate;
  5690. $sub ['%info%'] = $i;
  5691. // $sub['%content%']=$con;
  5692. $sub ['%annex%'] = $annex;
  5693. $toFormatMail ['sub'] = $sub;
  5694. $url = 'http://sendcloud.sohu.com/webapi/mail.send_template.xml';
  5695. $param = array (
  5696. 'api_user' => 'cldmail',
  5697. 'api_key' => 'cDO1GjtY1seH',
  5698. 'template_invoke_name' => $eMailList ['templateName'],
  5699. 'from' => $this->staff [0] ['email'],
  5700. 'fromname' => '纵横' . $eMailList ['staffName'],
  5701. 'subject' => $eMailList ['eTitle'],
  5702. 'substitution_vars' => json_encode ( $toFormatMail )
  5703. );
  5704. $post_data = http_build_query ( $param );
  5705. $ch = curl_init ();
  5706. curl_setopt ( $ch, CURLOPT_POST, 1 );
  5707. curl_setopt ( $ch, CURLOPT_URL, $url );
  5708. curl_setopt ( $ch, CURLOPT_HEADER, false ); // 设定是否输出页面内容
  5709. curl_setopt ( $ch, CURLOPT_NOBODY, false );
  5710. curl_setopt ( $ch, CURLOPT_POSTFIELDS, $post_data );
  5711. $result = curl_exec ( $ch );
  5712. curl_close ( $ch );
  5713. /*
  5714. * if($result=='success'){ $eM=new eMailList(); $eM->status='2'; $eM->update(array('where'=>'elid=?','param'=>array($elid))); }
  5715. */
  5716. }
  5717. // die;
  5718. return '/eMailList';
  5719. }
  5720. }
  5721. function a() {
  5722. $substitution_vars = $this->get_args ( 'substitution_vars' );
  5723. file_put_contents ( DOO::conf ()->SITE_PATH . 'upload/' . "_" . time () . "_" . rand ( 100, 999 ) . ".log", $substitution_vars );
  5724. }
  5725. function deleteEmail() {
  5726. $elid = isset ( $this->params ['elid'] ) ? $this->params ['elid'] : 0;
  5727. if (! empty ( $elid )) {
  5728. $sql = "DELETE FROM `CLD_eMailList` where elid = '" . $elid . "'";
  5729. Doo::db ()->query ( $sql );
  5730. return '/eMailList';
  5731. }
  5732. }
  5733. /**
  5734. * 发送post请求
  5735. * @param string $url 请求地址
  5736. * @param array $post_data post键值对数据
  5737. * @return string
  5738. */
  5739. function sendPost($url, $post_data) {
  5740. $postdata = http_build_query ( $post_data );
  5741. // X-Amzn-Authorization: AWS3 AWSAccessKeyId=AKIAIDSE5VYNX5ERJHXQ,Signature=lBP67vCvGlDMBQ=dofZxg8E8SUEXAMPLE,Algorithm=HmacSHA256,SignedHeaders=qG1BdSh9QyYPlWLnjqvjDXjyPdFjl7fUSkfs0Hk2
  5742. $options = array (
  5743. 'http' => array (
  5744. 'method' => 'POST',
  5745. 'header' => '
  5746. Content-Type: application/x-www-form-urlencoded
  5747. ',
  5748. 'content' => $postdata,
  5749. 'timeout' => 15 * 60
  5750. )
  5751. ); // 超时时间(单位:s)
  5752. $context = stream_context_create ( $options );
  5753. $result = file_get_contents ( $url, false, $context );
  5754. return $result;
  5755. }
  5756. function avatar() {
  5757. $result = array ();
  5758. $result ['success'] = false;
  5759. $successNum = 0;
  5760. // 定义一个变量用以储存当前头像的序号
  5761. $avatarNumber = 1;
  5762. $i = 0;
  5763. $msg = '';
  5764. // 上传目录
  5765. $dir = DOO::conf ()->SITE_PATH . "global/avatar";
  5766. // 遍历所有文件域
  5767. while ( list ( $key, $val ) = each ( $_FILES ) ) {
  5768. if ($_FILES [$key] ['error'] > 0)
  5769. $msg .= $_FILES [$key] ['error'];
  5770. else {
  5771. $fileName = 'avatar_' . $this->staff [0] ['sid'];
  5772. // 原始图片(file 域的名称:__source,如果客户端定义可以上传的话,可在此处理)。
  5773. if ($key == '__source') { // 当前头像基于原图的初始化参数,用于修改头像时保证界面的视图跟保存头像时一致。帮助提升用户体验度。修改头像时设置默认加载的原图的url为此图片的url+该参数即可。
  5774. $initParams = $_POST ["__initParams"];
  5775. $virtualPath = $dir . "/" . $fileName . "_" . $avatarNumber . ".jpg";
  5776. $result ['sourceUrl'] = '/' . $virtualPath . $initParams;
  5777. move_uploaded_file ( $_FILES [$key] ["tmp_name"], $virtualPath );
  5778. $successNum ++;
  5779. } else if (strpos ( $key, '__avatar' ) === 0) { // 头像图片(file 域的名称:__avatar1,2,3...)。
  5780. $virtualPath = $dir . "/" . $fileName . "_" . $avatarNumber . ".jpg";
  5781. $result ['avatarUrls'] [$i] = '/' . $virtualPath;
  5782. move_uploaded_file ( $_FILES [$key] ["tmp_name"], $virtualPath );
  5783. $avatarNumber ++;
  5784. $successNum ++;
  5785. $i ++;
  5786. }
  5787. }
  5788. }
  5789. $result ['msg'] = $msg;
  5790. if ($successNum > 0)
  5791. $result ['success'] = true;
  5792. // 返回图片的保存结果(返回内容为json字符串)
  5793. Doo::loadModel ( 'staff' );
  5794. $staff = new staff ();
  5795. $staff->sid = $this->staff [0] ['sid'];
  5796. $staff->avatar = "/global/avatar/" . $fileName;
  5797. $staff->update ();
  5798. echo json_encode ( $result );
  5799. }
  5800. function lockUpload() {
  5801. // move_uploaded_file($_FILES['Filedata']['tmp_name'], "/upload/".$_FILES['Filedata']['name']);
  5802. if (isset ( $_FILES ['Filedata'] ['name'] )) {
  5803. $file = $_FILES ['Filedata'] ['tmp_name'];
  5804. $error = false;
  5805. if (! is_uploaded_file ( $file )) {
  5806. $error = '400 Bad Request';
  5807. }
  5808. if ($error) {
  5809. header ( 'HTTP/1.0 ' . $error );
  5810. die ( 'Error ' . $error );
  5811. } else {
  5812. include (DOO::conf ()->SITE_PATH . 'protected/plugin/io.han.php');
  5813. $this->IoHandler = new IoHandler ();
  5814. $pics = explode ( '.', $_FILES ['Filedata'] ['name'] );
  5815. // $filedir=$_POST['time'];
  5816. // 调用定义物理路径
  5817. $t = DOO::conf ()->SITE_PATH . "upload/";
  5818. $this->IoHandler->MakeDir ( $t );
  5819. $filename = $this->_GetFileEXT ( $_FILES ['Filedata'] ['name'] );
  5820. if ($filename != 'xlsx')
  5821. return "";
  5822. // $upload_dir = $t."/".time().rand(10,100).".".$filename;
  5823. $upload_file = iconv ( "UTF-8", "GB2312", $_FILES ["Filedata"] ["name"] );
  5824. $upload_dir = $t . "/" . $upload_file;
  5825. $k = move_uploaded_file ( $file, $upload_dir );
  5826. if ($k) {
  5827. // "series/".$filedir."/".
  5828. $m = round ( $_FILES ['Filedata'] ['size'] / 1024 / 1024, 2 );
  5829. echo $pics [0] . "." . $filename . "#" . $m . "#" . $_FILES ['Filedata'] ['size'];
  5830. }
  5831. }
  5832. }
  5833. }
  5834. function getAuthentication() {
  5835. }
  5836. function loadCVS() {
  5837. Doo::loadModel ( 'longle' );
  5838. $longle = new longle ();
  5839. $list = $longle->find ( array (
  5840. 'select' => 'key_num',
  5841. 'asArray' => TRUE
  5842. ) );
  5843. $file = fopen ( DOO::conf ()->SITE_PATH . "upload/key2.csv", 'r' );
  5844. while ( $data = fgetcsv ( $file ) ) {
  5845. $goods_list [$data [0]] = $data [1];
  5846. }
  5847. fclose ( $file );
  5848. $sqlArray = array ();
  5849. $sql = 'UPDATE CLD_longle SET SerialNumber = CASE key_num ';
  5850. foreach ( $list as $key => $value ) {
  5851. if (array_key_exists ( $value ['key_num'], $goods_list )) {
  5852. // echo $value['key_num'].'-'.$goods_list[$value['key_num']].'<br/>';
  5853. // $longle->SerialNumber=$goods_list[$value['key_num']];
  5854. // $longle->update(array('where'=>'key_num="'.$value['key_num'].'"'));
  5855. $sql .= ' WHEN "' . $value ['key_num'] . '" THEN "' . $goods_list [$value ['key_num']] . '" ';
  5856. array_push ( $sqlArray, '"' . $value ['key_num'] . '"' );
  5857. unset ( $goods_list [$value ['key_num']] );
  5858. }
  5859. }
  5860. $sql .= 'END WHERE key_num IN (' . implode ( ',', $sqlArray ) . ')';
  5861. echo $sql . '<br/>--------------------------------<br/>';
  5862. foreach ( $goods_list as $key => $value ) {
  5863. echo $key . ',' . $value . '<br/>';
  5864. }
  5865. }
  5866. private function getRandChar($length) {
  5867. $str = null;
  5868. $strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
  5869. $max = strlen ( $strPol ) - 1;
  5870. for($i = 0; $i < $length; $i ++) {
  5871. $str .= $strPol [rand ( 0, $max )]; // rand($min,$max)生成介于min和max两个数之间的一个随机整数
  5872. }
  5873. return $str;
  5874. }
  5875. // private function getReceiptCount(){
  5876. // $status=2;
  5877. // $year=date('Y');
  5878. // Doo::loadModel('receipt');
  5879. // $receipt=new receipt();
  5880. // $dateCondition=" and Year(date) =".$year;
  5881. // $approvalCondition=' and nowStaff like "%'.$this->staff[0]['sid'].'%" ';
  5882. // $receiptList=$receipt->find(array('where'=>' status='.$status.$dateCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  5883. // return count($receiptList);
  5884. // }
  5885. // private function getExeCount(){
  5886. // Doo::loadModel('receipt');
  5887. // $receipt=new receipt();
  5888. // $receiptList=$receipt->find(array('where'=>'(executeCopy like \'%["'.$this->staff[0]['sid'].'%\' and executeStaff NOT LIKE \'%'.$this->staff[0]['sid'].'%\' ) and (status=1 or status=6)','desc'=>'rid','asArray'=>true));
  5889. // return count($receiptList);
  5890. // }
  5891. /**
  5892. * 格式化excel文件为数组
  5893. * @param unknown_type $file_url
  5894. * @param unknown_type $mcid
  5895. */
  5896. function _format_excel_to_array($file_url = "") {
  5897. if (! file_exists ( $file_url ))
  5898. return array ();
  5899. Doo::loadClass ( 'PHPExcel' );
  5900. $PHPExcel = new PHPExcel ();
  5901. $PHPReader = new PHPExcel_Reader_Excel2007 ();
  5902. if (! $PHPReader->canRead ( $file_url )) {
  5903. $PHPReader = new PHPExcel_Reader_Excel5 ();
  5904. if (! $PHPReader->canRead ( $file_url )) {
  5905. echo 'no Excel';
  5906. return;
  5907. }
  5908. }
  5909. $PHPExcel = $PHPReader->load ( $file_url );
  5910. /**
  5911. * 读取excel文件中的第一个工作表
  5912. */
  5913. $currentSheet = $PHPExcel->getSheet ( 0 );
  5914. /**
  5915. * 取得最大的列号
  5916. */
  5917. $allColumn = $currentSheet->getHighestColumn ();
  5918. /**
  5919. * 取得一共有多少行
  5920. */
  5921. $allRow = $currentSheet->getHighestRow ();
  5922. $excel_array = array ();
  5923. for($currentRow = 2; $currentRow <= $allRow; $currentRow ++) {
  5924. $excel_column = array ();
  5925. // 后期改进
  5926. if ($allColumn == 'AM')
  5927. $allColumn = 'Z';
  5928. /**
  5929. * 从第A列开始输出
  5930. */
  5931. for($currentColumn = 'A'; $currentColumn <= $allColumn; $currentColumn ++) {
  5932. $val = $currentSheet->getCellByColumnAndRow ( ord ( $currentColumn ) - 65, $currentRow )->getValue ();
  5933. /**
  5934. * ord()将字符转为十进制数 iconv ( 'utf-8', 'gb2312',
  5935. */
  5936. $val = "'" . addslashes ( $val ) . "'";
  5937. if ($currentColumn == 'A')
  5938. $excel_column ['key_num'] = $val;
  5939. elseif ($currentColumn == 'C')
  5940. $excel_column ['product'] = $val;
  5941. elseif ($currentColumn == 'D') {
  5942. $val = str_replace ( "'", "", $val );
  5943. $excel_column ['make_day'] = $this->excelTime ( $val );
  5944. } elseif ($currentColumn == 'E') {
  5945. $val = str_replace ( "'", "", $val );
  5946. $excel_column ['alloted_time'] = $this->excelTime ( $val );
  5947. } elseif ($currentColumn == 'F') {
  5948. $val = str_replace ( "'", "", $val );
  5949. $excel_column ['version'] = $val;
  5950. } elseif ($currentColumn == 'B') {
  5951. $val = str_replace ( "'", "", $val );
  5952. $excel_column ['SerialNumber'] = $val;
  5953. }
  5954. }
  5955. array_push ( $excel_array, $excel_column );
  5956. }
  5957. return $excel_array;
  5958. }
  5959. function excelTime($date, $time = false) {
  5960. if (function_exists ( 'GregorianToJD' )) {
  5961. if (is_numeric ( $date )) {
  5962. $jd = GregorianToJD ( 1, 1, 1970 );
  5963. $gregorian = JDToGregorian ( $jd + intval ( $date ) - 25569 );
  5964. $date = explode ( '/', $gregorian );
  5965. $date_str = str_pad ( $date [2], 4, '0', STR_PAD_LEFT ) . "-" . str_pad ( $date [0], 2, '0', STR_PAD_LEFT ) . "-" . str_pad ( $date [1], 2, '0', STR_PAD_LEFT ) . ($time ? " 00:00:00" : '');
  5966. return $date_str;
  5967. }
  5968. } else {
  5969. $date = $date > 25568 ? $date + 1 : 25569;
  5970. /* There was a bug if Converting date before 1-1-1970 (tstamp 0) */
  5971. $ofs = (70 * 365 + 17 + 2) * 86400;
  5972. $date = date ( "Y-m-d", ($date * 86400) - $ofs ) . ($time ? " 00:00:00" : '');
  5973. }
  5974. return $date;
  5975. }
  5976. function _GetFileEXT($filename) {
  5977. $pics = explode ( '.', $filename );
  5978. $num = count ( $pics );
  5979. return $pics [$num - 1];
  5980. }
  5981. /**
  5982. * 获取get或者POST值
  5983. * @param string $name 属性名称
  5984. * @return fixed 值
  5985. */
  5986. function get_args($name) {
  5987. if (isset ( $_GET [$name] )) {
  5988. if (is_array ( $_GET [$name] ))
  5989. return $_GET [$name];
  5990. else {
  5991. return addslashes ( $_GET [$name] );
  5992. }
  5993. } elseif (isset ( $_POST [$name] )) {
  5994. if (is_array ( $_POST [$name] ))
  5995. return $_POST [$name];
  5996. else {
  5997. return addslashes ( $_POST [$name] );
  5998. }
  5999. } else {
  6000. return false;
  6001. }
  6002. }
  6003. function get_previous($on_page = 1) {
  6004. return $on_page != 0 ? $on_page - 1 : $on_page;
  6005. }
  6006. /**
  6007. * 获得分页数据
  6008. * @param unknown_type $table
  6009. * @param unknown_type $condition
  6010. * @param unknown_type $on_page
  6011. * @param unknown_type $page_size
  6012. */
  6013. function get_Tpage($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $tagSQL) {
  6014. $page_c = "";
  6015. $page ['previous'] = $this->get_previous ( $on_page );
  6016. $page ['on_page'] = $on_page;
  6017. $total_count = $this->get_table_Tcount ( $table, $condition, $tagSQL );
  6018. $total = intval ( $total_count / $page_size );
  6019. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  6020. $page ['total_data'] = $total_count;
  6021. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  6022. $i = 1;
  6023. $page_max = 1;
  6024. if ($on_page > 10) {
  6025. $page_max = intval ( $on_page / 10 ) + 1;
  6026. $i = intval ( $on_page / 10 ) * 10 - 1;
  6027. }
  6028. $page ['page'] = $page_c;
  6029. $page ['lower'] = (-- $on_page) * $page_size;
  6030. return $page;
  6031. }
  6032. /**
  6033. * 获得分页数据
  6034. * @param unknown_type $table
  6035. * @param unknown_type $condition
  6036. * @param unknown_type $on_page
  6037. * @param unknown_type $page_size
  6038. */
  6039. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page", $staffid = "", $search, $tooltip, $cateid, $tagSQL) {
  6040. $page_c = "";
  6041. $page ['previous'] = $this->get_previous ( $on_page );
  6042. $page ['on_page'] = $on_page;
  6043. $total_count = $this->get_table_count ( $table, $condition, $staffid, $search, $tooltip, $cateid, $tagSQL );
  6044. $total = intval ( $total_count / $page_size );
  6045. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  6046. $page ['total_data'] = $total_count;
  6047. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  6048. $i = 1;
  6049. $page_max = 1;
  6050. if ($on_page > 10) {
  6051. $page_max = intval ( $on_page / 10 ) + 1;
  6052. $i = intval ( $on_page / 10 ) * 10 - 1;
  6053. }
  6054. for(; $i <= $page ['total_page']; $i ++) {
  6055. if ($i == $on_page) {
  6056. if ($other == "page")
  6057. $page_c .= '<a href="javascript:void(0);" class="current">' . $i . '</a>';
  6058. else
  6059. $page_c .= '&nbsp;<span class="current">' . $i . '</span>&nbsp;';
  6060. } else if ($other == "page")
  6061. $page_c .= '<a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a>';
  6062. else
  6063. $page_c .= '&nbsp;<a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a>&nbsp;';
  6064. if ($i == (10 * $page_max))
  6065. break;
  6066. }
  6067. $page ['page'] = $page_c;
  6068. $page ['lower'] = (-- $on_page) * $page_size;
  6069. return $page;
  6070. }
  6071. /**
  6072. * 获取总页数
  6073. * @param unknown_type $table
  6074. * @param unknown_type $condition
  6075. */
  6076. public function get_table_Tcount($table = "", $condition = "", $tagSQL) {
  6077. if ($tagSQL)
  6078. $sql = "select count(*) as count from CLD_tagCompanyNexus as a left join CLD_company as b on (a.company=b.cid ) where " . $condition;
  6079. else
  6080. $sql = "select count(*) as count from CLD_company where " . $condition;
  6081. $query = Doo::db ()->query ( $sql );
  6082. $result = $query->fetch ();
  6083. return $result ['count'];
  6084. }
  6085. /**
  6086. * 获取总页数
  6087. * @param unknown_type $table
  6088. * @param unknown_type $condition
  6089. */
  6090. public function get_table_count($table = "", $condition = "", $staffid = "", $search, $tooltip, $cateid, $tagSQL) {
  6091. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  6092. // echo $staffid;die;
  6093. //
  6094. if (! empty ( $staffid )) {
  6095. // $staffid="and a.sid= '".$staffid."'"; " . $table . " as a left join on (a.cid=b.cid ".$staffid.")
  6096. $sql = "select count(*) as count from CLD_client as b left join CLD_tag_client as c on (b.cid=c.client) where 1 " . $condition;
  6097. } else {
  6098. if (strlen ( $condition ) == 1 || empty ( $condition ))
  6099. $sql = "select count(*) as count from CLD_client as a " . $condition;
  6100. else
  6101. $sql = "select count(*) as count from CLD_client as a left join CLD_tag_client as c on (a.cid=c.client) where 1 " . $condition;
  6102. }
  6103. if (! empty ( $search ))
  6104. $sql = "select count(*) as count from CLD_client as a where 1 " . $condition;
  6105. if (! empty ( $tooltip )) {
  6106. $condition = str_replace ( "a.", "c.", $condition );
  6107. if ($tagSQL)
  6108. $sql = "select count(*) as count from CLD_C_tooltip as a left join CLD_tag_client as c on (a.cid=c.client) left join CLD_client as b on (c.client=b.cid ) where a.name like '%" . $tooltip . "%' and a.cateid = " . $cateid . " " . $condition;
  6109. else
  6110. $sql = "select count(*) as count from CLD_C_tooltip as a left join CLD_client as b on (a.cid=b.cid ) where a.name like '%" . $tooltip . "%' and a.cateid = " . $cateid . " " . $condition;
  6111. }
  6112. // echo $sql;
  6113. $query = Doo::db ()->query ( $sql );
  6114. $result = $query->fetch ();
  6115. return $result ['count'];
  6116. }
  6117. }
  6118. ?>