MainController.php 201 KB

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