MainController.php 241 KB

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