MainController.php 258 KB

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