MainController.php 258 KB

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