MainController.php 258 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724
  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. );
  3836. echo json_encode ( $clientHtml );
  3837. }
  3838. function ajaxGetClientInfo() {
  3839. $clientname = $this->get_args ( 'client' )&&is_numeric($this->get_args ( 'client' )) ? $this->get_args ( 'client' ) : "";
  3840. if ($clientname == "") {
  3841. echo json_encode ( array (
  3842. "success" => false
  3843. ) );
  3844. die ();
  3845. }
  3846. Doo::loadModel ( 'client' );
  3847. Doo::loadModel ( 'client_staff' );
  3848. Doo::loadModel ( 'longle' );
  3849. Doo::loadModel ( 'company' );
  3850. Doo::loadModel ( 'service_log' );
  3851. Doo::loadModel ( "district" );
  3852. $district = new district ();
  3853. $service_log = new service_log ();
  3854. $company = new company ();
  3855. $longle = new longle ();
  3856. $client = new client ();
  3857. $client_staff = new client_staff ();
  3858. $clientInfo = $client->getOne ( array (
  3859. "where" => ' cid = "' . $clientname . '"',
  3860. 'asArray' => TRUE
  3861. ) );
  3862. if (empty ( $clientInfo )) {
  3863. echo json_encode ( array (
  3864. "success" => false,
  3865. 'html' => ''
  3866. ) );
  3867. die ();
  3868. }
  3869. // 获取锁
  3870. $longleInfo = $longle->getLongleByClientid ( $clientInfo ['cid'] );
  3871. $k = "";
  3872. foreach ( $longleInfo as $key => $value ) {
  3873. if ($value ['status'] == 6 || $value ['status'] == 7)
  3874. $k .= '<a href="javascript:void(0)" class="disenable" onclick="getLock(' . $value ['lid'] . ')" >' . $value ['key_num'] . '/' . $value ['product'] . '/' . $value ['statusT'] . '</a>&nbsp; ';
  3875. else
  3876. $k .= '<a href="javascript:void(0)" onclick="getLock(' . $value ['lid'] . ')" >' . $value ['key_num'] . '/' . $value ['product'] . '/' . $value ['statusT'] . '</a>&nbsp; ';
  3877. }
  3878. // 获取办事人
  3879. $staffInfo = $client_staff->getClientByCid ( $clientInfo ['cid'] );
  3880. $b = "";
  3881. if (! empty ( $staffInfo ))
  3882. $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>';
  3883. // 获取公司信息
  3884. $companyInfo = $company->getCompanyByCid ( $clientInfo ['companyid'] );
  3885. $serviceLog = $service_log->getServiceByClientid ( $clientInfo ['cid'] );
  3886. $local = $district->getbyidlist ( $clientInfo ['district'] );
  3887. if (! isset ( $local [1] ))
  3888. $local [1] ['name'] = "";
  3889. if (! isset ( $local [2] ))
  3890. $local [2] ['name'] = "";
  3891. $m = "";
  3892. if (! empty ( $companyInfo )) {
  3893. $m = '<div class="contactPanel">
  3894. <table>
  3895. <tbody>
  3896. <tr><th>单位全称</th><td colspan="3"><a href="javascript:void(0)" onclick="getCompany(\'' . $companyInfo [0] ['cid'] . '\')">' . $companyInfo [0] ['companyname'] . '</a></td></tr>
  3897. <tr><th>单位主页</th><td colspan="3">' . $clientInfo ['webservice'] . '</td></tr>
  3898. <tr><th>客户地区</th><td>' . $local [0] ['name'] . ',' . $local [1] ['name'] . ',' . $local [2] ['name'] . '</td><th>部门/职位</th><td>' . $clientInfo ['department'] . '/' . $clientInfo ['position'] . '</td></tr>
  3899. <tr><th>客户传真</th><td>' . $clientInfo ['fax'] . '</td><th>办公室</th><td>' . $clientInfo ['office'] . '</td></tr>
  3900. <tr><th>客户地址</th><td colspan="3">' . $clientInfo ['address'] . '</td></tr>
  3901. <tr><th>客户乘车</th><td colspan="3">' . $clientInfo ['ride'] . '</td></tr>
  3902. <tr><th>客户地标</th><td colspan="3">' . $clientInfo ['landmarks'] . '</td></tr>
  3903. <tr><th>客户住宿</th><td colspan="3">' . $clientInfo ['stay'] . '</td></tr>
  3904. </tbody></table>
  3905. </div>';
  3906. }
  3907. $u = "";
  3908. $order = array (
  3909. "\r\n",
  3910. "\n",
  3911. "\r"
  3912. );
  3913. $replace = '</br>';
  3914. foreach ( $serviceLog as $key => $value ) {
  3915. $datetime = explode ( "-", $value ['date'] );
  3916. $u .= '<div class="infoFlowList">
  3917. <div class="dateTitle">
  3918. <em class="month"><span class="num">' . $datetime ['1'] . '</span><span class="text">-' . $datetime ['2'] . '</span></em>
  3919. <span class="year">' . $datetime ['0'] . '</span>
  3920. </div>
  3921. <ul class="flowList">';
  3922. if ($value ['status'] == 1)
  3923. $u .= '<li class="item iconService">上门服务<';
  3924. elseif ($value ['status'] == 2)
  3925. $u .= '<li class="item iconPhone">电话拜访<';
  3926. elseif ($value ['status'] == 3)
  3927. $u .= '<li class="item iconOther">其他<';
  3928. $u .= $value ['category'] . '<a href="javascript:void(0)" onclick="getStaffInfo(\'' . $value ['staffname'] . '\')" >' . $value ['staffname'] . '</a></li>
  3929. <li class="item">
  3930. ' . str_replace ( $order, $replace, $value ['mark'] ) . '
  3931. </li>
  3932. </ul>
  3933. </div>';
  3934. }
  3935. Doo::loadModel ( "tag_client" );
  3936. Doo::loadModel ( "tag" );
  3937. $tag = new tag ();
  3938. $tag_client = new tag_client ();
  3939. $tagId = $tag_client->getTagClientBySCid ( $clientInfo ['cid'], $this->staff [0] ['sid'] );
  3940. $taginfo = $tag->getTagByTidL ( $tagId ['tag'] );
  3941. $taghtml = "";
  3942. foreach ( $taginfo as $key => $value ) {
  3943. $taghtml .= '<span class="contactsTag tagCol-0' . $value ['colorid'] . '">' . $value ['name'] . '</span>';
  3944. }
  3945. $mhtml = "";
  3946. $dhtml = "";
  3947. $yhtml = "";
  3948. for($year = 2020; $year >= 2004; $year --) {
  3949. if (date ( "Y" ) == $year)
  3950. $yhtml .= '<option selected value="' . $year . '">' . $year . '年</option>';
  3951. else
  3952. $yhtml .= '<option value="' . $year . '">' . $year . '年</option>';
  3953. }
  3954. for($month = 1; $month <= 12; $month ++) {
  3955. if (date ( "m" ) == $month)
  3956. $mhtml .= '<option selected value="' . $month . '">' . $month . '月</option>';
  3957. else
  3958. $mhtml .= '<option value="' . $month . '">' . $month . '月</option>';
  3959. }
  3960. for($day = 1; $day <= 31; $day ++) {
  3961. if (date ( "d" ) == $day)
  3962. $dhtml .= '<option selected value="' . $day . '">' . $day . '日</option>';
  3963. else
  3964. $dhtml .= '<option value="' . $day . '">' . $day . '日</option>';
  3965. }
  3966. $clientHtml = array (
  3967. 'html' => '<div class="contactInfo clearfix">
  3968. <div class="contactPanel">
  3969. <h1>' . $b . '<a data-original-title="编辑客户" data-toggle="ctooltip" data-placement="right" href="javascript:clientEdit(' . $clientInfo ['cid'] . ')" class="icon- edit">I</a></h1>
  3970. <table>
  3971. <tbody><tr><th>性别</th><td>' . $clientInfo ['gender'] . '</td><th>昵称</th><td>' . $clientInfo ['nicename'] . '</td></tr>
  3972. <tr><th>手机</th><td>' . $clientInfo ['telephone'] . '</td><th>QQ</th><td>' . $clientInfo ['qq'] . '</td></tr>
  3973. <tr><th>电话</th><td>' . $clientInfo ['phone'] . '</td><th>邮箱</th><td>' . $clientInfo ['email'] . '</td></tr>
  3974. <tr><th>软件锁</th><td colspan="3"><div class="lockContent">' . $k . '</div></td></tr>
  3975. <tr><th>备注</th><td colspan="3">' . $clientInfo ['mark'] . '</td></tr>
  3976. <tr><td colspan="4">
  3977. ' . $taghtml . '
  3978. </td></tr>
  3979. </tbody></table>
  3980. </div>
  3981. ' . $m . '
  3982. </div>
  3983. <div class="lockRecord autoHeightR1" >
  3984. <!--添加记录按钮-->
  3985. <div class="addRecord addRecordButton clearfix" >
  3986. <a href="#" onclick="slideupInfo(this)">+ 打开添加服务记录</a>
  3987. </div>
  3988. <!--添加记录-->
  3989. <div class="addRecord addRecordForm clearfix hide">
  3990. <a onclick="slidedownInfo(this)" class="fR slidedownInfo">- 关闭添加记录</a>
  3991. <form name="lk" action="/addServiceLog" method="post" >
  3992. <div class="control-group">
  3993. <div class="controls">
  3994. <label class="radio inline">
  3995. <input type="radio" name="logstatus" id="status" checked value="2">电话拜访
  3996. </label>
  3997. <label class="radio inline">
  3998. <input type="radio" name="logstatus" id="status" value="1" >上门服务
  3999. </label>
  4000. <label class="radio inline">
  4001. <input type="radio" name="logstatus" id="status" value="3">其他
  4002. </label>
  4003. </div>
  4004. </div>
  4005. <div class="control-group">
  4006. <div class="controls">时间:
  4007. <select name="y" id="y">
  4008. ' . $yhtml . '
  4009. </select>
  4010. <select name="m" id="m">
  4011. ' . $mhtml . '
  4012. </select>
  4013. <select name="d" id="d">
  4014. ' . $dhtml . '
  4015. </select>
  4016. </div>
  4017. </div>
  4018. <link href="' . WEB_SITE_GLOBAL . 'css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
  4019. <!--添加记录-备注-->
  4020. <!--<div class="control-group">
  4021. <div class="controls">
  4022. <select name="date" id="date">
  4023. <option value="2013">2013</option>
  4024. </select>
  4025. </div>
  4026. </div>-->
  4027. <div class="control-group">
  4028. <div class="controls" onclick="slideupInfo()">
  4029. <textarea name="mark" id="mark" style="width:95%" rows="5"></textarea>
  4030. <div class="bsAlert bsWarning"><b>含泪告知:</b>客户记录暂时无法修改!删除!,添加时请谨慎。点击确定添加成功后,信息会立即出现在下方!注意咯,别猛戳‘确定添加’导致重复添加了哦~</div>
  4031. </div>
  4032. </div>
  4033. <div class="control-group">
  4034. <div class="controls">
  4035. <div style="display:inline-block;margin-right:10px"><label><input name="Remind" onclick="reFK()" type="checkbox" value="1"> 添加提醒</label></div>
  4036. <span id="reHL" class="hide">
  4037. <div>
  4038. 限期:
  4039. <input type="date" name="time" id="dtp_input2" value="" class="hide"/>
  4040. </div>
  4041. <div>
  4042. 备注:<input id="remark" name="remark" type="text"></span>
  4043. </div>
  4044. </div>
  4045. <div class="control-group">
  4046. <div class="controls clearfix">
  4047. <input type="button" value="确定添加" id="conSer" onclick="aServiceLog(\'' . $this->staff [0] ['category'] . '\',\'' . $this->staff [0] ['username'] . '\',' . $clientInfo ['cid'] . ')" class="button"></input>
  4048. <div id="load"></div>
  4049. </div>
  4050. </div>
  4051. </div>
  4052. </form>
  4053. </div>
  4054. <!--添加记录按钮-->
  4055. <!--记录列表-->
  4056. <div id="kl"></div>
  4057. ' . $u . '
  4058. <script type="text/javascript">autoFlashHeight();</script> </div>'
  4059. );
  4060. echo json_encode ( $clientHtml );
  4061. }
  4062. function ajaxGetCompanyInfo() {
  4063. }
  4064. function checkClient() {
  4065. $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : "";
  4066. $company = $this->get_args ( 'company' ) ? $this->get_args ( 'company' ) : "";
  4067. if (! empty ( $name )&&! empty ( $company )) {
  4068. Doo::loadModel ( 'client' );
  4069. $client = new client ();
  4070. $clientInfo = $client->getClientByName2 ( $name, $company );
  4071. if (! empty ( $clientInfo ))
  4072. echo json_encode ( array (
  4073. "success" => true
  4074. ) );
  4075. else
  4076. echo json_encode ( array (
  4077. "success" => false
  4078. ) );
  4079. } else {
  4080. echo json_encode ( array (
  4081. "success" => false
  4082. ) );
  4083. }
  4084. }
  4085. function searchClient() {
  4086. $searchDbInforItem = $this->get_args ( 'searchDbInforItem' ) ? $this->get_args ( 'searchDbInforItem' ) : "";
  4087. if (! empty ( $searchDbInforItem )) {
  4088. Doo::loadModel ( 'client' );
  4089. $client = new client ();
  4090. $clientInfo = $client->getClientByName ( $searchDbInforItem );
  4091. echo json_encode ( $clientInfo );
  4092. } else {
  4093. echo json_encode ( array (
  4094. 0 => array (
  4095. 'clientname' => ''
  4096. )
  4097. ) );
  4098. }
  4099. }
  4100. function searchCompany() {
  4101. $searchDbInforItem = $this->get_args ( 'searchDbInforItem' ) ? $this->get_args ( 'searchDbInforItem' ) : "";
  4102. if (! empty ( $searchDbInforItem )) {
  4103. Doo::loadModel ( 'company' );
  4104. $company = new company ();
  4105. $clientInfo = $company->searchCompany ( $searchDbInforItem );
  4106. echo json_encode ( $clientInfo );
  4107. } else {
  4108. echo json_encode ( array (
  4109. 0 => array (
  4110. 'companyname' => '',
  4111. 'local' => ''
  4112. )
  4113. ) );
  4114. }
  4115. }
  4116. function checkCompany() {
  4117. $searchDbInforItem = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : "";
  4118. $searchDbInforItem = explode ( '-', $searchDbInforItem );
  4119. $this->nature ['naturelenght'] = 15;
  4120. Doo::loadModel ( 'district' );
  4121. $district = new district ();
  4122. $d = $district->get_lv ( 1 );
  4123. $html = '<option vlaue="0">请选择</option>';
  4124. foreach ( $d as $key => $value ) {
  4125. $html .= '<option value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  4126. }
  4127. $this->nature ['district'] = $html;
  4128. if (! empty ( $searchDbInforItem )) {
  4129. Doo::loadModel ( 'company' );
  4130. $company = new company ();
  4131. if (! isset ( $searchDbInforItem [1] )) {
  4132. echo json_encode ( array (
  4133. "success" => false,
  4134. 'nature' => $this->nature
  4135. ) );
  4136. die ();
  4137. }
  4138. $clientInfo = $company->getCompanyByName ( $searchDbInforItem [0], $searchDbInforItem [1] );
  4139. if (! empty ( $clientInfo ))
  4140. echo json_encode ( array (
  4141. "success" => true,
  4142. 'data' => $clientInfo
  4143. ) );
  4144. else
  4145. echo json_encode ( array (
  4146. "success" => false,
  4147. 'nature' => $this->nature
  4148. ) );
  4149. } else {
  4150. echo json_encode ( array (
  4151. "success" => false,
  4152. 'nature' => $this->nature
  4153. ) );
  4154. }
  4155. }
  4156. function checkLongle() {
  4157. $searchDbInforItem = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : "";
  4158. $searchDbInforItem = explode ( ' ', $searchDbInforItem );
  4159. if (! empty ( $searchDbInforItem )) {
  4160. Doo::loadModel ( 'longle' );
  4161. $longle = new longle ();
  4162. $clientInfo = $longle->getLongleBykeynum ( $searchDbInforItem [0] );
  4163. if (! empty ( $clientInfo ))
  4164. echo json_encode ( array (
  4165. "success" => true
  4166. ) );
  4167. else
  4168. echo json_encode ( array (
  4169. "success" => false
  4170. ) );
  4171. } else {
  4172. echo json_encode ( array (
  4173. "success" => false
  4174. ) );
  4175. }
  4176. }
  4177. function searchLongle() {
  4178. $searchDbInforItem = $this->get_args ( 'searchDbInforItem' ) ? $this->get_args ( 'searchDbInforItem' ) : "";
  4179. if (! empty ( $searchDbInforItem )) {
  4180. Doo::loadModel ( 'longle' );
  4181. $longle = new longle ();
  4182. $longleInfo = $longle->getLongleBykeynum2 ( $searchDbInforItem );
  4183. echo json_encode ( $longleInfo );
  4184. } else {
  4185. echo json_encode ( array (
  4186. 0 => array (
  4187. 'clientname' => ''
  4188. )
  4189. ) );
  4190. }
  4191. }
  4192. function updateChangeCompany() {
  4193. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4194. $clientID = $this->get_args ( 'clientID' ) ? $this->get_args ( 'clientID' ) : 0;
  4195. $companyname = $this->get_args ( 'companyname' ) ? $this->get_args ( 'companyname' ) : "";
  4196. Doo::loadModel ( 'company' );
  4197. Doo::loadModel ( 'client' );
  4198. $client = new client ();
  4199. $company = new company ();
  4200. $companyname = explode ( "-", $companyname );
  4201. if (isset ( $companyname [1] ))
  4202. $k = $company->getCompanyByName ( $companyname [0], $companyname [1] );
  4203. else
  4204. $k = array ();
  4205. if (! empty ( $cid ) && ! empty ( $k ) && ! empty ( $clientID )) {
  4206. $client->cid = $clientID;
  4207. $client->companyid = $cid;
  4208. $client->companyname = $companyname [0];
  4209. $client->update ();
  4210. } else {
  4211. $local1 = $this->get_args ( 'lv21' ) ? $this->get_args ( 'lv21' ) : 0;
  4212. $local2 = $this->get_args ( 'lv22' ) ? $this->get_args ( 'lv22' ) : 0;
  4213. $local3 = $this->get_args ( 'lv23' ) ? $this->get_args ( 'lv23' ) : 0;
  4214. Doo::loadModel ( 'district' );
  4215. $district = new district ();
  4216. // 更新公司信息
  4217. $lv1 = $district->getbyid ( $local1 );
  4218. $lv2 = $district->getbyid ( $local2 );
  4219. $lv3 = $district->getbyid ( $local3 );
  4220. if (empty ( $local1 ) || empty ( $local2 ))
  4221. return "/";
  4222. if (! empty ( $local1 ) && ! empty ( $local2 ))
  4223. $company->local = $lv1 [0] ['name'] . "," . $lv2 [0] ['name'] . "," . $lv3 [0] ['name'];
  4224. if (! empty ( $local1 ) && ! empty ( $local2 ))
  4225. $company->district = $local1 . "," . $local2 . "," . $local3;
  4226. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  4227. $fax = $this->get_args ( 'fax' ) ? $this->get_args ( 'fax' ) : "";
  4228. $webservice = $this->get_args ( 'webservice' ) ? $this->get_args ( 'webservice' ) : "";
  4229. $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
  4230. $landmarks = $this->get_args ( 'landmarks' ) ? $this->get_args ( 'landmarks' ) : "";
  4231. $stay = $this->get_args ( 'stay' ) ? $this->get_args ( 'stay' ) : "";
  4232. $ride = $this->get_args ( 'ride' ) ? $this->get_args ( 'ride' ) : "";
  4233. $nature = implode ( ",", $nature );
  4234. $company->companyname = $companyname [0];
  4235. $company->ride = $ride;
  4236. $company->fax = $fax;
  4237. $company->webservice = $webservice;
  4238. $company->address = $address;
  4239. $company->landmarks = $landmarks;
  4240. $company->stay = $stay;
  4241. $company->nature = $nature;
  4242. $cid = $company->insert ();
  4243. $client->cid = $clientID;
  4244. $client->companyid = $cid;
  4245. $client->companyname = $companyname [0];
  4246. $client->update ();
  4247. }
  4248. return "/contacts";
  4249. }
  4250. function AddClientInfo() { // 不编辑公司
  4251. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4252. $clientname = $this->get_args ( 'clientname' ) ? $this->get_args ( 'clientname' ) : "";
  4253. $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : "";
  4254. $nicename = $this->get_args ( 'nicename' ) ? $this->get_args ( 'nicename' ) : "";
  4255. $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : "";
  4256. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";
  4257. $email = $this->get_args ( 'email' ) ? $this->get_args ( 'email' ) : "";
  4258. $unit = $this->get_args ( 'unit' ) ? $this->get_args ( 'unit' ) : "";
  4259. $fax = $this->get_args ( 'fax' ) ? $this->get_args ( 'fax' ) : "";
  4260. $webservice = $this->get_args ( 'webservice' ) ? $this->get_args ( 'webservice' ) : "";
  4261. $department = $this->get_args ( 'department' ) ? $this->get_args ( 'department' ) : "";
  4262. $position = $this->get_args ( 'position' ) ? $this->get_args ( 'position' ) : "";
  4263. $office = $this->get_args ( 'office' ) ? $this->get_args ( 'office' ) : "";
  4264. $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
  4265. $ride = $this->get_args ( 'ride' ) ? $this->get_args ( 'ride' ) : "";
  4266. $landmarks = $this->get_args ( 'landmarks' ) ? $this->get_args ( 'landmarks' ) : "";
  4267. $qq = $this->get_args ( 'qq' ) ? $this->get_args ( 'qq' ) : "";
  4268. $priority = $this->get_args ( 'priority' ) ? $this->get_args ( 'priority' ) : 5;
  4269. $stay = $this->get_args ( 'stay' ) ? $this->get_args ( 'stay' ) : "";
  4270. $mark = $this->get_args ( 'mark' ) ? $this->get_args ( 'mark' ) : "";
  4271. $lv21 = $this->get_args ( 'lv21' ) ? $this->get_args ( 'lv21' ) : "";
  4272. $lv22 = $this->get_args ( 'lv22' ) ? $this->get_args ( 'lv22' ) : "";
  4273. $lv23 = $this->get_args ( 'lv23' ) ? $this->get_args ( 'lv23' ) : "";
  4274. if (! empty ( $cid ) && ! empty ( $clientname )) {
  4275. Doo::loadModel ( 'client' );
  4276. Doo::loadModel ( 'district' );
  4277. $district = new district ();
  4278. $client = new client ();
  4279. $client->cid = $cid;
  4280. $client->clientname = $clientname;
  4281. $client->gender = $gender;
  4282. $client->nicename = $nicename;
  4283. $client->telephone = $telephone;
  4284. $client->phone = $phone;
  4285. $client->email = $email;
  4286. // if(!empty($unit)){
  4287. // $client->unit=$unit;
  4288. // $client->companyname=$unit;
  4289. // }
  4290. if (! empty ( $lv21 ) && ! empty ( $lv22 ) && ! empty ( $lv23 )) {
  4291. $client->district = $lv21 . "," . $lv22 . "," . $lv23;
  4292. }
  4293. if (! empty ( $client->district )) {
  4294. $districtList = $district->find ( array (
  4295. 'where' => 'id in(' . $client->district . ')',
  4296. 'asArray' => true
  4297. ) );
  4298. $jsonString = array ();
  4299. foreach ( $districtList as $value ) {
  4300. array_push ( $jsonString, $value ['name'] );
  4301. }
  4302. $jsonString = implode ( ",", $jsonString );
  4303. if (! empty ( $jsonString ))
  4304. $client->local = $jsonString;
  4305. }
  4306. $client->fax = $fax;
  4307. $client->webservice = $webservice;
  4308. $client->department = $department;
  4309. $client->position = $position;
  4310. $client->office = $office;
  4311. $client->address = $address;
  4312. $client->ride = $ride;
  4313. $client->landmarks = $landmarks;
  4314. $client->qq = $qq;
  4315. $client->stay = $stay;
  4316. $client->priority = $priority;
  4317. $client->mark = $mark;
  4318. $client->updatetime = time ();
  4319. $client->update ();
  4320. // Doo::loadModel ( 'company' );
  4321. // $company = new company();
  4322. // $companyid=$client->getOne(array('where'=>' cid='.$cid,'asArray'=>true));
  4323. // $company->office=$office;
  4324. // $company->fax=$fax;
  4325. // $company->address=$address;
  4326. // $company->ride=$ride;
  4327. // $company->landmarks=$landmarks;
  4328. // $company->cid=$companyid['companyid'];
  4329. // if(!empty($unit)){
  4330. // $company->companyname=$unit;
  4331. // }
  4332. // $company->update();
  4333. $clientInfo = $client->getOne ( array (
  4334. 'where' => ' cid=' . $cid,
  4335. 'asArray' => true
  4336. ) );
  4337. // 日常行为
  4338. Doo::loadModel ( "action_log" );
  4339. $action_log = new action_log ();
  4340. $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'] . ')';
  4341. $action_log->sid = $this->staff [0] ['sid'];
  4342. $action_log->cid = $this->staff [0] ['cid'];
  4343. $action_log->updatetime = date ( "Y-m-d" );
  4344. $action_log->time = date ( "H:i" );
  4345. $action_log->class = $action_log->iconContacts;
  4346. $action_log->status = 2;
  4347. $action_log->districtid = $clientInfo ['district'];
  4348. $local = $district->getbyidlist ( $clientInfo ['district'] );
  4349. $action_log->city = $local [0] ['name'];
  4350. $action_log->province = $local [1] ['name'];
  4351. $action_log->company = $clientInfo ['companyname'];
  4352. Doo::loadModel ( 'company' );
  4353. $company = new company ();
  4354. $companyInfo = $company->getOne ( array (
  4355. 'where' => ' companyname="' . $clientInfo ['companyname'] . '"',
  4356. 'asArray' => true
  4357. ) );
  4358. $nature = explode ( ',', $companyInfo ['nature'] );
  4359. $action_log->nature = $nature [0];
  4360. $action_log->insert ();
  4361. echo json_encode ( array (
  4362. "success" => true
  4363. ) );
  4364. die ();
  4365. } else
  4366. echo json_encode ( array (
  4367. "success" => false
  4368. ) );
  4369. die ();
  4370. }
  4371. function ajaxClientInfo() {
  4372. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4373. if (! empty ( $cid )) {
  4374. Doo::loadModel ( 'client' );
  4375. Doo::loadModel ( 'company' );
  4376. $company = new company ();
  4377. $client = new client ();
  4378. $info = $client->getOne ( array (
  4379. 'where' => ' cid=' . $cid,
  4380. 'asArray' => true
  4381. ) );
  4382. $cinfo = $company->getOne ( array (
  4383. 'where' => ' cid=' . $info ['companyid'],
  4384. 'asArray' => true
  4385. ) );
  4386. Doo::loadModel ( 'district' );
  4387. $district = new district ();
  4388. $districtLv1 = $district->get_lv ( 1 );
  4389. $info ['districtList'] = $district->getbyidlist ( $info ['district'] );
  4390. $optionHtml = '<option vlaue="0">请选择</option>';
  4391. foreach ( $districtLv1 as $key => $value ) {
  4392. if ($value ['name'] == $info ['districtList'] [0] ['name']) {
  4393. $optionHtml .= '<option selected value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  4394. } else
  4395. $optionHtml .= '<option value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  4396. }
  4397. $districtLv2 = $district->get_lvByid ( 2, $info ['districtList'] [0] ['id'] );
  4398. $optionHtml2 = '';
  4399. foreach ( $districtLv2 as $key => $value ) {
  4400. if ($value ['name'] == $info ['districtList'] [1] ['name'])
  4401. $optionHtml2 .= '<option selected value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  4402. else
  4403. $optionHtml2 .= '<option value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  4404. }
  4405. $districtLv3 = $district->get_lvByid ( 2, $info ['districtList'] [1] ['id'] );
  4406. $optionHtml3 = '';
  4407. foreach ( $districtLv3 as $key => $value ) {
  4408. if ($value ['name'] == $info ['districtList'] [2] ['name'])
  4409. $optionHtml3 .= '<option selected value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  4410. else
  4411. $optionHtml3 .= '<option value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  4412. }
  4413. $info ['districtLv1'] = $optionHtml;
  4414. $info ['districtLv2'] = $optionHtml2;
  4415. $info ['districtLv3'] = $optionHtml3;
  4416. $info ['companyInfo'] = $cinfo;
  4417. echo json_encode ( array (
  4418. "success" => true,
  4419. 'html' => $info
  4420. ) );
  4421. die ();
  4422. } else
  4423. echo json_encode ( array (
  4424. "success" => false,
  4425. 'html' => ''
  4426. ) );
  4427. die ();
  4428. }
  4429. /**
  4430. * 为客户添加服务日志
  4431. */
  4432. function ajaxAddServiceLog() {
  4433. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : "";
  4434. $clientid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "";
  4435. $mark = $this->get_args ( 'mark' ) ? $this->get_args ( 'mark' ) : "";
  4436. $m = $this->get_args ( 'm' ) ? $this->get_args ( 'm' ) : "";
  4437. $d = $this->get_args ( 'd' ) ? $this->get_args ( 'd' ) : "";
  4438. $y = $this->get_args ( 'y' ) ? $this->get_args ( 'y' ) : date ( "Y" );
  4439. $Remind = $this->get_args ( 'Remind' ) ? $this->get_args ( 'Remind' ) : 0;
  4440. $time = $this->get_args ( 'time' ) ? $this->get_args ( 'time' ) : 0;
  4441. $remark = $this->get_args ( 'remark' ) ? $this->get_args ( 'remark' ) : "";
  4442. if (! empty ( $status ) && ! empty ( $clientid )) {
  4443. Doo::loadModel ( 'service_log' );
  4444. Doo::loadModel ( 'client_staff' );
  4445. Doo::loadModel ( 'client' );
  4446. Doo::loadModel ( 'district' );
  4447. $district = new district ();
  4448. $client = new client ();
  4449. $clientStaff = new client_staff ();
  4450. $service_log = new service_log ();
  4451. $service_log->status = $status;
  4452. $service_log->clientid = $clientid;
  4453. $service_log->mark = htmlspecialchars ( $mark );
  4454. $service_log->date = $y . "-" . $m . "-" . $d;
  4455. $service_log->category = $this->staff [0] ['category'];
  4456. $service_log->staffname = $this->staff [0] ['username'];
  4457. $service_log->staffid = $this->staff [0] ['sid'];
  4458. $service_log->insert ();
  4459. // 日常行为
  4460. Doo::loadModel ( "action_log" );
  4461. Doo::loadModel ( "client" );
  4462. $client = new client ();
  4463. // 记录服务时间
  4464. $client->cid = $clientid;
  4465. $client->servicetime = time ();
  4466. $client->update ();
  4467. $action_log = new action_log ();
  4468. $clientInfo = $client->getOne ( array (
  4469. 'where' => ' cid=' . $clientid,
  4470. 'asArray' => TRUE
  4471. ) );
  4472. $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'] . ')添加新客户记录。';
  4473. $action_log->sid = $this->staff [0] ['sid'];
  4474. $action_log->cid = $this->staff [0] ['cid'];
  4475. $action_log->updatetime = date ( "Y-m-d" );
  4476. $action_log->time = date ( "H:i" );
  4477. $action_log->status = 3;
  4478. $action_log->districtid = $clientInfo ['district'];
  4479. $local = $district->getbyidlist ( $clientInfo ['district'] );
  4480. $action_log->city = $local [0] ['name'];
  4481. $action_log->province = $local [1] ['name'];
  4482. $action_log->company = $clientInfo ['companyname'];
  4483. Doo::loadModel ( 'company' );
  4484. $company = new company ();
  4485. $companyInfo = $company->getOne ( array (
  4486. 'where' => ' companyname="' . $clientInfo ['companyname'] . '"',
  4487. 'asArray' => true
  4488. ) );
  4489. $nature = explode ( ',', $companyInfo ['nature'] );
  4490. $action_log->nature = $nature [0];
  4491. $action_log->class = $action_log->iconContacts;
  4492. $action_log->insert ();
  4493. // 更新信息中心服务日志统计数量
  4494. $redis = new Redis ();
  4495. $redis->connect ( '127.0.0.1', '6379' );
  4496. $categoryCondition = " and cid=" . $this->staff [0] ['cid'];
  4497. $sidCondition = " and sid=" . $this->staff [0] ['sid'];
  4498. // actionlog免查询值 $alCondition='';
  4499. $alCondition = ' aid>' . REMIT . ' and ';
  4500. // 个人服务日志数量redis值
  4501. $redisKeyCS = date ( 'Y-m-d' ) . 'SL_' . $this->staff [0] ['cid'] . '_' . $this->staff [0] ['sid'];
  4502. $action_log = new action_log ();
  4503. $actionLogLongle = $action_log->find ( array (
  4504. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  4505. 'where' => $alCondition . " status=3 " . $categoryCondition . $sidCondition . " and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) ",
  4506. 'groupby' => 'date_format(updatetime,"%m-%d")',
  4507. 'asArray' => true
  4508. ) );
  4509. $statisticsLongle = array ();
  4510. for($d = 0; $d <= 29; $d ++) {
  4511. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  4512. $falgLongle = true;
  4513. foreach ( $actionLogLongle as $value ) {
  4514. if ($value ['updatetime'] == $MD) {
  4515. array_push ( $statisticsLongle, $value ['count'] );
  4516. $falgLongle = false;
  4517. break;
  4518. }
  4519. }
  4520. if ($falgLongle)
  4521. array_push ( $statisticsLongle, 0 );
  4522. }
  4523. $statisticsLongle = array_reverse ( $statisticsLongle );
  4524. $jsl = json_encode ( $statisticsLongle );
  4525. $redis->set ( $redisKeyCS, $jsl );
  4526. // 办事处服务日志数量reids值
  4527. $redisKeyC = date ( 'Y-m-d' ) . 'SL_' . $this->staff [0] ['cid'] . '_';
  4528. $action_log = new action_log ();
  4529. $actionLogLongle = $action_log->find ( array (
  4530. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  4531. 'where' => $alCondition . " status=3 " . $categoryCondition . " and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) ",
  4532. 'groupby' => 'date_format(updatetime,"%m-%d")',
  4533. 'asArray' => true
  4534. ) );
  4535. $statisticsLongle = array ();
  4536. for($d = 0; $d <= 29; $d ++) {
  4537. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  4538. $falgLongle = true;
  4539. foreach ( $actionLogLongle as $value ) {
  4540. if ($value ['updatetime'] == $MD) {
  4541. array_push ( $statisticsLongle, $value ['count'] );
  4542. $falgLongle = false;
  4543. break;
  4544. }
  4545. }
  4546. if ($falgLongle)
  4547. array_push ( $statisticsLongle, 0 );
  4548. }
  4549. $statisticsLongle = array_reverse ( $statisticsLongle );
  4550. $jsl = json_encode ( $statisticsLongle );
  4551. $redis->set ( $redisKeyC, $jsl );
  4552. // 全员处服务日志数量的redis值
  4553. $redisKey = date ( 'Y-m-d' ) . 'SL__';
  4554. $action_log = new action_log ();
  4555. $actionLogLongle = $action_log->find ( array (
  4556. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  4557. 'where' => $alCondition . " status=3 and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) ",
  4558. 'groupby' => 'date_format(updatetime,"%m-%d")',
  4559. 'asArray' => true
  4560. ) );
  4561. $statisticsLongle = array ();
  4562. for($d = 0; $d <= 29; $d ++) {
  4563. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  4564. $falgLongle = true;
  4565. foreach ( $actionLogLongle as $value ) {
  4566. if ($value ['updatetime'] == $MD) {
  4567. array_push ( $statisticsLongle, $value ['count'] );
  4568. $falgLongle = false;
  4569. break;
  4570. }
  4571. }
  4572. if ($falgLongle)
  4573. array_push ( $statisticsLongle, 0 );
  4574. }
  4575. $statisticsLongle = array_reverse ( $statisticsLongle );
  4576. $jsl = json_encode ( $statisticsLongle );
  4577. $redis->set ( $redisKey, $jsl );
  4578. if (! empty ( $Remind )) {
  4579. Doo::loadModel ( 'remind' );
  4580. $remindObj = new remind ();
  4581. $datetime1 = new DateTime ( date ( 'Y-m-d' ) );
  4582. $datetime2 = new DateTime ( $time );
  4583. $interval = $datetime1->diff ( $datetime2 );
  4584. $remindObj->day = $interval->format ( '%a' );
  4585. $remindObj->remark = $remark;
  4586. $remindObj->time = date ( "Y-m-d" );
  4587. $remindObj->clientName = $clientInfo ['clientname'];
  4588. $remindObj->clientID = $clientid;
  4589. $remindObj->companyName = $clientInfo ['companyname'];
  4590. $remindObj->companyID = $companyInfo ['cid'];
  4591. $remindObj->staffID = $this->staff [0] ['sid'];
  4592. if ($status == 1)
  4593. $remindObj->class = "iconService";
  4594. if ($status == 2)
  4595. $remindObj->class = "iconPhone";
  4596. if ($status == 3)
  4597. $remindObj->class = "iconOther";
  4598. $remindObj->insert ();
  4599. }
  4600. echo json_encode ( array (
  4601. "success" => true,
  4602. 'html' => ''
  4603. ) );
  4604. die ();
  4605. } else
  4606. echo json_encode ( array (
  4607. "success" => false,
  4608. 'html' => ''
  4609. ) );
  4610. die ();
  4611. }
  4612. function _getLongleLogHtml($longleLog = array()) {
  4613. $html = "";
  4614. foreach ( $longleLog as $key => $value ) {
  4615. $dateline = explode ( "-", $value ['dateline'] );
  4616. $html .= '<div class="infoFlowList">
  4617. <div class="dateTitle">
  4618. <em class="month"><span class="num">' . $dateline [1] . '</span><span class="text">-' . $dateline [2] . '</span></em>
  4619. <span class="year">' . $dateline [0] . '</span>
  4620. </div>
  4621. ';
  4622. // 备注
  4623. if ($value ['status'] == 8) {
  4624. $html .= '
  4625. <ul class="flowList">
  4626. <li class="item iconLock">备注<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')" >' . $value ['operator'] . '</a></li>
  4627. <li class="item">' . $value ['mark'] . '</li>
  4628. </ul>';
  4629. // 生成
  4630. } elseif ($value ['status'] == 1) {
  4631. $html .= '<ul class="flowList">
  4632. <li class="item iconGenerate">生成<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')" >' . $value ['operator'] . '</a></li>
  4633. </ul>';
  4634. // 接收
  4635. } elseif ($value ['status'] == 2) {
  4636. $html .= '<ul class="flowList">
  4637. <li class="item iconReceive">接收<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')" >' . $value ['operator'] . '</a></li>
  4638. </ul>';
  4639. // 借出
  4640. } elseif ($value ['status'] == 3) {
  4641. $html .= '<ul class="flowList">
  4642. <li class="item iconBorrow">借出<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')" >' . $value ['operator'] . '</a></li>
  4643. <li class="item">' . $value ['product'] . '</li>
  4644. <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\'' . $value ['clientid'] . "," . $value ['client'] . '\')" >' . $value ['client'] . '</a></li>
  4645. </ul>';
  4646. // 销售
  4647. } elseif ($value ['status'] == 4) {
  4648. $html .= '<ul class="flowList">
  4649. <li class="item iconSell">销售<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')" >' . $value ['operator'] . '</a></li>
  4650. <li class="item">' . $value ['product'] . '</li>
  4651. <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\'' . $value ['clientid'] . "," . $value ['client'] . '\')" >' . $value ['client'] . '</a></li>
  4652. </ul>';
  4653. // 升级
  4654. } elseif ($value ['status'] == 5) {
  4655. $html .= '<ul class="flowList">
  4656. <li class="item iconUpdate">升级<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')" >' . $value ['operator'] . '</a></li>
  4657. <li class="item">' . $value ['product'] . '</li>
  4658. <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\'' . $value ['clientid'] . "," . $value ['client'] . '\')" >' . $value ['client'] . '</a></li>
  4659. </ul>';
  4660. // 更换
  4661. } elseif ($value ['status'] == 6) {
  4662. $html .= '<ul class="flowList">
  4663. <li class="item iconReplace">更换<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')">' . $value ['operator'] . '</a></li>
  4664. <li class="item"><a href="javascript:void(0);" onclick="getLockByName(\'' . $value ['new_key_num'] . '\')">' . $value ['new_key_num'] . '</a>
  4665. <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\'' . $value ['clientid'] . "," . $value ['client'] . '\')" >' . $value ['client'] . '</a></li>
  4666. </ul>';
  4667. // 回收
  4668. } elseif ($value ['status'] == 7) {
  4669. Doo::loadModel ( 'staff' );
  4670. $staff = new staff ();
  4671. $staffinfo = $staff->getOne ( array (
  4672. 'where' => ' username like "' . $value ['responsible'] . '"',
  4673. 'asArray' => true
  4674. ) );
  4675. if (empty ( $staffinfo ))
  4676. $staffinfo ['category'] = "";
  4677. $html .= '<ul class="flowList">
  4678. <li class="item iconRecycle">收回<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')">' . $value ['operator'] . '</a></li>
  4679. <li class="item">' . $staffinfo ['category'] . '<a href="javascript:void(0);" id="ajaxStaff" data="' . $value ['responsible'] . '">' . $value ['responsible'] . '</a></li>
  4680. </ul>';
  4681. } elseif ($value ['status'] == 9) {
  4682. $html .= '<ul class="flowList">
  4683. <li class="item iconGif">赠送 &lt; ' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')">' . $value ['operator'] . '</a></li>
  4684. <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\'' . $value ['clientid'] . "," . $value ['client'] . '\')" >' . $value ['client'] . '</a></li>
  4685. </ul>';
  4686. }
  4687. $html .= '</div>';
  4688. }
  4689. return $html;
  4690. }
  4691. function adminLock() {
  4692. $emsg = isset ( $this->params ['emsg'] ) ? $this->params ['emsg'] : "";
  4693. $data ['emsg'] = "";
  4694. if ($emsg != "")
  4695. $data ['emsg'] = "请填写完整的数据";
  4696. $data ['memu'] = "keyonline";
  4697. $data ['staff'] = $this->staff;
  4698. if ($this->staff [0] ['isadmin'] != 1)
  4699. return "/adminmyinfo";
  4700. Doo::loadModel ( 'L_category' );
  4701. $L_category = new L_category ();
  4702. $data ['category'] = $L_category->getCategory ();
  4703. $data ['time'] = time ();
  4704. $this->render ( "/admin/admin_addlock", $data );
  4705. }
  4706. function adminAddLock() {
  4707. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4708. $path = $this->get_args ( 'path' ) ? $this->get_args ( 'path' ) : "";
  4709. if ($cid != 0 && $path != "") {
  4710. Doo::loadModel ( 'longle' );
  4711. Doo::loadModel ( 'L_category' );
  4712. $L_category = new L_category ();
  4713. Doo::loadModel ( 'longle_log' );
  4714. $exlArray = $this->_format_excel_to_array ( DOO::conf ()->SITE_PATH . "upload/" . iconv ( "UTF-8", "GB2312", $path ) );
  4715. // print_r($exlArray);die;
  4716. // echo json_encode($exlArray);die;
  4717. $category = $L_category->getCategoryById ( $cid );
  4718. foreach ( $exlArray as $key => $value ) {
  4719. // 锁记录
  4720. $longle = new longle ();
  4721. $longle->key_num = str_replace ( "'", "", $value ['key_num'] );
  4722. $longle->product = str_replace ( "'", "", $value ['product'] );
  4723. $longle->make_day = $value ['make_day'];
  4724. $longle->alloted_time = $value ['alloted_time'];
  4725. $longle->status = 1;
  4726. $longle->statusT = "生成";
  4727. $longle->cid = $cid;
  4728. $longle->category = $category [0] ['title'];
  4729. $longle->SerialNumber = $value ['SerialNumber'];
  4730. $longle->version = $value ['version'];
  4731. $lid = $longle->insert ();
  4732. // 锁日志记录
  4733. $longle_log = new longle_log ();
  4734. $longle_log->lid = $lid;
  4735. $longle_log->status = 1;
  4736. $longle_log->statusT = "生成";
  4737. $longle_log->operator = $this->staff [0] ['username'];
  4738. $longle_log->product = $longle->product;
  4739. $longle_log->category = $this->staff [0] ['category'];
  4740. $longle_log->dateline = date ( "Y-m-d" );
  4741. $id = $longle_log->insert ();
  4742. }
  4743. // 记录日常行为
  4744. Doo::loadModel ( "action_log" );
  4745. $action_log = new action_log ();
  4746. $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>个锁';
  4747. $action_log->sid = $this->staff [0] ['sid'];
  4748. $action_log->cid = $this->staff [0] ['cid'];
  4749. $action_log->class = $action_log->iconGenerate;
  4750. $action_log->updatetime = date ( "Y-m-d" );
  4751. $action_log->time = date ( "H:i" );
  4752. $action_log->status = 11;
  4753. $action_log->insert ();
  4754. return "/keyonline";
  4755. } else
  4756. return "/adminlock/error";
  4757. }
  4758. function avatarCM() {
  4759. $vid = isset ( $this->params ['vid'] ) ? $this->params ['vid'] : 0;
  4760. if (! empty ( $vid )) {
  4761. Doo::loadModel ( "verify" );
  4762. $verify = new verify ();
  4763. Doo::loadModel ( 'staff' );
  4764. $staff = new staff ();
  4765. $list = $verify->getOne ( array (
  4766. 'where' => 'vid=' . $vid,
  4767. 'asArray' => true
  4768. ) );
  4769. if (empty ( $list ))
  4770. return "/adminverify";
  4771. $avatar = json_decode ( $list ['staff'] );
  4772. foreach ( $avatar as $key => $value ) {
  4773. $uinfo = $staff->getOne ( array (
  4774. 'where' => 'sid=' . $value [0],
  4775. 'asArray' => true
  4776. ) );
  4777. $avatar [$key] ['2'] = $uinfo ['avatar'];
  4778. }
  4779. $verify->staff = json_encode ( $avatar );
  4780. $verify->update ( array (
  4781. 'where' => 'vid=' . $vid
  4782. ) );
  4783. }
  4784. return "/adminverify";
  4785. }
  4786. function adminmyinfo() {
  4787. $data ['memu'] = "adminmyinfo";
  4788. $data ['staff'] = $this->staff;
  4789. $birArray = explode ( '-', $this->staff [0] ['birthday'] );
  4790. $data ['year'] = $birArray [0];
  4791. $year = date ( 'Y' );
  4792. $yearHtml = "";
  4793. for(; $year >= 1900; $year --) {
  4794. $yearHtml .= '<option ';
  4795. if ($data ['year'] == $year)
  4796. $yearHtml .= 'selected';
  4797. $yearHtml .= ' value="' . $year . '">' . $year . '</option>';
  4798. }
  4799. $data ['yearHtml'] = $yearHtml;
  4800. $data ['month'] = 01;
  4801. $data ['day'] = 01;
  4802. if (isset ( $birArray [1] )) {
  4803. $data ['month'] = $birArray [1];
  4804. $data ['day'] = $birArray [2];
  4805. }
  4806. $data ['msg'] = urldecode ( $this->params ['msg'] );
  4807. $this->render ( "/admin/admin_myinfo", $data );
  4808. }
  4809. function updateMyinfo() {
  4810. $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : 0;
  4811. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : 0;
  4812. $email = $this->get_args ( 'email' ) ? $this->get_args ( 'email' ) : "";
  4813. $qq = is_numeric ( $this->get_args ( 'qq' ) ) ? $_POST ['qq'] : 0;
  4814. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4815. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4816. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : "";
  4817. $position = $this->get_args ( 'position' ) ? $this->get_args ( 'position' ) : "";
  4818. $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : "男";
  4819. $oldpassword = $this->get_args ( 'oldpassword' ) ? $this->get_args ( 'oldpassword' ) : "";
  4820. $newpassword = $this->get_args ( 'newpassword' ) ? $this->get_args ( 'newpassword' ) : "";
  4821. $rnewpassword = $this->get_args ( 'rnewpassword' ) ? $this->get_args ( 'rnewpassword' ) : "";
  4822. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  4823. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  4824. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  4825. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  4826. Doo::loadModel ( 'staff' );
  4827. $staff = new staff ();
  4828. Doo::loadModel ( 'staffDynamic' );
  4829. $staffDynamic = new staffDynamic ();
  4830. $staff->sid = $this->staff [0] ['sid'];
  4831. if (! empty ( $remittanceName ))
  4832. $staff->remittanceName = $remittanceName;
  4833. if (! empty ( $bankName ))
  4834. $staff->bankName = $bankName;
  4835. if (! empty ( $bankNumber ))
  4836. $staff->bankNumber = $bankNumber;
  4837. if (! empty ( $coupletNumber ))
  4838. $staff->coupletNumber = $coupletNumber;
  4839. $content = "";
  4840. $ext = "更新了他的";
  4841. if ($telephone != 0 && $this->staff [0] ['telephone'] != $telephone) {
  4842. $staff->telephone = $telephone;
  4843. $content .= "<b>手机</b>&nbsp;";
  4844. }
  4845. if ($phone != 0 && $this->staff [0] ['phone'] != $phone) {
  4846. $staff->phone = $phone;
  4847. $content .= "<b>电话</b>&nbsp;";
  4848. }
  4849. if ($qq != 0 && $this->staff [0] ['qq'] != $qq) {
  4850. $staff->qq = $qq;
  4851. $content .= "<b>QQ</b>&nbsp;";
  4852. }
  4853. if ($year != 2014) {
  4854. $staff->birthday = $year . "-" . $month . "-" . $day;
  4855. $content .= "<b>生日</b>&nbsp;";
  4856. }
  4857. if ($email != "" && filter_var ( $email, FILTER_VALIDATE_EMAIL ) && $this->staff [0] ['email'] != $email) {
  4858. $staff->email = $email;
  4859. $content .= "<b>邮箱</b>&nbsp;";
  4860. }
  4861. if (! empty ( $position )) {
  4862. $staff->position = $position;
  4863. $content .= "<b>职位</b>&nbsp;";
  4864. }
  4865. $staff->gender = $gender;
  4866. $msg = "更新成功";
  4867. if ($this->staff [0] ['passwork'] == md5 ( $oldpassword )) {
  4868. if ($newpassword == $rnewpassword && (! empty ( $newpassword )))
  4869. $staff->passwork = md5 ( $newpassword );
  4870. else
  4871. $msg = "密码不一致";
  4872. } else {
  4873. if ($oldpassword != "")
  4874. $msg = "密码错误";
  4875. }
  4876. if (! empty ( $content )) {
  4877. $staffDynamic->content = $ext . $content;
  4878. $staffDynamic->cid = $this->staff [0] ['cid'];
  4879. $staffDynamic->category = $this->staff [0] ['category'];
  4880. $staffDynamic->time = time ();
  4881. $staffDynamic->sid = $this->staff [0] ['sid'];
  4882. $staffDynamic->staff = $this->staff [0] ['username'];
  4883. $staffDynamic->insert ();
  4884. }
  4885. $staff->update ( array (
  4886. 'where' => ' sid=' . $this->staff [0] ['sid']
  4887. ) );
  4888. return "/adminmyinfo/" . $msg;
  4889. }
  4890. function admincontacts() {
  4891. $data ['memu'] = "admincontacts";
  4892. $data ['staff'] = $this->staff;
  4893. Doo::loadModel ( 'L_category' );
  4894. Doo::loadModel ( 'staff' );
  4895. $staff = new staff ();
  4896. $L_category = new L_category ();
  4897. $this->render ( "/admin/admin_addContacts", $data );
  4898. }
  4899. /**
  4900. * 微信通知设置
  4901. */
  4902. // function notificationConf() {
  4903. // Doo::loadModel ( "notificationConf" );
  4904. // $notificationConf = new notificationConf ();
  4905. // $detail = $notificationConf->getNotificationConfBySid ( $this->staff [0] ['sid'] );
  4906. // $rule = json_decode ( $detail ['conf'], true );
  4907. // $data ['rule'] = $rule;
  4908. // $data ['memu'] = "notificationConf";
  4909. // $data ['staff'] = $this->staff;
  4910. // $this->render ( "/admin/invoiceNotificationConf", $data );
  4911. // }
  4912. // function ajaxSetNotificationConf() {
  4913. // $notificationType = $this->get_args ( 'notificationType' ) ? $this->get_args ( 'notificationType' ) : "";
  4914. // $notificationValue = $this->get_args ( 'notificationValue' ) ? $this->get_args ( 'notificationValue' ) : '';
  4915. // if (! empty ( $notificationType ) && ! empty ( $notificationValue ) && ! empty ( $this->staff [0] ['sid'] )) {
  4916. // Doo::loadModel ( "notificationConf" );
  4917. // $notificationConf = new notificationConf ();
  4918. // $detail = $notificationConf->getNotificationConfBySid ( $this->staff [0] ['sid'] );
  4919. // if (empty ( $detail )) {
  4920. // $rule = array (
  4921. // $notificationType => $notificationValue
  4922. // );
  4923. // $rule = json_encode ( $rule );
  4924. // $item = array (
  4925. // 'sid' => $this->staff [0] ['sid'],
  4926. // 'conf' => $rule
  4927. // );
  4928. // $notificationConf->addNotification ( $item );
  4929. // } else {
  4930. // $rule = json_decode ( $detail ['conf'], true );
  4931. // $rule [$notificationType] = $notificationValue;
  4932. // $rule = json_encode ( $rule );
  4933. // $item = array (
  4934. // 'nid' => $detail ['nid'],
  4935. // 'conf' => $rule
  4936. // );
  4937. // $notificationConf->setNotificationByCondition ( $item );
  4938. // }
  4939. // echo json_encode ( array (
  4940. // 'status' => 1,
  4941. // 'msgType' => $notificationType,
  4942. // 'msg' => ''
  4943. // ) );
  4944. // die ();
  4945. // }
  4946. // echo json_encode ( array (
  4947. // 'status' => 2,
  4948. // 'msgType' => $notificationType,
  4949. // 'msg' => 'illegal request'
  4950. // ) );
  4951. // die ();
  4952. // }
  4953. function eMailTask() {
  4954. Doo::loadModel ( 'tag' );
  4955. $tag = new tag ();
  4956. Doo::loadModel ( 'district' );
  4957. $district = new district ();
  4958. $tagList = $tag->getAllBySid ( $this->staff [0] ['sid'] );
  4959. $districtList = $district->get_lv ( 1 );
  4960. $data ['tagList'] = $tagList;
  4961. $data ['districtList'] = $districtList;
  4962. $data ['memu'] = "eMailTask";
  4963. $data ['staff'] = $this->staff;
  4964. $data ['mailMemu'] = 'eMailTask';
  4965. $data ['nature'] = $this->nature;
  4966. $this->render ( "/mail_create", $data );
  4967. }
  4968. function eMialCenter() {
  4969. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4970. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 0;
  4971. Doo::loadModel ( 'eMailList' );
  4972. $eMailList = new eMailList ();
  4973. Doo::loadModel ( 'tag' );
  4974. $tag = new tag ();
  4975. Doo::loadModel ( 'staff' );
  4976. $staff = new staff ();
  4977. $dateCondition = "status!=2 and Year(date) =" . $year;
  4978. if (! empty ( $month ))
  4979. $dateCondition = "Year(date) =" . $year . " and Month(date) = " . $month;
  4980. $mailList = $eMailList->find ( array (
  4981. 'where' => $dateCondition,
  4982. 'asc' => 'status',
  4983. 'desc' => 'elid',
  4984. 'asArray' => true
  4985. ) );
  4986. foreach ( $mailList as $key => $value ) {
  4987. $mailList [$key] ['clientName2'] = $mailList [$key] ['clientName3'] = array ();
  4988. $mailList [$key] ['clientName'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName'] ) ), true );
  4989. if (! empty ( $value ['clientName2'] ))
  4990. $mailList [$key] ['clientName2'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName2'] ) ), true );
  4991. if (! empty ( $value ['clientName3'] ))
  4992. $mailList [$key] ['clientName3'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName3'] ) ), true );
  4993. $mailList [$key] ['illegalEmail'] = json_decode ( $value ['illegalEmail'], true );
  4994. $mailList [$key] ['sendEmail'] = json_decode ( $value ['sendEmail'], true );
  4995. $mailList [$key] ['clientCount'] = count ( $mailList [$key] ['clientName'] ) + count ( $mailList [$key] ['clientName2'] ) + count ( $mailList [$key] ['clientName3'] );
  4996. $mailList [$key] ['tag'] = array ();
  4997. $kks = $staff->getOne ( array (
  4998. 'where' => 'username like "' . $value ['staffName'] . '"',
  4999. 'asArray' => true
  5000. ) );
  5001. $mailList [$key] ['category'] = $kks ['category'];
  5002. if (! empty ( $value ['tag'] ))
  5003. $mailList [$key] ['tag'] = $tag->find ( array (
  5004. 'where' => 'tid in ( ' . $value ['tag'] . ') ',
  5005. 'asArray' => true
  5006. ) );
  5007. }
  5008. $dateHtml = "";
  5009. $now = date ( "Y" );
  5010. for($YEARD = 2014; $YEARD <= 2050; $YEARD ++) {
  5011. if ($YEARD <= $now) {
  5012. $dateHtml .= '<option ';
  5013. if ($year == $YEARD)
  5014. $dateHtml .= ' selected ';
  5015. $dateHtml .= ' value="' . $YEARD . '">' . $YEARD . '</option>';
  5016. }
  5017. }
  5018. $monthHtml = '<option value="0">所有月份</option>';
  5019. for($i = 1; $i <= 12; $i ++) {
  5020. $monthHtml .= '<option ';
  5021. if ($i == $month)
  5022. $monthHtml .= ' selected ';
  5023. $monthHtml .= ' value="' . $i . '">' . $i . '</option>';
  5024. }
  5025. $data ['monthHtml'] = $monthHtml;
  5026. $data ['dateHtml'] = $dateHtml;
  5027. $data ['mailList'] = $mailList;
  5028. $data ['memu'] = "eMailTask";
  5029. $data ['staff'] = $this->staff;
  5030. $data ['mailMemu'] = 'eMialCenter';
  5031. $data ['nature'] = $this->nature;
  5032. $this->render ( "/mailCenter", $data );
  5033. }
  5034. function authMail() {
  5035. $elid = isset ( $this->params ['elid'] ) ? $this->params ['elid'] : 0;
  5036. if (! empty ( $elid )) {
  5037. Doo::loadModel ( 'eMailList' );
  5038. $eMailList = new eMailList ();
  5039. $eMailList->examine = 2;
  5040. $eMailList->mark = $this->staff [0] ['username'] . "已同意";
  5041. $eMailList->update ( array (
  5042. 'where' => 'elid=' . $elid,
  5043. 'asArray' => true
  5044. ) );
  5045. }
  5046. return '/eMialCenter';
  5047. }
  5048. function editMailView() {
  5049. $elid = isset ( $this->params ['elid'] ) ? $this->params ['elid'] : 0;
  5050. Doo::loadModel ( 'tag' );
  5051. $tag = new tag ();
  5052. Doo::loadModel ( 'district' );
  5053. $district = new district ();
  5054. Doo::loadModel ( 'eMailList' );
  5055. $eMList = new eMailList ();
  5056. $mail = $eMList->getOne ( array (
  5057. 'where' => 'elid =' . $elid . '',
  5058. 'asArray' => true
  5059. ) );
  5060. if (empty ( $mail ))
  5061. return "/eMailList";
  5062. $mail ['tagList'] = explode ( ",", $mail ['tag'] );
  5063. $tagList = $tag->getAllBySid ( $this->staff [0] ['sid'] );
  5064. $districtList = $district->get_lv ( 1 );
  5065. $tagHtml = '';
  5066. foreach ( $tagList as $key => $value ) {
  5067. $tagHtml .= '<label><span data-original-title="' . $value ['name'] . '" data-toggle="ctooltip" data-placement="right" class="contactsTag tagCol-0' . $value ['colorid'] . '">
  5068. <input type="checkbox" name="tagId[]"';
  5069. foreach ( $mail ['tagList'] as $k => $v ) {
  5070. if ($value ['tid'] == $v) {
  5071. $tagHtml .= ' checked ';
  5072. break;
  5073. }
  5074. }
  5075. $tagHtml .= ' value="' . $value ['tid'] . '"></span></label>';
  5076. }
  5077. $districtHtml = '';
  5078. foreach ( $districtList as $key => $value ) {
  5079. $districtHtml .= '<option value="' . $value ['id'] . '"';
  5080. if ($value ['id'] == $mail ['districtId'])
  5081. $districtHtml .= 'selected';
  5082. $districtHtml .= '>' . $value ['name'] . '</option>';
  5083. }
  5084. $natureHtml = '';
  5085. $natList = explode ( ",", $mail ['nature'] );
  5086. foreach ( $this->nature as $key => $value ) {
  5087. $natureHtml .= '<label><input type="checkbox" name="nature[]" ';
  5088. foreach ( $natList as $k => $v ) {
  5089. if ($value == $v) {
  5090. $natureHtml .= ' checked ';
  5091. break;
  5092. }
  5093. }
  5094. $natureHtml .= 'value="' . $value . '">' . $value . '</label>';
  5095. }
  5096. $data ['natureHtml'] = $natureHtml;
  5097. $data ['districtHtml'] = $districtHtml;
  5098. $data ['tagHtml'] = $tagHtml;
  5099. $data ['mail'] = $mail;
  5100. $data ['tagList'] = $tagList;
  5101. $data ['districtList'] = $districtList;
  5102. $data ['memu'] = "eMailTask";
  5103. $data ['staff'] = $this->staff;
  5104. $data ['mailMemu'] = 'eMailList';
  5105. $data ['nature'] = $this->nature;
  5106. $this->render ( "/mailEdit", $data );
  5107. }
  5108. function editEmail() {
  5109. $title = $this->get_args ( 'title' ) ? $this->get_args ( 'title' ) : "";
  5110. $skin = $this->get_args ( 'skin' ) ? $this->get_args ( 'skin' ) : "";
  5111. $content = isset ( $_POST ['content'] ) ? $_POST ['content'] : "";
  5112. $tagId = $this->get_args ( 'tagId' ) ? $this->get_args ( 'tagId' ) : array ();
  5113. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : array ();
  5114. $natureNULL = $this->get_args ( 'natureNULL' ) ? $this->get_args ( 'natureNULL' ) : "";
  5115. $did = $this->get_args ( 'did' ) ? $this->get_args ( 'did' ) : "";
  5116. $stype = $this->get_args ( 'stype' ) ? $this->get_args ( 'stype' ) : "";
  5117. $elid = $this->get_args ( 'elid' ) ? $this->get_args ( 'elid' ) : "";
  5118. if (! empty ( $title ) && ! empty ( $elid ) && (! empty ( $tagId ) || ! empty ( $did ))) {
  5119. Doo::loadModel ( 'eMailList' );
  5120. $eMailList = new eMailList ();
  5121. $etid = $eMailList->getOne ( array (
  5122. 'select' => 'etid,annexName,annex',
  5123. 'where' => 'elid=' . $elid,
  5124. 'asArray' => true
  5125. ) );
  5126. Doo::loadModel ( 'eMailTemplate' );
  5127. $eMailTemplate = new eMailTemplate ();
  5128. Doo::loadModel ( 'eMailJournal' );
  5129. $eMailJournal = new eMailJournal ();
  5130. if ($natureNULL != 'NULL') {
  5131. if (empty ( $tagId ) && ! empty ( $did ) && empty ( $nature ))
  5132. die ( '请选择性质' );
  5133. }
  5134. // annex
  5135. $annexPath = "";
  5136. $annexEXT = $this->_GetFileEXT ( $_FILES ["annex"] ["name"] );
  5137. $annexName = "";
  5138. if (isset ( $_FILES ['annex'] ['name'] )) {
  5139. 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)) {
  5140. $path = DOO::conf ()->SITE_PATH . "upload/emailAnnex/";
  5141. if (! file_exists ( $path . $_FILES ["annex"] ["name"] )) {
  5142. $fileName = time () . "." . $annexEXT;
  5143. $annexName = $_FILES ['annex'] ['name'];
  5144. $annexPath = $path . $fileName;
  5145. move_uploaded_file ( $_FILES ["annex"] ["tmp_name"], $annexPath );
  5146. $annexPath = $this->webPath . $fileName;
  5147. }
  5148. }
  5149. }
  5150. if (! empty ( $annexPath )) {
  5151. $annexHtml = '<table style="width:100%;margin:10px 0">
  5152. <thead>
  5153. <tr>
  5154. <th align="left" colspan="2" style="background-color:ff6501;color:#fff;font-size:16px;padding:5px">下载附件:</th>
  5155. </tr>
  5156. </thead>
  5157. <tbody>
  5158. <tr>
  5159. <td style="padding:5px"><a href="' . $annexPath . '" target="_blank" style="font-size:16px">' . $annexName . '</a></td>
  5160. <td>&nbsp;</td>
  5161. </tr>
  5162. </tbody>
  5163. </table>';
  5164. } elseif (! empty ( $etid ['annexName'] ) && empty ( $annexPath ))
  5165. $annexHtml = $etid ['annex'];
  5166. $smartcostMail = 'smartcost_mail_1';
  5167. $info = "";
  5168. // html template
  5169. if ($skin == 1) {
  5170. $html = '<div><table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  5171. <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">
  5172. <tbody><tr>
  5173. <td style="background-color:#ff6501;padding:20px 0 25px;" align="center">
  5174. <span style="vertical-align:bottom;font-size:20px;color:#fff;">' . $title . '</span>
  5175. </td></tr><tr><td>
  5176. <table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;border-top:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  5177. <tbody><tr><td style="padding: 0 40px;" align="left">
  5178. <p style="margin-top:40px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
  5179. </td></tr><tr><td style="padding: 0 40px;" align="left">
  5180. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>' . $this->staff [0] ['username'] . '</b>:</p>
  5181. <p style="margin-top:0px;margin-bottom:20px;color:#383838;font-size:16px;line-height:32px;">
  5182. ' . $content . '</p>
  5183. </td></tr>
  5184. <tr><td align="left" style="padding: 0 40px;background:#fff">
  5185. ' . $annexHtml . '
  5186. </td></tr>
  5187. <tr> <td style="padding: 20px 40px;border-top:1px dashed #ddd" align="left">
  5188. <p style="margin-bottom:10px;color:#383838;font-size:16px;line-height:22px;border-left:2px solid #FF6501;padding-left:5px">
  5189. 纵横公路造价软件' . $this->staff [0] ['category'] . '办事处</p>
  5190. <table>
  5191. <tr><th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td></tr>
  5192. <tr><th align="right">联系人:</th><td>' . $this->staff [0] ['username'] . '</td></tr>
  5193. <tr><th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr>
  5194. <tr><th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td></tr>
  5195. <tr><th align="right">邮箱:</th><td>' . $this->staff [0] ['email'] . '</td></tr>
  5196. </table></td></tr></tbody></table></td></tr><tr>
  5197. <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>
  5198. </tr></tbody></table></td></tr></tbody></table></div>';
  5199. $info = '<table><tr><th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td></tr>
  5200. <tr><th align="right">联系人:</th><td>' . $this->staff [0] ['username'] . '</td></tr>
  5201. <tr><th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr>
  5202. <tr><th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td></tr>
  5203. <tr><th align="right">邮箱:</th><td>' . $this->staff [0] ['email'] . '</td></tr></table>';
  5204. } elseif ($skin == 2) {
  5205. $smartcostMail = 'smartcost_mail_2';
  5206. $html = '<table cellspacing="0" cellpadding="0" style="background-color:#e4e4e4; width:100%;"><tbody><tr><td>
  5207. <table align="center" cellspacing="0" cellpadding="0" style="background-color:#f8f8f8; width:640px;margin-bottom:20px">
  5208. <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;">
  5209. <b><span name="titleHtml">' . $title . '</span></b></p></td>
  5210. </tr><tr><td><table align="center" cellspacing="0" cellpadding="0" style="border:1px solid #ddd;"><tbody><tr>
  5211. <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>
  5212. </tr><tr><td align="center" style="background-color:#fff;"><img width="640" height="191" src="http://zonghengvideo.qiniudn.com/hero.jpg"></td>
  5213. </tr><tr><td align="left" style="background-color:#fff;padding:40px;border-bottom:1px solid #ddd;">
  5214. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
  5215. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>' . $this->staff [0] ['username'] . '</b>:</p>
  5216. <p name="contentHtml" style="margin-top:0px;margin-bottom:15px;color:#383838;font-size:16px;line-height:32px;">' . $content . '</p></td>
  5217. </tr>
  5218. <tr><td align="left" style="padding: 0 40px;background:#fff">
  5219. ' . $annexHtml . '
  5220. </td></tr>
  5221. <tr><td style="padding: 10px 0;background:#EEF2F5"><table><tbody><tr>
  5222. <td style="font-size:14pxl;color:#333;padding:0 20px"><b>纵横公路造价软件' . $this->staff [0] ['category'] . '办事处</b><br>' . $this->staff [0] ['username'] . '</td>
  5223. <td><table><tbody><tr style="font-size:12px;color:#666">
  5224. <th align="right">电话:</th><td style="padding:0 20px 0 0">' . $this->staff [0] ['phone'] . '</td>
  5225. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr><tr style="font-size:12px;color:#666">
  5226. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5227. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  5228. </tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr>
  5229. <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>
  5230. </tr></tbody></table></td></tr></tbody> </table>';
  5231. $info = '<table><tbody><tr style="font-size:12px;color:#666">
  5232. <th align="right">电话:</th><td style="padding:0 20px 0 0">' . $this->staff [0] ['phone'] . '</td>
  5233. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr><tr style="font-size:12px;color:#666">
  5234. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5235. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  5236. </tr></tbody></table>';
  5237. } else {
  5238. $smartcostMail = 'smartcost_mail_3';
  5239. $html = '<table cellspacing="0" cellpadding="0" style="background-color:#ECF0E1; width:100%">
  5240. <tbody>
  5241. <tr>
  5242. <td>
  5243. <table align="center" cellspacing="0" cellpadding="0" style="width:698px;margin-bottom:30px;margin-top:30px;">
  5244. <tbody>
  5245. <tr>
  5246. <td>
  5247. <table align="center" cellspacing="0" cellpadding="0" style="border:1px solid #ccc;width:100%;border-top:none">
  5248. <tbody>
  5249. <tr>
  5250. <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;">
  5251. <div style="position:relative;text-align:right">
  5252. <b style="font-size:24px;color:#8A9F98;z-index:999"><span name="titleHtml">' . $title . '</span></b>
  5253. <div style="width:80px;height:80px;position:absolute;top:0;left:0"><img src="http://zonghengvideo.qiniudn.com/zonghenglogo.png"></div>
  5254. </div>
  5255. </td>
  5256. </tr>
  5257. <tr>
  5258. <td align="left" style="background-color:#fff;padding:40px;border-bottom:1px solid #ddd;">
  5259. <p style="margin-top:0px;margin-bottom:10px;color:#666;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
  5260. <p style="margin-top:0px;margin-bottom:10px;color:#666;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>' . $this->staff [0] ['username'] . '</b>:</p>
  5261. <p name="contentHtml" style="margin-top:0px;margin-bottom:15px;color:#666;font-size:16px;line-height:32px;">' . $content . '</p></td>
  5262. </tr>
  5263. <tr><td align="left" style="padding: 0 40px;background:#fff">
  5264. ' . $annexHtml . '
  5265. </td></tr>
  5266. <tr>
  5267. <td style="padding: 10px 0 0;background:#F6F6F6;">
  5268. <table>
  5269. <tbody><tr>
  5270. <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>
  5271. <td>
  5272. <table style="width:100%">
  5273. <tbody><tr style="font-size:12px;color:#496781">
  5274. <th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td>
  5275. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td>
  5276. </tr>
  5277. <tr style="font-size:12px;color:#496781">
  5278. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5279. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  5280. </tr>
  5281. </tbody></table>
  5282. </td>
  5283. </tr>
  5284. </tbody></table>
  5285. </td>
  5286. </tr>
  5287. <tr>
  5288. <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>
  5289. </tr>
  5290. </tbody>
  5291. </table></td>
  5292. </tr>
  5293. </tbody>
  5294. </table></td>
  5295. </tr>
  5296. </tbody>
  5297. </table>';
  5298. $info = '<table><tr style="font-size:12px;color:#496781"><th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td>
  5299. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr><tr style="font-size:12px;color:#496781">
  5300. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5301. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td></tr></table>
  5302. ';
  5303. }
  5304. Doo::loadModel ( 'tag_client' );
  5305. $tagClient = new tag_client ();
  5306. Doo::loadModel ( 'client' );
  5307. $client = new client ();
  5308. Doo::loadModel ( 'company' );
  5309. $company = new company ();
  5310. $eMailTemplate->title = $title;
  5311. $eMailTemplate->skin = $skin;
  5312. $eMailTemplate->content = $content;
  5313. if (! empty ( $tagId ))
  5314. $eMailTemplate->tag = implode ( ",", $tagId );
  5315. $eMailTemplate->staffId = $this->staff [0] ['sid'];
  5316. $eMailTemplate->staffName = $this->staff [0] ['username'];
  5317. $eMailTemplate->status = 0;
  5318. $eMailTemplate->html = $html;
  5319. if (! empty ( $annexPath )) {
  5320. $eMailTemplate->annex = $annexPath;
  5321. $eMailTemplate->annexName = $annexName;
  5322. }
  5323. $etid = $eMailTemplate->update ( array (
  5324. 'where' => 'etid=' . $etid ['etid']
  5325. ) );
  5326. // create email list
  5327. $tagCondition = "";
  5328. $tagArray = array ();
  5329. foreach ( $tagId as $value ) {
  5330. array_push ( $tagArray, " tag like '%" . $value . "%' " );
  5331. }
  5332. if (! empty ( $tagArray ))
  5333. $tagCondition = ' and (' . implode ( " or ", $tagArray ) . ')';
  5334. $clientList = $tagClient->find ( array (
  5335. 'select' => 'client',
  5336. 'where' => 'sid=' . $this->staff [0] ['sid'] . $tagCondition,
  5337. 'asArray' => true
  5338. ) );
  5339. $clientArray = array ();
  5340. foreach ( $clientList as $value ) {
  5341. array_push ( $clientArray, $value ['client'] );
  5342. }
  5343. $clientEmailList = array ();
  5344. if (! empty ( $clientArray ))
  5345. $clientEmailList = $client->find ( array (
  5346. 'select' => 'email,cid,nicename as clientname,companyname',
  5347. 'where' => 'cid in (' . implode ( ",", $clientArray ) . ')',
  5348. 'asArray' => true
  5349. ) );
  5350. //
  5351. if ($stype == 2) {
  5352. // 获取性质相关数据
  5353. $cidList = '';
  5354. if ($natureNULL == '') {
  5355. $nD = array ();
  5356. foreach ( $nature as $key => $value ) {
  5357. array_push ( $nD, ' nature like "' . $value . '"' );
  5358. // $nD=' nature like "'.$value.'"';
  5359. }
  5360. $nD = implode ( ' or ', $nD );
  5361. $companycid = $company->find ( array (
  5362. 'select' => 'cid',
  5363. 'where' => $nD,
  5364. 'asArray' => true
  5365. ) );
  5366. $cidList = array ();
  5367. foreach ( $companycid as $key => $value ) {
  5368. array_push ( $cidList, $value ['cid'] );
  5369. }
  5370. $cidList = implode ( ',', $cidList );
  5371. if (! empty ( $cidList ))
  5372. $cidList = ' and companyid in (' . $cidList . ')';
  5373. else
  5374. $cidList = '';
  5375. }
  5376. // 'select'=>'email,cid,nicename as clientname,companyname,district'
  5377. $clientEmailList = $client->find ( array (
  5378. 'select' => 'email,cid,nicename as clientname,companyname,district',
  5379. 'where' => 'district like "' . $did . ',%" ' . $cidList,
  5380. 'asArray' => true
  5381. ) );
  5382. }
  5383. // ;datediff(curdate(), 'date')>=10
  5384. $eMailJournal->delete ( array (
  5385. 'where' => "datediff(curdate(), date)>=7"
  5386. ) );
  5387. $eMailJournal->delete ( array (
  5388. 'where' => 'DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(date)'
  5389. ) );
  5390. $checkMail = $eMailJournal->find ( array (
  5391. 'where' => 'DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(date)',
  5392. ' groupby' => 'email',
  5393. 'asArray' => true
  5394. ) );
  5395. $emailNameList = $emailArray = $illegalEmail = $sendEmail = array ();
  5396. Doo::db ()->beginTransaction ();
  5397. foreach ( $clientEmailList as $value ) {
  5398. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  5399. if (! empty ( $checkMail )) {
  5400. $falg = true;
  5401. foreach ( $checkMail as $v ) {
  5402. if ($v ['email'] == $value ['email']) {
  5403. $Bdate = strtotime ( $v ['date'] ) + 7 * 24 * 3600;
  5404. if ($Bdate <= time ()) {
  5405. array_push ( $emailArray, $value ['email'] );
  5406. array_push ( $emailNameList, $value );
  5407. $eMailJournal->date = date ( "Y-m-d" );
  5408. $eMailJournal->update ( array (
  5409. 'where' => 'ejid=' . $v ['ejid']
  5410. ) );
  5411. } else {
  5412. array_push ( $sendEmail, $value );
  5413. }
  5414. $falg = false;
  5415. break;
  5416. }
  5417. }
  5418. if ($falg) {
  5419. array_push ( $emailArray, $value ['email'] );
  5420. array_push ( $emailNameList, $value );
  5421. $eMailJournal->clientId = $value ['cid'];
  5422. $eMailJournal->status = 1;
  5423. $eMailJournal->email = $value ['email'];
  5424. $eMailJournal->date = date ( "Y-m-d" );
  5425. $eMailJournal->insert ();
  5426. }
  5427. } else {
  5428. array_push ( $emailArray, $value ['email'] );
  5429. array_push ( $emailNameList, $value );
  5430. $eMailJournal->clientId = $value ['cid'];
  5431. $eMailJournal->status = 1;
  5432. $eMailJournal->email = $value ['email'];
  5433. $eMailJournal->date = date ( "Y-m-d" );
  5434. $eMailJournal->insert ();
  5435. }
  5436. } else {
  5437. array_push ( $illegalEmail, $value );
  5438. }
  5439. }
  5440. Doo::db ()->commit ();
  5441. // echo json_encode($illegalEmail);
  5442. // json_encode(array_slice($illegalEmail,0,100))
  5443. // $kk=gzcompress();
  5444. // $ll=gzuncompress($kk);
  5445. // ."</br>".strlen($kk)."</br>".strlen($ll);die;
  5446. $size = floor ( count ( $emailArray ) / 3 );
  5447. if (! empty ( $emailArray )) {
  5448. if (count ( $emailArray ) < 3) {
  5449. $list = array (
  5450. 0 => $emailArray,
  5451. 1 => array (),
  5452. 2 => array ()
  5453. );
  5454. } else
  5455. $list = array_chunk ( $emailArray, $size );
  5456. } else
  5457. $list = array (
  5458. 0 => array (),
  5459. 1 => array (),
  5460. 2 => array ()
  5461. );
  5462. $emailJson = array ();
  5463. foreach ( $list as $value ) {
  5464. $em = array ();
  5465. foreach ( $value as $v ) {
  5466. array_push ( $em, $v );
  5467. }
  5468. array_push ( $emailJson, $em );
  5469. }
  5470. $size = floor ( count ( $emailNameList ) / 3 );
  5471. if (! empty ( $emailNameList )) {
  5472. if (count ( $emailNameList ) < 3) {
  5473. $list = array (
  5474. 0 => $emailNameList,
  5475. 1 => array (),
  5476. 2 => array ()
  5477. );
  5478. } else
  5479. $list = array_chunk ( $emailNameList, $size );
  5480. } else
  5481. $list = array (
  5482. 0 => array (),
  5483. 1 => array (),
  5484. 2 => array ()
  5485. );
  5486. $emailNameJson = array ();
  5487. foreach ( $list as $value ) {
  5488. $em = array ();
  5489. foreach ( $value as $v ) {
  5490. array_push ( $em, $v );
  5491. }
  5492. array_push ( $emailNameJson, $em );
  5493. }
  5494. //
  5495. $eMailList->date = date ( "Y-m-d" );
  5496. $eMailList->clientEmail = base64_encode ( gzcompress ( json_encode ( $emailJson [0] ) ) );
  5497. $eMailList->clientEmail2 = base64_encode ( gzcompress ( json_encode ( $emailJson [1] ) ) );
  5498. $eMailList->clientEmail3 = base64_encode ( gzcompress ( json_encode ( $emailJson [2] ) ) );
  5499. $eMailList->clientName = base64_encode ( gzcompress ( json_encode ( $emailNameJson [0] ) ) );
  5500. $eMailList->clientName2 = base64_encode ( gzcompress ( json_encode ( $emailNameJson [1] ) ) );
  5501. $eMailList->clientName3 = base64_encode ( gzcompress ( json_encode ( $emailNameJson [2] ) ) );
  5502. $eMailList->illegalEmail = json_encode ( array_slice ( $illegalEmail, 0, 100 ) ); // json_encode($illegalEmail);
  5503. $eMailList->sendEmail = json_encode ( $sendEmail );
  5504. $eMailList->templateName = $smartcostMail;
  5505. $eMailList->eTitle = $title;
  5506. $eMailList->html = $html;
  5507. $eMailList->content = $content;
  5508. $eMailList->info = $info;
  5509. if (! empty ( $annexName )) {
  5510. $eMailList->annex = $annexHtml;
  5511. $eMailList->annexName = $annexName;
  5512. }
  5513. if ($stype == 1) {
  5514. $eMailList->tag = implode ( ",", $tagId );
  5515. $eMailList->districtId = "";
  5516. $eMailList->nature = "";
  5517. }
  5518. if ($stype == 2) {
  5519. $eMailList->districtId = $did;
  5520. $eMailList->nature = implode ( ",", $nature );
  5521. $eMailList->tag = "";
  5522. }
  5523. $eMailList->update ( array (
  5524. 'where' => 'elid=' . $elid
  5525. ) );
  5526. return "/eMailList";
  5527. }
  5528. return "/eMailTask";
  5529. }
  5530. function createEmail() {
  5531. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  5532. $title = $this->get_args ( 'title' ) ? $this->get_args ( 'title' ) : "";
  5533. $skin = $this->get_args ( 'skin' ) ? $this->get_args ( 'skin' ) : "";
  5534. $content = isset ( $_POST ['content'] ) ? $_POST ['content'] : "";
  5535. $tagId = $this->get_args ( 'tagId' ) ? $this->get_args ( 'tagId' ) : array ();
  5536. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : array ();
  5537. $natureNULL = $this->get_args ( 'natureNULL' ) ? $this->get_args ( 'natureNULL' ) : "";
  5538. $did = $this->get_args ( 'did' ) ? $this->get_args ( 'did' ) : "";
  5539. $stype = $this->get_args ( 'stype' ) ? $this->get_args ( 'stype' ) : "";
  5540. if (! empty ( $title ) && (! empty ( $tagId ) || ! empty ( $did ))) {
  5541. Doo::loadModel ( 'eMailTemplate' );
  5542. $eMailTemplate = new eMailTemplate ();
  5543. Doo::loadModel ( 'eMailJournal' );
  5544. $eMailJournal = new eMailJournal ();
  5545. if ($natureNULL != 'NULL') {
  5546. if (empty ( $tagId ) && ! empty ( $did ) && empty ( $nature )) {
  5547. header ( 'Content-Type:text/html;charset=utf-8' );
  5548. die ( '请选择性质' );
  5549. }
  5550. }
  5551. // annex
  5552. $annexPath = "";
  5553. $annexEXT = $this->_GetFileEXT ( $_FILES ["annex"] ["name"] );
  5554. $annexName = "";
  5555. if (isset ( $_FILES ['annex'] ['name'] )) {
  5556. 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)) {
  5557. $path = DOO::conf ()->SITE_PATH . "upload/emailAnnex/";
  5558. if (! file_exists ( $path . $_FILES ["annex"] ["name"] )) {
  5559. $fileName = time () . "." . $annexEXT;
  5560. $annexName = $_FILES ['annex'] ['name'];
  5561. $annexPath = $path . $fileName;
  5562. move_uploaded_file ( $_FILES ["annex"] ["tmp_name"], $annexPath );
  5563. $annexPath = $this->webPath . $fileName;
  5564. }
  5565. }
  5566. }
  5567. $annexHtml = '<table style="width:100%;margin:10px 0">
  5568. <thead>
  5569. <tr>
  5570. <th align="left" colspan="2">下载附件:</th>
  5571. </tr>
  5572. </thead>
  5573. <tbody>
  5574. <tr>
  5575. <td><a href="' . $annexPath . '" target="_blank">' . $annexName . '</a></td>
  5576. <td>&nbsp;</td>
  5577. </tr>
  5578. </tbody>
  5579. </table>';
  5580. $smartcostMail = 'smartcost_mail_1';
  5581. $info = "";
  5582. // html template
  5583. if ($skin == 1) {
  5584. $html = '<div><table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  5585. <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">
  5586. <tbody><tr>
  5587. <td style="background-color:#ff6501;padding:20px 0 25px;" align="center">
  5588. <span style="vertical-align:bottom;font-size:20px;color:#fff;">' . $title . '</span>
  5589. </td></tr><tr><td>
  5590. <table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;border-top:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  5591. <tbody><tr><td style="padding: 0 40px;" align="left">
  5592. <p style="margin-top:40px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;"><b>CLIENTNAME</b></p>
  5593. </td></tr><tr><td style="padding: 0 40px;" align="left">
  5594. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;">您好,我是纵横公路造价软件 <b>' . $this->staff [0] ['username'] . '</b>:</p>
  5595. <p style="margin-top:0px;margin-bottom:20px;color:#383838;font-size:16px;line-height:32px;">
  5596. ' . $content . '</p>
  5597. </td></tr>
  5598. <tr><td align="left" style="padding: 0 40px;background:#fff">
  5599. ' . $annexHtml . '
  5600. </td></tr>
  5601. <tr>
  5602. <td style="padding: 10px 0 0;background:#F6F6F6;">
  5603. <table>
  5604. <tr>
  5605. <td style="font-size:14pxl;color:#666;padding:0 20px"><b>纵横软件公司' . $this->staff [0] ['category'] . '服务中心</b><br>' . $this->staff [0] ['username'] . '<br>
  5606. <a href="[图片]http://www.smartcost.com.cn" style="color:#666;font-size:12px;text-decoration:underline;">[图片]smartcost.com.cn</a></td>
  5607. <td>
  5608. <table>
  5609. <tr style="font-size:12px;color:#666">
  5610. <th align="right">电话:</th><td style="padding:0 20px 0 0">' . $this->staff [0] ['phone'] . '</td>
  5611. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td>
  5612. </tr>
  5613. <tr style="font-size:12px;color:#666">
  5614. <th align="right">Q Q:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5615. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  5616. </tr>
  5617. </table>
  5618. </td>
  5619. </tr>
  5620. </table>
  5621. </td></tr></tbody></table></td></tr><tr>
  5622. <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>
  5623. </tr></tbody></table></td></tr></tbody></table></div>';
  5624. $info = '<table><tr><th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td></tr>
  5625. <tr><th align="right">联系人:</th><td>' . $this->staff [0] ['username'] . '</td></tr>
  5626. <tr><th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr>
  5627. <tr><th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td></tr>
  5628. <tr><th align="right">邮箱:</th><td>' . $this->staff [0] ['email'] . '</td></tr></table>';
  5629. } elseif ($skin == 2) {
  5630. $smartcostMail = 'smartcost_mail_2';
  5631. $html = '<table cellspacing="0" cellpadding="0" style="background-color:#e4e4e4; width:100%;"><tbody><tr><td>
  5632. <table align="center" cellspacing="0" cellpadding="0" style="background-color:#f8f8f8; width:640px;margin-bottom:20px">
  5633. <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;">
  5634. <b><span name="titleHtml">' . $title . '</span></b></p></td>
  5635. </tr><tr><td><table align="center" cellspacing="0" cellpadding="0" style="border:1px solid #ddd;"><tbody><tr>
  5636. <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>
  5637. </tr><tr><td align="center" style="background-color:#fff;"><img width="640" height="191" src="http://zonghengvideo.qiniudn.com/hero.jpg"></td>
  5638. </tr><tr><td align="left" style="background-color:#fff;padding:40px;border-bottom:1px solid #ddd;">
  5639. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;"><b>CLIENTNAME</b></p>
  5640. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;">您好,我是纵横公路造价软件 <b>' . $this->staff [0] ['username'] . '</b>:</p>
  5641. <p name="contentHtml" style="margin-top:0px;margin-bottom:15px;color:#383838;font-size:16px;line-height:32px;">' . $content . '</p></td>
  5642. </tr>
  5643. <tr><td align="left" style="padding: 0 40px;background:#fff">
  5644. ' . $annexHtml . '
  5645. </td></tr>
  5646. <tr>
  5647. <td style="padding: 10px 0;background:#F6F6F6">
  5648. <table>
  5649. <tbody>
  5650. <tr>
  5651. <td style="font-size:14pxl;color:#333;padding:0 20px">
  5652. <b>纵横公路造价软件' . $this->staff [0] ['category'] . '服务中心</b><br>' . $this->staff [0] ['username'] . '</td>
  5653. <td>
  5654. <table>
  5655. <tbody>
  5656. <tr style="font-size:12px;color:#666">
  5657. <th align="right">电话:</th><td style="padding:0 20px 0 0">' . $this->staff [0] ['phone'] . '</td>
  5658. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr><tr style="font-size:12px;color:#666">
  5659. <th align="right">Q Q:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5660. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  5661. </tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr>
  5662. <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>
  5663. </tr></tbody></table></td></tr></tbody> </table>';
  5664. $info = '<table><tbody><tr style="font-size:12px;color:#666">
  5665. <th align="right">电话:</th><td style="padding:0 20px 0 0">' . $this->staff [0] ['phone'] . '</td>
  5666. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr><tr style="font-size:12px;color:#666">
  5667. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5668. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  5669. </tr></tbody></table>';
  5670. } else {
  5671. $smartcostMail = 'smartcost_mail_3';
  5672. $html = '<table cellspacing="0" cellpadding="0" style="background-color:#ECF0E1; width:100%">
  5673. <tbody>
  5674. <tr>
  5675. <td>
  5676. <table align="center" cellspacing="0" cellpadding="0" style="width:698px;margin-bottom:30px;margin-top:30px;">
  5677. <tbody>
  5678. <tr>
  5679. <td>
  5680. <table align="center" cellspacing="0" cellpadding="0" style="border:1px solid #ccc;width:100%;border-top:none">
  5681. <tbody>
  5682. <tr>
  5683. <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;">
  5684. <div style="position:relative;text-align:right">
  5685. <b style="font-size:24px;color:#8A9F98;z-index:999"><span name="titleHtml">' . $title . '</span></b>
  5686. <div style="width:80px;height:80px;position:absolute;top:0;left:0"><img src="http://zonghengvideo.qiniudn.com/zonghenglogo.png"></div>
  5687. </div>
  5688. </td>
  5689. </tr>
  5690. <tr>
  5691. <td align="left" style="background-color:#fff;padding:40px;border-bottom:1px solid #ddd;">
  5692. <p style="margin-top:0px;margin-bottom:10px;color:#666;font-size:16px;line-height:32px;"><b>CLIENTNAME</b></p>
  5693. <p style="margin-top:0px;margin-bottom:10px;color:#666;font-size:16px;line-height:32px;">您好,我是纵横公路造价软件 <b>' . $this->staff [0] ['username'] . '</b>:</p>
  5694. <p name="contentHtml" style="margin-top:0px;margin-bottom:15px;color:#666;font-size:16px;line-height:32px;">' . $content . '</p></td>
  5695. </tr>
  5696. <tr><td align="left" style="padding: 0 40px;background:#fff">
  5697. ' . $annexHtml . '
  5698. </td></tr>
  5699. <tr>
  5700. <td style="padding: 10px 0 0;background:#F6F6F6;">
  5701. <table>
  5702. <tbody><tr>
  5703. <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>
  5704. <td>
  5705. <table style="width:100%">
  5706. <tbody><tr style="font-size:12px;color:#496781">
  5707. <th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td>
  5708. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td>
  5709. </tr>
  5710. <tr style="font-size:12px;color:#496781">
  5711. <th align="right">Q Q:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5712. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  5713. </tr>
  5714. </tbody></table>
  5715. </td>
  5716. </tr>
  5717. </tbody></table>
  5718. </td>
  5719. </tr>
  5720. <tr>
  5721. <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>
  5722. </tr>
  5723. </tbody>
  5724. </table></td>
  5725. </tr>
  5726. </tbody>
  5727. </table></td>
  5728. </tr>
  5729. </tbody>
  5730. </table>';
  5731. $info = '<table><tr style="font-size:12px;color:#496781"><th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td>
  5732. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr><tr style="font-size:12px;color:#496781">
  5733. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5734. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td></tr></table>
  5735. ';
  5736. }
  5737. $eMailTemplate->title = $title;
  5738. $eMailTemplate->skin = $skin;
  5739. $eMailTemplate->content = $content;
  5740. if (! empty ( $tagId ))
  5741. $eMailTemplate->tag = implode ( ",", $tagId );
  5742. $eMailTemplate->staffId = $this->staff [0] ['sid'];
  5743. $eMailTemplate->staffName = $this->staff [0] ['username'];
  5744. $eMailTemplate->status = 0;
  5745. $eMailTemplate->html = $html;
  5746. $eMailTemplate->annex = $annexPath;
  5747. $eMailTemplate->annexName = $annexName;
  5748. $etid = $eMailTemplate->insert ();
  5749. // create email list
  5750. Doo::loadModel ( 'tag_client' );
  5751. $tagClient = new tag_client ();
  5752. Doo::loadModel ( 'client' );
  5753. $client = new client ();
  5754. Doo::loadModel ( 'eMailList' );
  5755. $eMailList = new eMailList ();
  5756. Doo::loadModel ( 'company' );
  5757. $company = new company ();
  5758. $tagCondition = "";
  5759. $tagArray = array ();
  5760. foreach ( $tagId as $value ) {
  5761. array_push ( $tagArray, " tag like '%" . $value . "%' " );
  5762. }
  5763. if (! empty ( $tagArray ))
  5764. $tagCondition = ' and (' . implode ( " or ", $tagArray ) . ')';
  5765. $clientList = $tagClient->find ( array (
  5766. 'select' => 'client',
  5767. 'where' => 'sid=' . $this->staff [0] ['sid'] . $tagCondition,
  5768. 'asArray' => true
  5769. ) );
  5770. $clientArray = array ();
  5771. foreach ( $clientList as $value ) {
  5772. array_push ( $clientArray, $value ['client'] );
  5773. }
  5774. $clientEmailList = array ();
  5775. if (! empty ( $clientArray ))
  5776. $clientEmailList = $client->find ( array (
  5777. 'select' => 'email,cid,nicename as clientname,companyname',
  5778. 'where' => 'cid in (' . implode ( ",", $clientArray ) . ')',
  5779. 'asArray' => true
  5780. ) );
  5781. //
  5782. if ($stype == 2) {
  5783. // 获取性质相关数据
  5784. $cidList = '';
  5785. if ($natureNULL == '') {
  5786. $nD = array ();
  5787. foreach ( $nature as $key => $value ) {
  5788. array_push ( $nD, ' nature like "' . $value . '"' );
  5789. // $nD=' nature like "'.$value.'"';
  5790. }
  5791. $nD = implode ( ' or ', $nD );
  5792. $companycid = $company->find ( array (
  5793. 'select' => 'cid',
  5794. 'where' => $nD,
  5795. 'asArray' => true
  5796. ) );
  5797. $cidList = array ();
  5798. foreach ( $companycid as $key => $value ) {
  5799. array_push ( $cidList, $value ['cid'] );
  5800. }
  5801. $cidList = implode ( ',', $cidList );
  5802. if (! empty ( $cidList ))
  5803. $cidList = ' and companyid in (' . $cidList . ')';
  5804. else
  5805. $cidList = '';
  5806. }
  5807. // 'select'=>'email,cid,nicename as clientname,companyname,district'
  5808. $clientEmailList = $client->find ( array (
  5809. 'select' => 'email,cid,nicename as clientname,companyname,district',
  5810. 'where' => 'district like "' . $did . ',%" ' . $cidList,
  5811. 'asArray' => true
  5812. ) );
  5813. }
  5814. // ;datediff(curdate(), 'date')>=10
  5815. $eMailJournal->delete ( array (
  5816. 'where' => "datediff(curdate(), date)>=7"
  5817. ) );
  5818. $checkMail = $eMailJournal->find ( array (
  5819. 'where' => 'DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(date)',
  5820. ' groupby' => 'email',
  5821. 'asArray' => true
  5822. ) );
  5823. $emailNameList = $emailArray = $illegalEmail = $sendEmail = array ();
  5824. Doo::db ()->beginTransaction ();
  5825. foreach ( $clientEmailList as $value ) {
  5826. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  5827. if (! empty ( $checkMail )) {
  5828. $falg = true;
  5829. foreach ( $checkMail as $v ) {
  5830. if ($v ['email'] == $value ['email']) {
  5831. $Bdate = strtotime ( $v ['date'] ) + 7 * 24 * 3600;
  5832. if ($Bdate <= time ()) {
  5833. array_push ( $emailArray, $value ['email'] );
  5834. array_push ( $emailNameList, $value );
  5835. $eMailJournal->date = date ( "Y-m-d" );
  5836. $eMailJournal->update ( array (
  5837. 'where' => 'ejid=' . $v ['ejid']
  5838. ) );
  5839. } else {
  5840. array_push ( $sendEmail, $value );
  5841. }
  5842. $falg = false;
  5843. break;
  5844. }
  5845. }
  5846. if ($falg) {
  5847. array_push ( $emailArray, $value ['email'] );
  5848. array_push ( $emailNameList, $value );
  5849. $eMailJournal->clientId = $value ['cid'];
  5850. $eMailJournal->status = 1;
  5851. $eMailJournal->email = $value ['email'];
  5852. $eMailJournal->date = date ( "Y-m-d" );
  5853. // $eMailJournal->insert();
  5854. }
  5855. } else {
  5856. array_push ( $emailArray, $value ['email'] );
  5857. array_push ( $emailNameList, $value );
  5858. $eMailJournal->clientId = $value ['cid'];
  5859. $eMailJournal->status = 1;
  5860. $eMailJournal->email = $value ['email'];
  5861. $eMailJournal->date = date ( "Y-m-d" );
  5862. // $eMailJournal->insert();
  5863. }
  5864. } else {
  5865. array_push ( $illegalEmail, $value );
  5866. }
  5867. }
  5868. Doo::db ()->commit ();
  5869. // echo json_encode($illegalEmail);
  5870. // json_encode(array_slice($illegalEmail,0,100))
  5871. // $kk=gzcompress();
  5872. // $ll=gzuncompress($kk);
  5873. // ."</br>".strlen($kk)."</br>".strlen($ll);die;
  5874. $size = floor ( count ( $emailArray ) / 3 );
  5875. if (! empty ( $emailArray )) {
  5876. if (count ( $emailArray ) < 3) {
  5877. $list = array (
  5878. 0 => $emailArray,
  5879. 1 => array (),
  5880. 2 => array ()
  5881. );
  5882. } else
  5883. $list = array_chunk ( $emailArray, $size );
  5884. } else
  5885. $list = array (
  5886. 0 => array (),
  5887. 1 => array (),
  5888. 2 => array ()
  5889. );
  5890. $emailJson = array ();
  5891. foreach ( $list as $value ) {
  5892. $em = array ();
  5893. foreach ( $value as $v ) {
  5894. array_push ( $em, $v );
  5895. }
  5896. array_push ( $emailJson, $em );
  5897. }
  5898. $size = floor ( count ( $emailNameList ) / 3 );
  5899. if (! empty ( $emailNameList )) {
  5900. if (count ( $emailNameList ) < 3) {
  5901. $list = array (
  5902. 0 => $emailNameList,
  5903. 1 => array (),
  5904. 2 => array ()
  5905. );
  5906. } else
  5907. $list = array_chunk ( $emailNameList, $size );
  5908. } else
  5909. $list = array (
  5910. 0 => array (),
  5911. 1 => array (),
  5912. 2 => array ()
  5913. );
  5914. $emailNameJson = array ();
  5915. foreach ( $list as $value ) {
  5916. $em = array ();
  5917. foreach ( $value as $v ) {
  5918. array_push ( $em, $v );
  5919. }
  5920. array_push ( $emailNameJson, $em );
  5921. }
  5922. //
  5923. $eMailList->date = date ( "Y-m-d" );
  5924. $eMailList->clientEmail = base64_encode ( gzcompress ( json_encode ( $emailJson [0] ) ) );
  5925. $eMailList->clientEmail2 = base64_encode ( gzcompress ( json_encode ( $emailJson [1] ) ) );
  5926. $eMailList->clientEmail3 = base64_encode ( gzcompress ( json_encode ( $emailJson [2] ) ) );
  5927. $eMailList->clientName = base64_encode ( gzcompress ( json_encode ( $emailNameJson [0] ) ) );
  5928. $eMailList->clientName2 = base64_encode ( gzcompress ( json_encode ( $emailNameJson [1] ) ) );
  5929. $eMailList->clientName3 = base64_encode ( gzcompress ( json_encode ( $emailNameJson [2] ) ) );
  5930. $eMailList->illegalEmail = json_encode ( array_slice ( $illegalEmail, 0, 100 ) ); // json_encode($illegalEmail);
  5931. $eMailList->sendEmail = json_encode ( $sendEmail );
  5932. $eMailList->etid = $etid;
  5933. $eMailList->templateName = $smartcostMail;
  5934. $eMailList->eTitle = $title;
  5935. $eMailList->html = $html;
  5936. $eMailList->content = $content;
  5937. $eMailList->info = $info;
  5938. if (! empty ( $annexName ))
  5939. $eMailList->annex = $annexHtml;
  5940. $eMailList->annexName = $annexName;
  5941. $eMailList->staffId = $this->staff [0] ['sid'];
  5942. $eMailList->staffName = $this->staff [0] ['username'];
  5943. if ($stype == 1)
  5944. $eMailList->tag = implode ( ",", $tagId );
  5945. if ($stype == 2) {
  5946. $eMailList->districtId = $did;
  5947. $eMailList->nature = implode ( ",", $nature );
  5948. }
  5949. $eMailList->insert ();
  5950. // 创建邮件地址
  5951. // 'http://sendcloud.sohu.com/webapi/list_member.add.json';
  5952. // print_r($emailJson);
  5953. // die;
  5954. return "/eMailList";
  5955. }
  5956. return "/eMailTask";
  5957. }
  5958. function eMailList() {
  5959. Doo::loadModel ( 'eMailList' );
  5960. $eMailList = new eMailList ();
  5961. Doo::loadModel ( 'tag' );
  5962. $tag = new tag ();
  5963. $mailList = $eMailList->find ( array (
  5964. 'where' => 'staffId=' . $this->staff [0] ['sid'],
  5965. 'desc' => 'elid',
  5966. 'asArray' => true
  5967. ) );
  5968. foreach ( $mailList as $key => $value ) {
  5969. $mailList [$key] ['clientName2'] = $mailList [$key] ['clientName3'] = array ();
  5970. $mailList [$key] ['clientName'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName'] ) ), true );
  5971. if (! empty ( $value ['clientName2'] ))
  5972. $mailList [$key] ['clientName2'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName2'] ) ), true );
  5973. if (! empty ( $value ['clientName3'] ))
  5974. $mailList [$key] ['clientName3'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName3'] ) ), true );
  5975. $mailList [$key] ['illegalEmail'] = json_decode ( $value ['illegalEmail'], true );
  5976. $mailList [$key] ['sendEmail'] = json_decode ( $value ['sendEmail'], true );
  5977. $mailList [$key] ['clientCount'] = count ( $mailList [$key] ['clientName'] ) + count ( $mailList [$key] ['clientName2'] ) + count ( $mailList [$key] ['clientName3'] );
  5978. $mailList [$key] ['tag'] = array ();
  5979. if (! empty ( $value ['tag'] ))
  5980. $mailList [$key] ['tag'] = $tag->find ( array (
  5981. 'where' => 'tid in ( ' . $value ['tag'] . ') ',
  5982. 'asArray' => true
  5983. ) );
  5984. }
  5985. $data ['mailList'] = $mailList;
  5986. $data ['memu'] = "eMailTask";
  5987. $data ['staff'] = $this->staff;
  5988. $data ['mailMemu'] = 'eMailList';
  5989. $this->render ( "/mail_list", $data );
  5990. }
  5991. function showEmailContent() {
  5992. $elid = isset ( $this->params ['elid'] ) ? $this->params ['elid'] : 0;
  5993. Doo::loadModel ( 'eMailList' );
  5994. $eMList = new eMailList ();
  5995. $isSend = $eMList->getOne ( array (
  5996. 'where' => 'elid =' . $elid . '',
  5997. 'asArray' => true
  5998. ) );
  5999. echo htmlspecialchars ( $isSend ['content'] );
  6000. }
  6001. function postEmail() {
  6002. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  6003. $elid = isset ( $this->params ['elid'] ) ? $this->params ['elid'] : 0;
  6004. $send = isset ( $this->params ['send'] ) ? $this->params ['send'] : 0;
  6005. Doo::loadModel ( 'eMailList' );
  6006. $eMList = new eMailList ();
  6007. if (! empty ( $elid )) {
  6008. $isSend = $eMList->getOne ( array (
  6009. 'select' => 'send' . $send,
  6010. 'where' => 'elid =' . $elid . ' and status=0 and send' . $send . '=1',
  6011. 'asArray' => true
  6012. ) );
  6013. if (! empty ( $isSend ))
  6014. die ( '这批邮件已经发送' );
  6015. if ($send == 1)
  6016. $send = '';
  6017. $eMailList = $eMList->getOne ( array (
  6018. 'select' => 'eTitle,staffName,clientName' . $send . ' as clientName,clientEmail' . $send . ' as clientEmail,annex,info,content,templateName',
  6019. 'where' => 'elid =' . $elid . ' and status=0',
  6020. 'asArray' => true
  6021. ) );
  6022. if ($send == "")
  6023. $send = 1;
  6024. $sql = "update `CLD_eMailList` set send" . $send . "='1' where elid = '" . $elid . "'";
  6025. Doo::db ()->query ( $sql );
  6026. $isSend = $eMList->getOne ( array (
  6027. 'where' => 'elid =' . $elid . ' and status=0 and send1=1 and send2=1 and send3=1',
  6028. 'asArray' => true
  6029. ) );
  6030. if (! empty ( $isSend )) {
  6031. $sql = "update `CLD_eMailList` set status='2' where elid = '" . $elid . "'";
  6032. Doo::db ()->query ( $sql );
  6033. }
  6034. $toFormatMail = array ();
  6035. $sub = array ();
  6036. // file_put_contents("test.txt", "This is another something.<br/>", FILE_APPEND);
  6037. // sleep(4);
  6038. // die;
  6039. $toMail = json_decode ( gzuncompress ( base64_decode ( $eMailList ['clientEmail'] ) ), true );
  6040. // $toMailCount=count($toMail);
  6041. $subMail = json_decode ( gzuncompress ( base64_decode ( $eMailList ['clientName'] ) ), true );
  6042. $chunkMail = array_chunk ( $toMail, 80 );
  6043. $chunkSubMail = array_chunk ( $subMail, 80 );
  6044. $vii = 0;
  6045. foreach ( $chunkMail as $key => $value ) {
  6046. $l = $s = $c = $i = $cate = $con = $annex = array ();
  6047. $toFormatMail ['to'] = $value;
  6048. $cn = $chunkSubMail [$key];
  6049. foreach ( $cn as $v ) {
  6050. array_push ( $l, $eMailList ['eTitle'] );
  6051. array_push ( $s, $eMailList ['staffName'] );
  6052. array_push ( $c, $v ['clientname'] );
  6053. array_push ( $annex, $eMailList ['annex'] );
  6054. array_push ( $i, $eMailList ['info'] );
  6055. // array_push($con, $eMailList['content']);
  6056. array_push ( $cate, $this->staff [0] ['category'] );
  6057. }
  6058. $sub ['%eTitle%'] = $l;
  6059. $sub ['%staffName%'] = $s;
  6060. $sub ['%clientName%'] = $c;
  6061. $sub ['%category%'] = $cate;
  6062. $sub ['%info%'] = $i;
  6063. // $sub['%content%']=$con;
  6064. $sub ['%annex%'] = $annex;
  6065. $toFormatMail ['sub'] = $sub;
  6066. $url = 'http://sendcloud.sohu.com/webapi/mail.send_template.xml';
  6067. $param = array (
  6068. 'api_user' => 'cldmail',
  6069. 'api_key' => 'cDO1GjtY1seH',
  6070. 'template_invoke_name' => $eMailList ['templateName'],
  6071. 'from' => $this->staff [0] ['email'],
  6072. 'fromname' => '纵横' . $eMailList ['staffName'],
  6073. 'subject' => $eMailList ['eTitle'],
  6074. 'substitution_vars' => json_encode ( $toFormatMail )
  6075. );
  6076. $post_data = http_build_query ( $param );
  6077. $ch = curl_init ();
  6078. curl_setopt ( $ch, CURLOPT_POST, 1 );
  6079. curl_setopt ( $ch, CURLOPT_URL, $url );
  6080. curl_setopt ( $ch, CURLOPT_HEADER, false ); // 设定是否输出页面内容
  6081. curl_setopt ( $ch, CURLOPT_NOBODY, false );
  6082. curl_setopt ( $ch, CURLOPT_POSTFIELDS, $post_data );
  6083. $result = curl_exec ( $ch );
  6084. curl_close ( $ch );
  6085. /*
  6086. * if($result=='success'){ $eM=new eMailList(); $eM->status='2'; $eM->update(array('where'=>'elid=?','param'=>array($elid))); }
  6087. */
  6088. }
  6089. // die;
  6090. return '/eMailList';
  6091. }
  6092. }
  6093. function a() {
  6094. $substitution_vars = $this->get_args ( 'substitution_vars' );
  6095. file_put_contents ( DOO::conf ()->SITE_PATH . 'upload/' . "_" . time () . "_" . rand ( 100, 999 ) . ".log", $substitution_vars );
  6096. }
  6097. function deleteEmail() {
  6098. $elid = isset ( $this->params ['elid'] ) ? $this->params ['elid'] : 0;
  6099. if (! empty ( $elid )) {
  6100. $sql = "DELETE FROM `CLD_eMailList` where elid = '" . $elid . "'";
  6101. Doo::db ()->query ( $sql );
  6102. return '/eMailList';
  6103. }
  6104. }
  6105. /**
  6106. * 发送post请求
  6107. * @param string $url 请求地址
  6108. * @param array $post_data post键值对数据
  6109. * @return string
  6110. */
  6111. function sendPost($url, $post_data) {
  6112. $postdata = http_build_query ( $post_data );
  6113. // X-Amzn-Authorization: AWS3 AWSAccessKeyId=AKIAIDSE5VYNX5ERJHXQ,Signature=lBP67vCvGlDMBQ=dofZxg8E8SUEXAMPLE,Algorithm=HmacSHA256,SignedHeaders=qG1BdSh9QyYPlWLnjqvjDXjyPdFjl7fUSkfs0Hk2
  6114. $options = array (
  6115. 'http' => array (
  6116. 'method' => 'POST',
  6117. 'header' => '
  6118. Content-Type: application/x-www-form-urlencoded
  6119. ',
  6120. 'content' => $postdata,
  6121. 'timeout' => 15 * 60
  6122. )
  6123. ); // 超时时间(单位:s)
  6124. $context = stream_context_create ( $options );
  6125. $result = file_get_contents ( $url, false, $context );
  6126. return $result;
  6127. }
  6128. function avatar() {
  6129. $result = array ();
  6130. $result ['success'] = false;
  6131. $successNum = 0;
  6132. // 定义一个变量用以储存当前头像的序号
  6133. $avatarNumber = 1;
  6134. $i = 0;
  6135. $msg = '';
  6136. // 上传目录
  6137. $dir = DOO::conf ()->SITE_PATH . "global/avatar";
  6138. // 遍历所有文件域
  6139. while ( list ( $key, $val ) = each ( $_FILES ) ) {
  6140. if ($_FILES [$key] ['error'] > 0)
  6141. $msg .= $_FILES [$key] ['error'];
  6142. else {
  6143. $fileName = 'avatar_' . $this->staff [0] ['sid'];
  6144. // 原始图片(file 域的名称:__source,如果客户端定义可以上传的话,可在此处理)。
  6145. if ($key == '__source') { // 当前头像基于原图的初始化参数,用于修改头像时保证界面的视图跟保存头像时一致。帮助提升用户体验度。修改头像时设置默认加载的原图的url为此图片的url+该参数即可。
  6146. $initParams = $_POST ["__initParams"];
  6147. $virtualPath = $dir . "/" . $fileName . "_" . $avatarNumber . ".jpg";
  6148. $result ['sourceUrl'] = '/' . $virtualPath . $initParams;
  6149. move_uploaded_file ( $_FILES [$key] ["tmp_name"], $virtualPath );
  6150. $successNum ++;
  6151. } else if (strpos ( $key, '__avatar' ) === 0) { // 头像图片(file 域的名称:__avatar1,2,3...)。
  6152. $virtualPath = $dir . "/" . $fileName . "_" . $avatarNumber . ".jpg";
  6153. $result ['avatarUrls'] [$i] = '/' . $virtualPath;
  6154. move_uploaded_file ( $_FILES [$key] ["tmp_name"], $virtualPath );
  6155. $avatarNumber ++;
  6156. $successNum ++;
  6157. $i ++;
  6158. }
  6159. }
  6160. }
  6161. $result ['msg'] = $msg;
  6162. if ($successNum > 0)
  6163. $result ['success'] = true;
  6164. // 返回图片的保存结果(返回内容为json字符串)
  6165. Doo::loadModel ( 'staff' );
  6166. $staff = new staff ();
  6167. $staff->sid = $this->staff [0] ['sid'];
  6168. $staff->avatar = "/global/avatar/" . $fileName;
  6169. $staff->update ();
  6170. echo json_encode ( $result );
  6171. }
  6172. function lockUpload() {
  6173. // move_uploaded_file($_FILES['Filedata']['tmp_name'], "/upload/".$_FILES['Filedata']['name']);
  6174. if (isset ( $_FILES ['Filedata'] ['name'] )) {
  6175. $file = $_FILES ['Filedata'] ['tmp_name'];
  6176. $error = false;
  6177. if (! is_uploaded_file ( $file )) {
  6178. $error = '400 Bad Request';
  6179. }
  6180. if ($error) {
  6181. header ( 'HTTP/1.0 ' . $error );
  6182. die ( 'Error ' . $error );
  6183. } else {
  6184. include (DOO::conf ()->SITE_PATH . 'protected/plugin/io.han.php');
  6185. $this->IoHandler = new IoHandler ();
  6186. $pics = explode ( '.', $_FILES ['Filedata'] ['name'] );
  6187. // $filedir=$_POST['time'];
  6188. // 调用定义物理路径
  6189. $t = DOO::conf ()->SITE_PATH . "upload/";
  6190. $this->IoHandler->MakeDir ( $t );
  6191. $filename = $this->_GetFileEXT ( $_FILES ['Filedata'] ['name'] );
  6192. if ($filename != 'xlsx')
  6193. return "";
  6194. // $upload_dir = $t."/".time().rand(10,100).".".$filename;
  6195. $upload_file = iconv ( "UTF-8", "GB2312", $_FILES ["Filedata"] ["name"] );
  6196. $upload_dir = $t . "/" . $upload_file;
  6197. $k = move_uploaded_file ( $file, $upload_dir );
  6198. if ($k) {
  6199. // "series/".$filedir."/".
  6200. $m = round ( $_FILES ['Filedata'] ['size'] / 1024 / 1024, 2 );
  6201. echo $pics [0] . "." . $filename . "#" . $m . "#" . $_FILES ['Filedata'] ['size'];
  6202. }
  6203. }
  6204. }
  6205. }
  6206. function getAuthentication() {
  6207. }
  6208. function loadCVS() {
  6209. Doo::loadModel ( 'longle' );
  6210. $longle = new longle ();
  6211. $list = $longle->find ( array (
  6212. 'select' => 'key_num',
  6213. 'asArray' => TRUE
  6214. ) );
  6215. $file = fopen ( DOO::conf ()->SITE_PATH . "upload/key2.csv", 'r' );
  6216. while ( $data = fgetcsv ( $file ) ) {
  6217. $goods_list [$data [0]] = $data [1];
  6218. }
  6219. fclose ( $file );
  6220. $sqlArray = array ();
  6221. $sql = 'UPDATE CLD_longle SET SerialNumber = CASE key_num ';
  6222. foreach ( $list as $key => $value ) {
  6223. if (array_key_exists ( $value ['key_num'], $goods_list )) {
  6224. // echo $value['key_num'].'-'.$goods_list[$value['key_num']].'<br/>';
  6225. // $longle->SerialNumber=$goods_list[$value['key_num']];
  6226. // $longle->update(array('where'=>'key_num="'.$value['key_num'].'"'));
  6227. $sql .= ' WHEN "' . $value ['key_num'] . '" THEN "' . $goods_list [$value ['key_num']] . '" ';
  6228. array_push ( $sqlArray, '"' . $value ['key_num'] . '"' );
  6229. unset ( $goods_list [$value ['key_num']] );
  6230. }
  6231. }
  6232. $sql .= 'END WHERE key_num IN (' . implode ( ',', $sqlArray ) . ')';
  6233. echo $sql . '<br/>--------------------------------<br/>';
  6234. foreach ( $goods_list as $key => $value ) {
  6235. echo $key . ',' . $value . '<br/>';
  6236. }
  6237. }
  6238. private function getRandChar($length) {
  6239. $str = null;
  6240. $strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
  6241. $max = strlen ( $strPol ) - 1;
  6242. for($i = 0; $i < $length; $i ++) {
  6243. $str .= $strPol [rand ( 0, $max )]; // rand($min,$max)生成介于min和max两个数之间的一个随机整数
  6244. }
  6245. return $str;
  6246. }
  6247. // private function getReceiptCount(){
  6248. // $status=2;
  6249. // $year=date('Y');
  6250. // Doo::loadModel('receipt');
  6251. // $receipt=new receipt();
  6252. // $dateCondition=" and Year(date) =".$year;
  6253. // $approvalCondition=' and nowStaff like "%'.$this->staff[0]['sid'].'%" ';
  6254. // $receiptList=$receipt->find(array('where'=>' status='.$status.$dateCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  6255. // return count($receiptList);
  6256. // }
  6257. // private function getExeCount(){
  6258. // Doo::loadModel('receipt');
  6259. // $receipt=new receipt();
  6260. // $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));
  6261. // return count($receiptList);
  6262. // }
  6263. /**
  6264. * 格式化excel文件为数组
  6265. * @param unknown_type $file_url
  6266. * @param unknown_type $mcid
  6267. */
  6268. function _format_excel_to_array($file_url = "") {
  6269. if (! file_exists ( $file_url ))
  6270. return array ();
  6271. Doo::loadClass ( 'PHPExcel' );
  6272. $PHPExcel = new PHPExcel ();
  6273. $PHPReader = new PHPExcel_Reader_Excel2007 ();
  6274. if (! $PHPReader->canRead ( $file_url )) {
  6275. $PHPReader = new PHPExcel_Reader_Excel5 ();
  6276. if (! $PHPReader->canRead ( $file_url )) {
  6277. echo 'no Excel';
  6278. return;
  6279. }
  6280. }
  6281. $PHPExcel = $PHPReader->load ( $file_url );
  6282. /**
  6283. * 读取excel文件中的第一个工作表
  6284. */
  6285. $currentSheet = $PHPExcel->getSheet ( 0 );
  6286. /**
  6287. * 取得最大的列号
  6288. */
  6289. $allColumn = $currentSheet->getHighestColumn ();
  6290. /**
  6291. * 取得一共有多少行
  6292. */
  6293. $allRow = $currentSheet->getHighestRow ();
  6294. $excel_array = array ();
  6295. for($currentRow = 2; $currentRow <= $allRow; $currentRow ++) {
  6296. $excel_column = array ();
  6297. // 后期改进
  6298. if ($allColumn == 'AM')
  6299. $allColumn = 'Z';
  6300. /**
  6301. * 从第A列开始输出
  6302. */
  6303. for($currentColumn = 'A'; $currentColumn <= $allColumn; $currentColumn ++) {
  6304. $val = $currentSheet->getCellByColumnAndRow ( ord ( $currentColumn ) - 65, $currentRow )->getValue ();
  6305. /**
  6306. * ord()将字符转为十进制数 iconv ( 'utf-8', 'gb2312',
  6307. */
  6308. $val = "'" . addslashes ( $val ) . "'";
  6309. if ($currentColumn == 'A')
  6310. $excel_column ['key_num'] = $val;
  6311. elseif ($currentColumn == 'C')
  6312. $excel_column ['product'] = $val;
  6313. elseif ($currentColumn == 'D') {
  6314. $val = str_replace ( "'", "", $val );
  6315. $excel_column ['make_day'] = $this->excelTime ( $val );
  6316. } elseif ($currentColumn == 'E') {
  6317. $val = str_replace ( "'", "", $val );
  6318. $excel_column ['alloted_time'] = $this->excelTime ( $val );
  6319. } elseif ($currentColumn == 'F') {
  6320. $val = str_replace ( "'", "", $val );
  6321. $excel_column ['version'] = $val;
  6322. } elseif ($currentColumn == 'B') {
  6323. $val = str_replace ( "'", "", $val );
  6324. $excel_column ['SerialNumber'] = $val;
  6325. }
  6326. }
  6327. array_push ( $excel_array, $excel_column );
  6328. }
  6329. return $excel_array;
  6330. }
  6331. function excelTime($date, $time = false) {
  6332. if (function_exists ( 'GregorianToJD' )) {
  6333. if (is_numeric ( $date )) {
  6334. $jd = GregorianToJD ( 1, 1, 1970 );
  6335. $gregorian = JDToGregorian ( $jd + intval ( $date ) - 25569 );
  6336. $date = explode ( '/', $gregorian );
  6337. $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" : '');
  6338. return $date_str;
  6339. }
  6340. } else {
  6341. $date = $date > 25568 ? $date + 1 : 25569;
  6342. /* There was a bug if Converting date before 1-1-1970 (tstamp 0) */
  6343. $ofs = (70 * 365 + 17 + 2) * 86400;
  6344. $date = date ( "Y-m-d", ($date * 86400) - $ofs ) . ($time ? " 00:00:00" : '');
  6345. }
  6346. return $date;
  6347. }
  6348. function _GetFileEXT($filename) {
  6349. $pics = explode ( '.', $filename );
  6350. $num = count ( $pics );
  6351. return $pics [$num - 1];
  6352. }
  6353. /**
  6354. * 获取get或者POST值
  6355. * @param string $name 属性名称
  6356. * @return fixed 值
  6357. */
  6358. function get_args($name) {
  6359. if (isset ( $_GET [$name] )) {
  6360. if (is_array ( $_GET [$name] ))
  6361. return $_GET [$name];
  6362. else {
  6363. return addslashes ( $_GET [$name] );
  6364. }
  6365. } elseif (isset ( $_POST [$name] )) {
  6366. if (is_array ( $_POST [$name] ))
  6367. return $_POST [$name];
  6368. else {
  6369. return addslashes ( $_POST [$name] );
  6370. }
  6371. } else {
  6372. return false;
  6373. }
  6374. }
  6375. function get_previous($on_page = 1) {
  6376. return $on_page != 0 ? $on_page - 1 : $on_page;
  6377. }
  6378. /**
  6379. * 获得分页数据
  6380. * @param unknown_type $table
  6381. * @param unknown_type $condition
  6382. * @param unknown_type $on_page
  6383. * @param unknown_type $page_size
  6384. */
  6385. function get_Tpage($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $tagSQL) {
  6386. $page_c = "";
  6387. $page ['previous'] = $this->get_previous ( $on_page );
  6388. $page ['on_page'] = $on_page;
  6389. $total_count = $this->get_table_Tcount ( $table, $condition, $tagSQL );
  6390. $total = intval ( $total_count / $page_size );
  6391. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  6392. $page ['total_data'] = $total_count;
  6393. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  6394. $i = 1;
  6395. $page_max = 1;
  6396. if ($on_page > 10) {
  6397. $page_max = intval ( $on_page / 10 ) + 1;
  6398. $i = intval ( $on_page / 10 ) * 10 - 1;
  6399. }
  6400. $page ['page'] = $page_c;
  6401. $page ['lower'] = (-- $on_page) * $page_size;
  6402. return $page;
  6403. }
  6404. /**
  6405. * 获得分页数据
  6406. * @param unknown_type $table
  6407. * @param unknown_type $condition
  6408. * @param unknown_type $on_page
  6409. * @param unknown_type $page_size
  6410. */
  6411. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page", $staffid = "", $search, $tooltip, $cateid, $tagSQL) {
  6412. $page_c = "";
  6413. $page ['previous'] = $this->get_previous ( $on_page );
  6414. $page ['on_page'] = $on_page;
  6415. $total_count = $this->get_table_count ( $table, $condition, $staffid, $search, $tooltip, $cateid, $tagSQL );
  6416. $total = intval ( $total_count / $page_size );
  6417. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  6418. $page ['total_data'] = $total_count;
  6419. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  6420. $i = 1;
  6421. $page_max = 1;
  6422. if ($on_page > 10) {
  6423. $page_max = intval ( $on_page / 10 ) + 1;
  6424. $i = intval ( $on_page / 10 ) * 10 - 1;
  6425. }
  6426. for(; $i <= $page ['total_page']; $i ++) {
  6427. if ($i == $on_page) {
  6428. if ($other == "page")
  6429. $page_c .= '<a href="javascript:void(0);" class="current">' . $i . '</a>';
  6430. else
  6431. $page_c .= '&nbsp;<span class="current">' . $i . '</span>&nbsp;';
  6432. } else if ($other == "page")
  6433. $page_c .= '<a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a>';
  6434. else
  6435. $page_c .= '&nbsp;<a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a>&nbsp;';
  6436. if ($i == (10 * $page_max))
  6437. break;
  6438. }
  6439. $page ['page'] = $page_c;
  6440. $page ['lower'] = (-- $on_page) * $page_size;
  6441. return $page;
  6442. }
  6443. /**
  6444. * 获取总页数
  6445. * @param unknown_type $table
  6446. * @param unknown_type $condition
  6447. */
  6448. public function get_table_Tcount($table = "", $condition = "", $tagSQL) {
  6449. if ($tagSQL)
  6450. $sql = "select count(*) as count from CLD_tagCompanyNexus as a left join CLD_company as b on (a.company=b.cid ) where " . $condition;
  6451. else
  6452. $sql = "select count(*) as count from CLD_company where " . $condition;
  6453. $query = Doo::db ()->query ( $sql );
  6454. $result = $query->fetch ();
  6455. return $result ['count'];
  6456. }
  6457. /**
  6458. * 获取总页数
  6459. * @param unknown_type $table
  6460. * @param unknown_type $condition
  6461. */
  6462. public function get_table_count($table = "", $condition = "", $staffid = "", $search, $tooltip, $cateid, $tagSQL) {
  6463. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  6464. // echo $staffid;die;
  6465. //
  6466. if (! empty ( $staffid )) {
  6467. // $staffid="and a.sid= '".$staffid."'"; " . $table . " as a left join on (a.cid=b.cid ".$staffid.")
  6468. $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;
  6469. } else {
  6470. if (strlen ( $condition ) == 1 || empty ( $condition ))
  6471. $sql = "select count(*) as count from CLD_client as a " . $condition;
  6472. else
  6473. $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;
  6474. }
  6475. if (! empty ( $search ))
  6476. $sql = "select count(*) as count from CLD_client as a where 1 " . $condition;
  6477. if (! empty ( $tooltip )) {
  6478. $condition = str_replace ( "a.", "c.", $condition );
  6479. if ($tagSQL)
  6480. $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;
  6481. else
  6482. $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;
  6483. }
  6484. // echo $sql;
  6485. $query = Doo::db ()->query ( $sql );
  6486. $result = $query->fetch ();
  6487. return $result ['count'];
  6488. }
  6489. }
  6490. ?>