MainController.php 197 KB

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