MainController.php 197 KB

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