MainController.php 199 KB

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