MainController.php 258 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736
  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. $CC2 ++;
  2328. }
  2329. }
  2330. }
  2331. if (! empty ( $clientCount ) && ! empty ( $lv3 )) {
  2332. $CC3 = 0;
  2333. foreach ( $clientCount as $key => $value ) {
  2334. if (strpos ( $value ['district'], $lv3 )) {
  2335. $CC3 ++;
  2336. }
  2337. }
  2338. }
  2339. }
  2340. Doo::loadModel ( 'remind' );
  2341. $remind = new remind ();
  2342. // and date_add(time, INTERVAL day DAY) <= CURDATE()
  2343. $remindList = $remind->find ( array (
  2344. 'where' => "staffID = '" . $this->staff [0] ['sid'] . "' and status=0 ",
  2345. 'asc' => 'date_add(time, INTERVAL day DAY)',
  2346. 'asArray' => TRUE
  2347. ) );
  2348. $rc = 0;
  2349. foreach ( $remindList as $key => $value ) {
  2350. $a = strtotime ( $value ['time'] . " +" . $value ['day'] . " days" );
  2351. $b = strtotime ( date ( 'y-m-d' ) );
  2352. if ($a <= $b) {
  2353. $rc ++;
  2354. $remindList [$key] ['isRemind'] = 1;
  2355. } else
  2356. $remindList [$key] ['isRemind'] = 0;
  2357. $remindList [$key] ['Ctime'] = date ( 'm-d', strtotime ( $value ['time'] ) );
  2358. $remindList [$key] ['Etime'] = date ( 'm-d', strtotime ( $value ['time'] . " +" . $value ['day'] . " days" ) );
  2359. }
  2360. $data ['remindCount'] = $rc;
  2361. $data ['remindList'] = $remindList;
  2362. $data ['CC1'] = $CC1;
  2363. $data ['CC2'] = $CC2;
  2364. $data ['CC3'] = $CC3;
  2365. $data ['lv1'] = $lv1;
  2366. $data ['lv2'] = $lv2;
  2367. $data ['lv3'] = $lv3;
  2368. $data ['lv4'] = $lv4;
  2369. $data ['districtLv'] = $districtLv;
  2370. $data ['tagList'] = $tagList;
  2371. $data ['tooltip'] = $this->tooltip;
  2372. $data ['ttip'] = $tooltip;
  2373. $data ['search'] = $search;
  2374. $data ['totalData'] = $pageinfo ['total_data'];
  2375. // $data['messagehtml']=$html;
  2376. $this->render ( "/contacts_client", $data );
  2377. }
  2378. function remindCL() {
  2379. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2380. Doo::loadModel ( 'remind' );
  2381. $remind = new remind ();
  2382. $remind->status = 1;
  2383. $remind->update ( array (
  2384. 'where' => "staffID = '" . $this->staff [0] ['sid'] . "' and rid=" . $rid,
  2385. 'asArray' => TRUE
  2386. ) );
  2387. return "/contacts";
  2388. }
  2389. function communication() {
  2390. $data ['memu'] = "contacts";
  2391. $data ['staff'] = $this->staff;
  2392. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2393. Doo::loadModel ( 'L_category' );
  2394. $L_category = new L_category ();
  2395. Doo::loadModel ( 'staff' );
  2396. $staff = new staff ();
  2397. Doo::loadModel ( 'staffDynamic' );
  2398. $staffDynamic = new staffDynamic ();
  2399. if (! empty ( $cid ))
  2400. $data ['staffList'] = $staff->getStaffByCid ( $cid );
  2401. else
  2402. $data ['staffList'] = $staff->getStaff ( true );
  2403. foreach ( $data ['staffList'] as $key => $value ) {
  2404. if (! empty ( $value ['birthday'] )) {
  2405. $dataD = date ( "d", strtotime ( $value ['birthday'] ) );
  2406. if (date ( 'm' ) == date ( "m", strtotime ( $value ['birthday'] ) )) {
  2407. $now = date ( 'd' );
  2408. $post = $dataD - 7; // date("d",mktime(0,0,0,date("m"),date("d")+7,date("Y")));
  2409. if ($now >= $post && $now <= $dataD) {
  2410. $data ['staffList'] [$key] ['birthday'] = "birthday";
  2411. $data ['staffList'] [$key] ['birthDAY'] = date ( "m-d", strtotime ( $value ['birthday'] ) );
  2412. }
  2413. }
  2414. }
  2415. $happy = date ( "m-d", strtotime ( $value ['birthday'] ) );
  2416. if ($happy == date ( 'm-d' )) {
  2417. $SBL = $staffDynamic->getStaffBirthday ( $happy, $value ['sid'] );
  2418. if (empty ( $SBL )) {
  2419. $staffDynamic->content = '<img src="/global/img/cake.gif"><span class="colOrange">今天过生日!</span>';
  2420. $staffDynamic->cid = $value ['cid'];
  2421. $staffDynamic->category = $value ['category'];
  2422. $staffDynamic->time = time ();
  2423. $staffDynamic->sid = $value ['sid'];
  2424. $staffDynamic->staff = $value ['username'];
  2425. $staffDynamic->insert ();
  2426. }
  2427. }
  2428. }
  2429. $sDynaimic = $staffDynamic->getStaffDynamic ();
  2430. foreach ( $sDynaimic as $key => $value ) {
  2431. $time = date ( "Y-m-d", $value ['time'] );
  2432. $timeArray = explode ( '-', $time );
  2433. $sDynaimic [$key] ['year'] = $timeArray [0];
  2434. $sDynaimic [$key] ['month'] = $timeArray [1];
  2435. $sDynaimic [$key] ['day'] = $timeArray [2];
  2436. }
  2437. $data ['sDynaimic'] = $sDynaimic;
  2438. $data ['category'] = $L_category->getCategory ();
  2439. $data ['cid'] = $cid;
  2440. $this->render ( "/staff_contacts", $data );
  2441. }
  2442. function app() {
  2443. $data ['memu'] = "app";
  2444. $data ['staff'] = $this->staff;
  2445. $this->render ( "/app", $data );
  2446. }
  2447. function synClient() {
  2448. if ($this->staff [0] ['isadmin'] != 1) {
  2449. Doo::loadModel ( 'L_category' );
  2450. Doo::loadModel ( 'client_staff' );
  2451. $client_staff = new client_staff ();
  2452. $cate = new L_category ();
  2453. $district = $cate->getOne ( array (
  2454. 'where' => 'cid=' . $this->staff [0] ['cid'],
  2455. 'asArray' => true
  2456. ) );
  2457. $syn = $client_staff->synClient ( $this->staff [0] ['sid'], $district ['districtid'] );
  2458. $bei = $client_staff->find ( array (
  2459. 'where' => "sid = " . $this->staff [0] ['sid'],
  2460. 'asArray' => true
  2461. ) );
  2462. foreach ( $syn as $value ) {
  2463. $falg = true;
  2464. foreach ( $bei as $v ) {
  2465. if (($v ['cid'] == $value ['cid']) && ($v ['sid'] == $this->staff [0] ['sid'])) {
  2466. $falg = false;
  2467. break;
  2468. }
  2469. }
  2470. if ($falg) {
  2471. $client_staff = new client_staff ();
  2472. $client_staff->sid = $this->staff [0] ['sid'];
  2473. $client_staff->cid = $value ['cid'];
  2474. $client_staff->insert ();
  2475. }
  2476. }
  2477. }
  2478. return "/contacts";
  2479. }
  2480. function DoAddTagCompany() {
  2481. $cid = $this->get_args ( 'id' );
  2482. $tid = $this->get_args ( 'tagALD' );
  2483. Doo::loadModel ( 'tagCompanyNexus' );
  2484. $strtid = implode ( ",", $tid );
  2485. foreach ( $cid as $key => $value ) {
  2486. $tagClient = new tagCompanyNexus ();
  2487. $tagClientInfo = $tagClient->getTagClientBySCid ( $value, $this->staff [0] ['sid'] );
  2488. $ar = explode ( ",", $strtid . ',' . $tagClientInfo ['tag'] );
  2489. $re = array_filter ( array_unique ( $ar ) );
  2490. $tagClient->tag = implode ( ",", $re );
  2491. if (! empty ( $tagClientInfo )) {
  2492. $tagClient->tcid = $tagClientInfo ['tcid'];
  2493. $tagClient->update ();
  2494. } else {
  2495. $tagClient->sid = $this->staff [0] ['sid'];
  2496. $tagClient->company = $value;
  2497. $tagClient->insert ();
  2498. }
  2499. }
  2500. header ( "Location: /mycompany" );
  2501. }
  2502. function DoAddTag() {
  2503. $cid = $this->get_args ( 'id' );
  2504. $tooltipAct = $this->get_args ( 'tooltipAct' ) ? $this->get_args ( 'tooltipAct' ) : "";
  2505. Doo::loadModel ( 'client' );
  2506. if (! empty ( $tooltipAct )) {
  2507. $tid = $this->get_args ( 'tooltiplist' );
  2508. $k = implode ( ",", $tid );
  2509. Doo::loadModel ( 'C_tooltip' );
  2510. $s = " and cateid=" . $this->staff [0] ['cid'];
  2511. if (! empty ( $this->staff [0] ['othercid'] )) {
  2512. $othercid = explode ( ",", $this->staff [0] ['othercid'] );
  2513. foreach ( $othercid as $value ) {
  2514. $s .= " or cateid=" . $value;
  2515. }
  2516. }
  2517. foreach ( $cid as $key => $value ) {
  2518. $C_tooltip = new C_tooltip ();
  2519. $tooltip = $C_tooltip->getOne ( array (
  2520. 'where' => 'cid=' . $value . " " . $s,
  2521. 'asArray' => true
  2522. ) );
  2523. if (empty ( $tooltip )) {
  2524. $C_tooltip->cid = $value;
  2525. $C_tooltip->name = $k;
  2526. $C_tooltip->cateid = $this->staff [0] ['cid'];
  2527. $C_tooltip->insert ();
  2528. } else {
  2529. $C_tooltip->tip = $tooltip ['tip'];
  2530. $C_tooltip->name = $k;
  2531. $C_tooltip->update ();
  2532. }
  2533. }
  2534. } else {
  2535. $tid = $this->get_args ( 'tagALD' );
  2536. Doo::loadModel ( 'tag_client' );
  2537. $strtid = implode ( ",", $tid );
  2538. foreach ( $cid as $key => $value ) {
  2539. $tagClient = new tag_client ();
  2540. $tagClientInfo = $tagClient->getTagClientBySCid ( $value, $this->staff [0] ['sid'] );
  2541. $ar = explode ( ",", $strtid . ',' . $tagClientInfo ['tag'] );
  2542. $re = array_filter ( array_unique ( $ar ) );
  2543. $tagClient->tag = implode ( ",", $re );
  2544. if (! empty ( $tagClientInfo )) {
  2545. $tagClient->tcid = $tagClientInfo ['tcid'];
  2546. $tagClient->update ();
  2547. } else {
  2548. $tagClient->sid = $this->staff [0] ['sid'];
  2549. $tagClient->client = $value;
  2550. $tagClient->insert ();
  2551. }
  2552. }
  2553. }
  2554. header ( "Location: /contacts" );
  2555. }
  2556. function ajaxDeleteTag() {
  2557. $cid = $this->get_args ( 'cid' );
  2558. $tid = $this->get_args ( 'tid' );
  2559. Doo::loadModel ( 'tag_client' );
  2560. $tagClient = new tag_client ();
  2561. $tagInfo = $tagClient->getTagClientBySCid ( $cid, $this->staff [0] ['sid'] );
  2562. $tag = str_replace ( $tid, "", $tagInfo ['tag'] );
  2563. $ar = explode ( ',', $tag );
  2564. $tag = implode ( ',', array_filter ( $ar ) );
  2565. $tagClient->tcid = $tagInfo ['tcid'];
  2566. $tagClient->tag = $tag;
  2567. $tagClient->update ();
  2568. }
  2569. function ajaxDeleteTagCompany() {
  2570. $cid = $this->get_args ( 'cid' );
  2571. $tid = $this->get_args ( 'tid' );
  2572. Doo::loadModel ( 'tagCompanyNexus' );
  2573. $tagClient = new tagCompanyNexus ();
  2574. $tagInfo = $tagClient->getTagClientBySCid ( $cid, $this->staff [0] ['sid'] );
  2575. $tag = str_replace ( $tid, "", $tagInfo ['tag'] );
  2576. $ar = explode ( ',', $tag );
  2577. $tag = implode ( ',', array_filter ( $ar ) );
  2578. $tagClient->tcid = $tagInfo ['tcid'];
  2579. $tagClient->tag = $tag;
  2580. $tagClient->update ();
  2581. }
  2582. function deleteToolTip() {
  2583. $cid = $this->get_args ( 'cid' );
  2584. $cateid = $this->get_args ( 'cateid' );
  2585. $name = $this->get_args ( 'name' );
  2586. Doo::loadModel ( "C_tooltip" );
  2587. $tooltip = new C_tooltip ();
  2588. if (! empty ( $cid ) && ! empty ( $cateid ) && ! empty ( $name )) {
  2589. $tool = $tooltip->getOne ( array (
  2590. 'where' => 'cid=' . $cid . ' and cateid=' . $cateid,
  2591. 'asArray' => true
  2592. ) );
  2593. if (! empty ( $tool )) {
  2594. $name = str_replace ( $name, "", $tool ['name'] );
  2595. $name = explode ( ',', $name );
  2596. $name = implode ( ',', array_filter ( $name ) );
  2597. $tooltip->name = $name;
  2598. $tooltip->tip = $tool ['tip'];
  2599. $tooltip->update ();
  2600. }
  2601. }
  2602. }
  2603. function DoEdiTagCompany() {
  2604. $tag_1 = $this->get_args ( 'tag_1' ) ? $this->get_args ( 'tag_1' ) : "";
  2605. $tag_2 = $this->get_args ( 'tag_2' ) ? $this->get_args ( 'tag_2' ) : "";
  2606. $tag_3 = $this->get_args ( 'tag_3' ) ? $this->get_args ( 'tag_3' ) : "";
  2607. $tag_4 = $this->get_args ( 'tag_4' ) ? $this->get_args ( 'tag_4' ) : "";
  2608. $tag_5 = $this->get_args ( 'tag_5' ) ? $this->get_args ( 'tag_5' ) : "";
  2609. $tag_6 = $this->get_args ( 'tag_6' ) ? $this->get_args ( 'tag_6' ) : "";
  2610. $tag_7 = $this->get_args ( 'tag_7' ) ? $this->get_args ( 'tag_7' ) : "";
  2611. $tid_1 = $this->get_args ( 'tid_1' ) ? $this->get_args ( 'tid_1' ) : 0;
  2612. $tid_2 = $this->get_args ( 'tid_2' ) ? $this->get_args ( 'tid_2' ) : 0;
  2613. $tid_3 = $this->get_args ( 'tid_3' ) ? $this->get_args ( 'tid_3' ) : 0;
  2614. $tid_4 = $this->get_args ( 'tid_4' ) ? $this->get_args ( 'tid_4' ) : 0;
  2615. $tid_5 = $this->get_args ( 'tid_5' ) ? $this->get_args ( 'tid_5' ) : 0;
  2616. $tid_6 = $this->get_args ( 'tid_6' ) ? $this->get_args ( 'tid_6' ) : 0;
  2617. $tid_7 = $this->get_args ( 'tid_7' ) ? $this->get_args ( 'tid_7' ) : 0;
  2618. Doo::loadModel ( 'tagCompany' );
  2619. if (! empty ( $tag_1 ) && ! empty ( $tid_1 )) {
  2620. $tag = new tagCompany ();
  2621. $tag->tid = $tid_1;
  2622. $tag->name = $tag_1;
  2623. $tag->update ();
  2624. }
  2625. if (! empty ( $tag_2 ) && ! empty ( $tid_2 )) {
  2626. $tag = new tagCompany ();
  2627. $tag->tid = $tid_2;
  2628. $tag->name = $tag_2;
  2629. $tag->update ();
  2630. }
  2631. if (! empty ( $tag_3 ) && ! empty ( $tid_3 )) {
  2632. $tag = new tagCompany ();
  2633. $tag->tid = $tid_3;
  2634. $tag->name = $tag_3;
  2635. $tag->update ();
  2636. }
  2637. if (! empty ( $tag_4 ) && ! empty ( $tid_4 )) {
  2638. $tag = new tagCompany ();
  2639. $tag->tid = $tid_4;
  2640. $tag->name = $tag_4;
  2641. $tag->update ();
  2642. }
  2643. if (! empty ( $tag_5 ) && ! empty ( $tid_5 )) {
  2644. $tag = new tagCompany ();
  2645. $tag->tid = $tid_5;
  2646. $tag->name = $tag_5;
  2647. $tag->update ();
  2648. }
  2649. if (! empty ( $tag_6 ) && ! empty ( $tid_6 )) {
  2650. $tag = new tagCompany ();
  2651. $tag->tid = $tid_6;
  2652. $tag->name = $tag_6;
  2653. $tag->update ();
  2654. }
  2655. if (! empty ( $tag_7 ) && ! empty ( $tid_7 )) {
  2656. $tag = new tagCompany ();
  2657. $tag->tid = $tid_7;
  2658. $tag->name = $tag_7;
  2659. $tag->update ();
  2660. }
  2661. return "/mycompany";
  2662. }
  2663. function DoEdiTag() {
  2664. $tag_1 = $this->get_args ( 'tag_1' ) ? $this->get_args ( 'tag_1' ) : "";
  2665. $tag_2 = $this->get_args ( 'tag_2' ) ? $this->get_args ( 'tag_2' ) : "";
  2666. $tag_3 = $this->get_args ( 'tag_3' ) ? $this->get_args ( 'tag_3' ) : "";
  2667. $tag_4 = $this->get_args ( 'tag_4' ) ? $this->get_args ( 'tag_4' ) : "";
  2668. $tag_5 = $this->get_args ( 'tag_5' ) ? $this->get_args ( 'tag_5' ) : "";
  2669. $tag_6 = $this->get_args ( 'tag_6' ) ? $this->get_args ( 'tag_6' ) : "";
  2670. $tag_7 = $this->get_args ( 'tag_7' ) ? $this->get_args ( 'tag_7' ) : "";
  2671. $tid_1 = $this->get_args ( 'tid_1' ) ? $this->get_args ( 'tid_1' ) : 0;
  2672. $tid_2 = $this->get_args ( 'tid_2' ) ? $this->get_args ( 'tid_2' ) : 0;
  2673. $tid_3 = $this->get_args ( 'tid_3' ) ? $this->get_args ( 'tid_3' ) : 0;
  2674. $tid_4 = $this->get_args ( 'tid_4' ) ? $this->get_args ( 'tid_4' ) : 0;
  2675. $tid_5 = $this->get_args ( 'tid_5' ) ? $this->get_args ( 'tid_5' ) : 0;
  2676. $tid_6 = $this->get_args ( 'tid_6' ) ? $this->get_args ( 'tid_6' ) : 0;
  2677. $tid_7 = $this->get_args ( 'tid_7' ) ? $this->get_args ( 'tid_7' ) : 0;
  2678. Doo::loadModel ( 'tag' );
  2679. if (! empty ( $tag_1 ) && ! empty ( $tid_1 )) {
  2680. $tag = new tag ();
  2681. $tag->tid = $tid_1;
  2682. $tag->name = $tag_1;
  2683. $tag->update ();
  2684. }
  2685. if (! empty ( $tag_2 ) && ! empty ( $tid_2 )) {
  2686. $tag = new tag ();
  2687. $tag->tid = $tid_2;
  2688. $tag->name = $tag_2;
  2689. $tag->update ();
  2690. }
  2691. if (! empty ( $tag_3 ) && ! empty ( $tid_3 )) {
  2692. $tag = new tag ();
  2693. $tag->tid = $tid_3;
  2694. $tag->name = $tag_3;
  2695. $tag->update ();
  2696. }
  2697. if (! empty ( $tag_4 ) && ! empty ( $tid_4 )) {
  2698. $tag = new tag ();
  2699. $tag->tid = $tid_4;
  2700. $tag->name = $tag_4;
  2701. $tag->update ();
  2702. }
  2703. if (! empty ( $tag_5 ) && ! empty ( $tid_5 )) {
  2704. $tag = new tag ();
  2705. $tag->tid = $tid_5;
  2706. $tag->name = $tag_5;
  2707. $tag->update ();
  2708. }
  2709. if (! empty ( $tag_6 ) && ! empty ( $tid_6 )) {
  2710. $tag = new tag ();
  2711. $tag->tid = $tid_6;
  2712. $tag->name = $tag_6;
  2713. $tag->update ();
  2714. }
  2715. if (! empty ( $tag_7 ) && ! empty ( $tid_7 )) {
  2716. $tag = new tag ();
  2717. $tag->tid = $tid_7;
  2718. $tag->name = $tag_7;
  2719. $tag->update ();
  2720. }
  2721. return "/contacts";
  2722. }
  2723. function ajaxGetLv2() {
  2724. $lv1 = $this->get_args ( 'lv1' ) ? $this->get_args ( 'lv1' ) : 0;
  2725. $s = $this->get_args ( 's' ) ? $this->get_args ( 's' ) : 0;
  2726. if ($lv1 == 0) {
  2727. echo json_encode ( array (
  2728. "success" => false,
  2729. "info" => ""
  2730. ) );
  2731. die ();
  2732. }
  2733. if (! empty ( $lv1 )) {
  2734. Doo::loadModel ( 'district' );
  2735. $district = new district ();
  2736. $district = $district->get_lvByid ( $s, $lv1 );
  2737. echo json_encode ( array (
  2738. "success" => true,
  2739. "info" => $district
  2740. ) );
  2741. }
  2742. }
  2743. function keyonline() {
  2744. $data ['memu'] = "keyonline";
  2745. $data ['staff'] = $this->staff;
  2746. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  2747. if (empty ( $year ))
  2748. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( 'Y' );
  2749. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "";
  2750. if (empty ( $cid ))
  2751. $cid = isset ( $this->params ['cid'] ) ? $this->params ['cid'] : $this->staff [0] ['cid'];
  2752. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  2753. if (empty ( $staff ))
  2754. $staff = isset ( $this->params ['staff'] ) ? $this->params ['staff'] : "";
  2755. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : "";
  2756. if (empty ( $status ))
  2757. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  2758. $search = $this->get_args ( 'search' ) ? $this->get_args ( 'search' ) : "";
  2759. $productW = $this->get_args ( 'product' ) ? $this->get_args ( 'product' ) : "";
  2760. Doo::loadModel ( 'longle' );
  2761. $longle = new longle ();
  2762. $data ['longleArray'] = $longle->getLongleByStatus ( $year, $cid, $staff, $status, $search, $productW );
  2763. // 获取接收锁信息
  2764. // $longle->getLongleByRe($this->staff[0]['cid'],1);
  2765. $othstr = "";
  2766. if (! empty ( $this->staff [0] ['othercid'] ))
  2767. $othstr = " cid in (" . $this->staff [0] ['cid'] . "," . $this->staff [0] ['othercid'] . ")";
  2768. else
  2769. $othstr = " cid in (" . $this->staff [0] ['cid'] . ")";
  2770. $data ['reLongle'] = $longle->count ( array (
  2771. 'where' => $othstr . ' and status=1'
  2772. ) );
  2773. $data ['cid'] = $cid;
  2774. $data ['year'] = $year;
  2775. $data ['staff'] = $staff;
  2776. $data ['status'] = $status;
  2777. $data ['productName'] = $productW;
  2778. Doo::loadModel ( 'L_category' );
  2779. Doo::loadModel ( 'staff' );
  2780. Doo::loadModel ( 'product' );
  2781. $product = new product ();
  2782. $staff = new staff ();
  2783. $L_category = new L_category ();
  2784. $data ['product'] = $product->getProudct ();
  2785. $data ['staffu'] = $staff->getUserById ( $this->staff [0] ['sid'] );
  2786. $data ['category'] = $L_category->getCategory ();
  2787. $data ['staffList'] = $staff->getStaffByCid ( $cid );
  2788. if ($cid == 1)
  2789. $data ['cid'] = $data ['category'] [0] ['cid'];
  2790. $dateHtml = "";
  2791. $now = date ( "Y" );
  2792. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  2793. if ($YEARD <= $now) {
  2794. $dateHtml .= '<option ';
  2795. if ($data ['year'] == $YEARD) {
  2796. $dateHtml .= 'selected ';
  2797. }
  2798. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  2799. }
  2800. }
  2801. $data ['dateHtml'] = $dateHtml;
  2802. $this->render ( "/lock_look", $data );
  2803. }
  2804. function keyStatistics() {
  2805. Doo::loadModel ( 'staff' );
  2806. $staff = new staff ();
  2807. Doo::loadModel ( 'longle' );
  2808. $longle = new longle ();
  2809. $staffCondition = "";
  2810. if ($this->staff [0] ['cid'] != 12)
  2811. $staffCondition = " and cid=" . $this->staff [0] ['cid'];
  2812. $staffList = $staff->find ( array (
  2813. 'where' => "isadmin= 0 " . $staffCondition,
  2814. 'asArray' => TRUE
  2815. ) );
  2816. Doo::db ()->beginTransaction ();
  2817. foreach ( $staffList as $key => $value ) { // not in(1,2)
  2818. $sum = $longle->count ( array (
  2819. 'where' => "status!= 1 and responsible ='" . $value ['username'] . "'",
  2820. 'asArray' => TRUE
  2821. ) );
  2822. $a = $longle->count ( array (
  2823. 'where' => "status!= 2 and status!= 1 and responsible ='" . $value ['username'] . "'",
  2824. 'asArray' => TRUE
  2825. ) );
  2826. $b = $sum - $a;
  2827. $staffList [$key] ['sum'] = $sum;
  2828. $staffList [$key] ['a'] = $a;
  2829. $staffList [$key] ['b'] = $b;
  2830. }
  2831. Doo::db ()->commit ();
  2832. $data ['staff'] = $this->staff;
  2833. $data ['staffList'] = $staffList;
  2834. $data ['memu'] = "keyStatistics";
  2835. $this->render ( "lock_count", $data );
  2836. }
  2837. function addDoLockLog() {
  2838. Doo::loadModel ( 'longle_log' );
  2839. Doo::loadModel ( 'longle' );
  2840. Doo::loadModel ( "action_log" );
  2841. Doo::loadModel ( 'client' );
  2842. $clientobj = new client ();
  2843. $longle = new longle ();
  2844. $longle_log = new longle_log ();
  2845. Doo::loadModel ( 'district' );
  2846. $district = new district ();
  2847. $status = $this->get_args ( 'longleStatus' ) ? $this->get_args ( 'longleStatus' ) : 0;
  2848. $lid = $this->get_args ( 'klid' ) ? $this->get_args ( 'klid' ) : 0;
  2849. $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : "";
  2850. $company = $this->get_args ( 'company' ) ? $this->get_args ( 'company' ) : '';
  2851. if (empty ( $lid ))
  2852. return "/keyonline/";
  2853. $linfo = $longle->getLongleByLid ( $lid );
  2854. if ($status == 0)
  2855. return "/keyonline/" . $lid;
  2856. elseif ($status == 3) {
  2857. $clientname = $clientobj->getClientByName2 ( $name, $company );
  2858. if (empty ( $clientname ))
  2859. return "/keyonline/" . $lid;
  2860. if ($name != "") {
  2861. $longle->client = $name;
  2862. $longle->clientid = $clientname [0] ['cid'];
  2863. }
  2864. // if($product!="")
  2865. // $longle->product=$product;
  2866. $longle->statusT = "借出";
  2867. $longle_log->client = $name;
  2868. $longle_log->clientid = $clientname [0] ['cid'];
  2869. $longle_log->product = $linfo [0] ['product'];
  2870. $longle_log->statusT = "借出";
  2871. // 日常行为
  2872. $action_log = new action_log ();
  2873. $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'] . ')';
  2874. $action_log->sid = $this->staff [0] ['sid'];
  2875. $action_log->cid = $this->staff [0] ['cid'];
  2876. $action_log->updatetime = date ( "Y-m-d" );
  2877. $action_log->time = date ( "H:i" );
  2878. $action_log->status = 4;
  2879. $action_log->districtid = $clientname [0] ['district'];
  2880. $local = $district->getbyidlist ( $clientname [0] ['district'] );
  2881. $action_log->city = $local [0] ['name'];
  2882. $action_log->province = $local [1] ['name'];
  2883. $action_log->company = $clientname [0] ['companyname'];
  2884. Doo::loadModel ( 'company' );
  2885. $company = new company ();
  2886. $companyInfo = $company->getOne ( array (
  2887. 'where' => ' companyname="' . $clientname [0] ['companyname'] . '"',
  2888. 'asArray' => true
  2889. ) );
  2890. $nature = explode ( ',', $companyInfo ['nature'] );
  2891. $action_log->nature = $nature [0];
  2892. $action_log->class = $action_log->iconBorrow;
  2893. $action_log->insert ();
  2894. } elseif ($status == 4) {
  2895. $clientname = $clientobj->getClientByName2 ( $name, $company );
  2896. if (empty ( $clientname ))
  2897. return "/keyonline/" . $lid;
  2898. if ($name != "") {
  2899. $longle->client = $name;
  2900. $longle->clientid = $clientname [0] ['cid'];
  2901. }
  2902. $longle->statusT = "销售";
  2903. $longle_log->client = $name;
  2904. $longle_log->clientid = $clientname [0] ['cid'];
  2905. $longle_log->product = $linfo [0] ['product'];
  2906. $longle_log->statusT = "销售";
  2907. // 日常行为
  2908. $action_log = new action_log ();
  2909. $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'] . ')';
  2910. $action_log->sid = $this->staff [0] ['sid'];
  2911. $action_log->cid = $this->staff [0] ['cid'];
  2912. $action_log->updatetime = date ( "Y-m-d" );
  2913. $action_log->time = date ( "H:i" );
  2914. $action_log->status = 5;
  2915. $action_log->districtid = $clientname [0] ['district'];
  2916. $local = $district->getbyidlist ( $clientname [0] ['district'] );
  2917. $action_log->city = $local [0] ['name'];
  2918. $action_log->province = $local [1] ['name'];
  2919. $action_log->company = $clientname [0] ['companyname'];
  2920. Doo::loadModel ( 'company' );
  2921. $company = new company ();
  2922. $companyInfo = $company->getOne ( array (
  2923. 'where' => ' companyname="' . $clientname [0] ['companyname'] . '"',
  2924. 'asArray' => true
  2925. ) );
  2926. $nature = explode ( ',', $companyInfo ['nature'] );
  2927. $action_log->nature = $nature [0];
  2928. $action_log->class = $action_log->iconSell;
  2929. $action_log->insert ();
  2930. } elseif ($status == 5) {
  2931. $product = $this->get_args ( 'newProduct' ) ? $this->get_args ( 'newProduct' ) : "";
  2932. if ($product != "")
  2933. $longle->product = $linfo [0] ['product'] . "+" . $product;
  2934. $longle->statusT = "升级";
  2935. $longle_log->product = $linfo [0] ['product'] . "+" . $product;
  2936. $longle_log->statusT = "升级";
  2937. $longle_log->client = $linfo [0] ['client'];
  2938. $longle_log->clientid = $linfo [0] ['clientid'];
  2939. $clientname = $clientobj->getOne ( array (
  2940. 'where' => "cid= '" . $linfo [0] ['clientid'] . "'",
  2941. 'asArray' => TRUE
  2942. ) );
  2943. // 日常行为
  2944. $action_log = new action_log ();
  2945. $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>';
  2946. $action_log->sid = $this->staff [0] ['sid'];
  2947. $action_log->cid = $this->staff [0] ['cid'];
  2948. $action_log->updatetime = date ( "Y-m-d" );
  2949. $action_log->time = date ( "H:i" );
  2950. $action_log->class = $action_log->iconUpdate;
  2951. $action_log->sid = $this->staff [0] ['sid'];
  2952. $action_log->cid = $this->staff [0] ['cid'];
  2953. $action_log->status = 7;
  2954. $action_log->insert ();
  2955. } elseif ($status == 6) {
  2956. $key_num = $this->get_args ( 'key_num' ) ? $this->get_args ( 'key_num' ) : "";
  2957. $key_num2 = explode ( "-", $key_num );
  2958. $key_num = $key_num2 [0] . "-" . $key_num2 [1];
  2959. // if($key_num!="")
  2960. // $longle->key_num=$key_num;
  2961. // 新锁拷贝记录
  2962. $newLongle = new longle ();
  2963. // $newLongle->product=$linfo[0]['product'];
  2964. $newLongle->statusT = "更换";
  2965. $newLongle->status = 6;
  2966. $newLongle->client = $linfo [0] ['client'];
  2967. $newLongle->clientid = $linfo [0] ['clientid'];
  2968. $newlid = $newLongle->update ( array (
  2969. 'where' => ' key_num= \'' . $key_num . "'"
  2970. ) );
  2971. $longleinfo = $longle->getOne ( array (
  2972. 'where' => ' key_num =\'' . $key_num . "'",
  2973. 'asArray' => true
  2974. ) );
  2975. $longleLog = $longle_log->getOne ( array (
  2976. 'where' => ' lid =' . $linfo [0] ['lid'],
  2977. 'desc' => 'logid',
  2978. 'asArray' => true
  2979. ) );
  2980. // 新记录日志
  2981. $newlongle_log = new longle_log ();
  2982. $newlongle_log->statusT = "更换";
  2983. $newlongle_log->status = 6;
  2984. $newlongle_log->client = $linfo [0] ['client'];
  2985. $newlongle_log->new_key_num = $linfo [0] ['key_num'];
  2986. $newlongle_log->product = $linfo [0] ['product'];
  2987. $newlongle_log->category = $this->staff [0] ['category'];
  2988. $newlongle_log->dateline = date ( "Y-m-d" );
  2989. $newlongle_log->operator = $this->staff [0] ['username'];
  2990. $newlongle_log->lid = $longleinfo ['lid'];
  2991. $newlongle_log->insert ();
  2992. $newlongle_log = new longle_log ();
  2993. $newlongle_log->statusT = $longleLog ['statusT'];
  2994. $newlongle_log->status = $longleLog ['status'];
  2995. $newlongle_log->client = $longleLog ['client'];
  2996. $newlongle_log->new_key_num = $longleLog ['new_key_num'];
  2997. $newlongle_log->product = $longleLog ['product'];
  2998. $newlongle_log->category = $longleLog ['category'];
  2999. $newlongle_log->dateline = $longleLog ['dateline'];
  3000. $newlongle_log->operator = $longleLog ['operator'];
  3001. $newlongle_log->lid = $longleinfo ['lid'];
  3002. $newlongle_log->insert ();
  3003. $newLongle = new longle ();
  3004. $newLongle->statusT = $longleLog ['statusT'];
  3005. $newLongle->status = $longleLog ['status'];
  3006. $newlid = $newLongle->update ( array (
  3007. 'where' => ' key_num= \'' . $key_num . "'"
  3008. ) );
  3009. // 新锁状态拷贝
  3010. $longle->statusT = "更换";
  3011. $longle_log->new_key_num = $key_num;
  3012. $longle_log->statusT = "更换";
  3013. $longle_log->client = $linfo [0] ['client'];
  3014. $clientname = $clientobj->getOne ( array (
  3015. 'where' => "cid= '" . $linfo [0] ['clientid'] . "'",
  3016. 'asArray' => TRUE
  3017. ) );
  3018. // 日常行为
  3019. $action_log = new action_log ();
  3020. $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'] . ')';
  3021. $action_log->sid = $this->staff [0] ['sid'];
  3022. $action_log->cid = $this->staff [0] ['cid'];
  3023. $action_log->updatetime = date ( "Y-m-d" );
  3024. $action_log->time = date ( "H:i" );
  3025. $action_log->class = $action_log->iconReplace;
  3026. $action_log->sid = $this->staff [0] ['sid'];
  3027. $action_log->cid = $this->staff [0] ['cid'];
  3028. $action_log->status = 8;
  3029. $action_log->insert ();
  3030. } elseif ($status == 7) {
  3031. $longle->statusT = "收回";
  3032. $longle_log->statusT = "收回";
  3033. $longle_log->responsible = $linfo [0] ['responsible'];
  3034. // 日常行为
  3035. $action_log = new action_log ();
  3036. $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>';
  3037. $action_log->sid = $this->staff [0] ['sid'];
  3038. $action_log->cid = $this->staff [0] ['cid'];
  3039. $action_log->updatetime = date ( "Y-m-d" );
  3040. $action_log->time = date ( "H:i" );
  3041. $action_log->class = $action_log->iconRecycle;
  3042. $action_log->sid = $this->staff [0] ['sid'];
  3043. $action_log->cid = $this->staff [0] ['cid'];
  3044. $action_log->status = 9;
  3045. $action_log->insert ();
  3046. } elseif ($status == 8) {
  3047. $mark = $this->get_args ( 'mark' ) ? $this->get_args ( 'mark' ) : "";
  3048. if (empty ( $mark )) {
  3049. echo json_encode ( array (
  3050. 'msg' => 2
  3051. ) );
  3052. die ();
  3053. }
  3054. $longle_log->mark = $mark;
  3055. // 日常行为
  3056. $action_log = new action_log ();
  3057. $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>添加新备注。';
  3058. $action_log->sid = $this->staff [0] ['sid'];
  3059. $action_log->cid = $this->staff [0] ['cid'];
  3060. $action_log->updatetime = date ( "Y-m-d" );
  3061. $action_log->time = date ( "H:i" );
  3062. $action_log->sid = $this->staff [0] ['sid'];
  3063. $action_log->cid = $this->staff [0] ['cid'];
  3064. $action_log->status = 10;
  3065. $action_log->class = $action_log->iconLock;
  3066. $action_log->insert ();
  3067. } elseif ($status == 9) {
  3068. $longle->statusT = "赠送";
  3069. $longle_log->statusT = "赠送";
  3070. $clientname = $clientobj->getClientByName2 ($name, $company );
  3071. if (empty ( $clientname ))
  3072. return "/keyonline/" . $lid;
  3073. if ($name != "") {
  3074. $longle->client = $name;
  3075. $longle->clientid = $clientname [0] ['cid'];
  3076. }
  3077. $longle_log->client = $name;
  3078. $longle_log->clientid = $clientname [0] ['cid'];
  3079. // 日常行为
  3080. $action_log = new action_log ();
  3081. $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'] . ')';
  3082. $action_log->updatetime = date ( "Y-m-d" );
  3083. $action_log->time = date ( "H:i" );
  3084. $action_log->class = $action_log->iconRecycle;
  3085. $action_log->sid = $this->staff [0] ['sid'];
  3086. $action_log->cid = $this->staff [0] ['cid'];
  3087. $action_log->status = 6;
  3088. $action_log->districtid = $clientname [0] ['district'];
  3089. $local = $district->getbyidlist ( $clientname [0] ['district'] );
  3090. $action_log->city = $local [0] ['name'];
  3091. $action_log->province = $local [1] ['name'];
  3092. $action_log->company = $clientname [0] ['companyname'];
  3093. Doo::loadModel ( 'company' );
  3094. $company = new company ();
  3095. $companyInfo = $company->getOne ( array (
  3096. 'where' => ' companyname="' . $clientname [0] ['companyname'] . '"',
  3097. 'asArray' => true
  3098. ) );
  3099. $nature = explode ( ',', $companyInfo ['nature'] );
  3100. $action_log->nature = $nature [0];
  3101. $action_log->insert ();
  3102. }
  3103. // 记录使用过的状态
  3104. $statuslog = $status . "," . $linfo [0] ['statuslog'];
  3105. $ar = explode ( ',', $statuslog );
  3106. $statuslog = implode ( ',', array_unique ( array_filter ( $ar ) ) );
  3107. $longle->statuslog = $statuslog;
  3108. if ($linfo [0] ['status'] <= 2) {
  3109. if ($status >= 4 && $status <= 2) {
  3110. return "/keyonline/" . $lid;
  3111. }
  3112. }
  3113. if ($lid != 0) {
  3114. $longle->lid = $lid;
  3115. if ($status != 8)
  3116. $longle->status = $status;
  3117. // if($status!=8)
  3118. $longle->responsible = $this->staff [0] ['username'];
  3119. $longle->update ();
  3120. }
  3121. $longle_log->lid = $lid;
  3122. $longle_log->status = $status;
  3123. $longle_log->operator = $this->staff [0] ['username'];
  3124. // 责任人
  3125. $longle_log->category = $this->staff [0] ['category'];
  3126. $longle_log->dateline = date ( "Y-m-d" );
  3127. $longle_log->insert ();
  3128. echo json_encode ( array (
  3129. 'msg' => 1
  3130. ) );
  3131. die ();
  3132. // return "/keyonline/".$lid;
  3133. }
  3134. function ajaxGetLongleByName() {
  3135. Doo::loadModel ( 'longle_log' );
  3136. Doo::loadModel ( 'longle' );
  3137. $longle = new longle ();
  3138. $longle_log = new longle_log ();
  3139. $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : "";
  3140. if (empty ( $name )) {
  3141. echo json_encode ( array (
  3142. "success" => false
  3143. ) );
  3144. die ();
  3145. }
  3146. $ky = $longle->getLongleBykeynum ( $name );
  3147. $t = $longle_log->getLongleByLid ( $ky [0] ['lid'] );
  3148. if (isset ( $t [0] ))
  3149. $tk = $t [0];
  3150. else
  3151. $tk = array ();
  3152. $longleLog = $tk;
  3153. $longleLog ['klid'] = $t [0] ['lid'];
  3154. $longleLog ['longle'] = $ky [0];
  3155. $longleLog ['longleLogHtml'] = $this->_getLongleLogHtml ( $t );
  3156. echo json_encode ( $longleLog );
  3157. }
  3158. function ajaxGetLongleN() {
  3159. Doo::loadModel ( 'longle_log' );
  3160. Doo::loadModel ( 'longle' );
  3161. $longle = new longle ();
  3162. $longle_log = new longle_log ();
  3163. $keynum = $this->get_args ( 'keynum' ) ? $this->get_args ( 'keynum' ) : "";
  3164. if (empty ( $keynum )) {
  3165. echo json_encode ( array (
  3166. "success" => false
  3167. ) );
  3168. die ();
  3169. }
  3170. $ky = $longle->getLongleBykeynum ( $keynum );
  3171. if (! empty ( $ky )) {
  3172. $t = $longle_log->getLongleByLid ( $ky [0] ['lid'] );
  3173. if (isset ( $t [0] ))
  3174. $tk = $t [0];
  3175. else
  3176. $tk = array ();
  3177. $longleLog = $tk;
  3178. $longleLog ['klid'] = $ky [0] ['lid'];
  3179. $longleLog ['longle'] = $ky [0];
  3180. $longleLog ['longleLogHtml'] = $this->_getLongleLogHtml ( $t );
  3181. echo json_encode ( $longleLog );
  3182. }
  3183. }
  3184. function ajaxGetLongle() {
  3185. Doo::loadModel ( 'longle_log' );
  3186. Doo::loadModel ( 'longle' );
  3187. $longle = new longle ();
  3188. $longle_log = new longle_log ();
  3189. $lid = $this->get_args ( 'lid' ) ? $this->get_args ( 'lid' ) : 0;
  3190. if ($lid == 0) {
  3191. echo json_encode ( array (
  3192. "success" => false
  3193. ) );
  3194. die ();
  3195. }
  3196. $t = $longle_log->getLongleByLid ( $lid );
  3197. if (isset ( $t [0] ))
  3198. $tk = $t [0];
  3199. else
  3200. $tk = array ();
  3201. $longleLog = $tk;
  3202. $longleLog ['klid'] = $lid;
  3203. $ky = $longle->getLongleByLid ( $lid );
  3204. $longleLog ['longle'] = $ky [0];
  3205. $longleLog ['longleLogHtml'] = $this->_getLongleLogHtml ( $t );
  3206. echo json_encode ( $longleLog );
  3207. }
  3208. function ajaxGetStaffInfo() {
  3209. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  3210. if ($username == "") {
  3211. echo json_encode ( array (
  3212. "success" => false
  3213. ) );
  3214. die ();
  3215. }
  3216. Doo::loadModel ( 'staff' );
  3217. $staff = new staff ();
  3218. $staffInfo = $staff->getOne ( array (
  3219. 'where' => ' username like "' . $username . '"',
  3220. 'asArray' => TRUE
  3221. ) );
  3222. if (empty ( $staffInfo )) {
  3223. echo json_encode ( array (
  3224. "success" => false,
  3225. 'html' => ''
  3226. ) );
  3227. die ();
  3228. }
  3229. $staffHtml = array (
  3230. 'html' => '<div class="contactPanel"><h1>' . $staffInfo ['username'] . '</h1>
  3231. <table><tbody><tr><th>性别</th><td>' . $staffInfo ['gender'] . '</td><th>办事处</th><td>' . $staffInfo ['category'] . '</td></tr>
  3232. <tr><th>手机</th><td>' . $staffInfo ['telephone'] . '</td><th>电话</th><td>' . $staffInfo ['phone'] . '</td></tr>
  3233. <tr><th>QQ</th><td>' . $staffInfo ['qq'] . '</td><th>邮箱</th><td>' . $staffInfo ['email'] . '</td></tr>
  3234. </tbody></table>
  3235. </div>'
  3236. );
  3237. echo json_encode ( $staffHtml );
  3238. }
  3239. function ajaxGetCompanyByAdd() {
  3240. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "";
  3241. if (! empty ( $cid )) {
  3242. Doo::loadModel ( 'company' );
  3243. $company = new company ();
  3244. Doo::loadModel ( 'client' );
  3245. Doo::loadModel ( 'district' );
  3246. $district = new district ();
  3247. $client = new client ();
  3248. Doo::loadClass ( 'XDeode' );
  3249. $XDeode = new XDeode ( 5 );
  3250. $districtInfo = $district->get_lv ( 1 );
  3251. // $companyInfo = $client->getClientByCompanyId ( $cid );
  3252. // $companyInfo = $companyInfo [0];
  3253. $companyInfo = $company->getOne ( array (
  3254. 'where' => "cid = " . $cid,
  3255. 'asArray' => TRUE
  3256. ) );
  3257. $companyInfo ['companyKey'] = $XDeode->encode ( $companyInfo ['cid'] );
  3258. // $companyInfo ['companyname'] = $cInfo ['companyname'];
  3259. // $companyInfo ['address'] = $cInfo ['address'];
  3260. // $companyInfo ['ride'] = $cInfo ['ride'];
  3261. // $companyInfo ['landmarks'] = $cInfo ['landmarks'];
  3262. // $companyInfo ['stay'] = $cInfo ['stay'];
  3263. $artld = explode ( ',', $companyInfo ['local'] );
  3264. $districtid = explode ( ',', $companyInfo ['district'] );
  3265. $html = "";
  3266. $html .= '<select name="lv21" id="lv31" onchange="dislv(\'lv31\',\'32\');"><option value="' . $districtid [0] . '">' . $artld [0] . '</option>';
  3267. // foreach ($districtInfo as $key=>$value){
  3268. //
  3269. // $html.='<option selected value="'.$value['id'].'">'.$value['name'].'</option>';
  3270. // }
  3271. $html .= '</select>&nbsp;';
  3272. $html .= '<span id="mlv32">
  3273. <select id="lv32" name="lv22">
  3274. <option selected value="' . $districtid [1] . '" >' . $artld [1] . '</option>
  3275. </select>
  3276. </span>';
  3277. $html .= '<span id="mlv33">
  3278. <select id="lv33" name="lv23">
  3279. <option selected value="' . $districtid [2] . '" >' . $artld [2] . '</option>
  3280. </select>&nbsp;
  3281. </span>';
  3282. $companyInfo ['dishtml'] = $html;
  3283. $companyInfo ['natureAr'] = $this->nature;
  3284. $companyInfo ['natureArlenght'] = 12;
  3285. echo json_encode ( array (
  3286. "success" => true,
  3287. 'data' => $companyInfo
  3288. ) );
  3289. die ();
  3290. } else
  3291. echo json_encode ( array (
  3292. "success" => false,
  3293. 'data' => ''
  3294. ) );
  3295. die ();
  3296. }
  3297. function doEditCompanyD() {
  3298. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3299. $companyname = $this->get_args ( 'companyname' ) ? $this->get_args ( 'companyname' ) : "";
  3300. $lv21 = $this->get_args ( 'lv21' ) ? $this->get_args ( 'lv21' ) : 0;
  3301. $lv22 = $this->get_args ( 'lv22' ) ? $this->get_args ( 'lv22' ) : 0;
  3302. $lv23 = $this->get_args ( 'lv23' ) ? $this->get_args ( 'lv23' ) : 0;
  3303. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  3304. $fax = $this->get_args ( 'fax' ) ? $this->get_args ( 'fax' ) : "";
  3305. $webservice = $this->get_args ( 'webservice' ) ? $this->get_args ( 'webservice' ) : "";
  3306. $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
  3307. $ride = $this->get_args ( 'ride' ) ? $this->get_args ( 'ride' ) : "";
  3308. $stay = $this->get_args ( 'stay' ) ? $this->get_args ( 'stay' ) : "";
  3309. $landmarks = $this->get_args ( 'landmarks' ) ? $this->get_args ( 'landmarks' ) : "";
  3310. if (empty ( $cid ) || empty ( $companyname )) {
  3311. echo json_encode ( array (
  3312. "success" => false
  3313. ) );
  3314. die ();
  3315. }
  3316. Doo::loadModel ( "company" );
  3317. Doo::loadModel ( "client" );
  3318. $client = new client ();
  3319. $company = new company ();
  3320. $company->cid = $cid;
  3321. if (! empty ( $lv21 ) && ! empty ( $lv22 ) && ! empty ( $lv23 )) {
  3322. Doo::loadModel ( 'district' );
  3323. $district = new district ();
  3324. // 更新公司信息
  3325. $lv1 = $district->getbyid ( $lv21 );
  3326. $lv2 = $district->getbyid ( $lv22 );
  3327. $lv3 = $district->getbyid ( $lv23 );
  3328. $company->district = $lv21 . "," . $lv22 . "," . $lv23;
  3329. $company->local = $lv1 [0] ['name'] . "," . $lv2 [0] ['name'] . "," . $lv3 [0] ['name'];
  3330. }
  3331. if (! empty ( $nature )) {
  3332. $nature = implode ( ",", $nature );
  3333. $company->nature = $nature;
  3334. }
  3335. if (! empty ( $companyname )) {
  3336. $company->companyname = $companyname;
  3337. $client->companyname = $companyname;
  3338. }
  3339. if (! empty ( $fax ))
  3340. $company->fax = $fax;
  3341. if (! empty ( $webservice ))
  3342. $company->webservice = $webservice;
  3343. $company->address = $address;
  3344. $company->ride = $ride;
  3345. $company->stay = $stay;
  3346. $company->landmarks = $landmarks;
  3347. $company->update ();
  3348. $client->update ( array (
  3349. 'where' => ' companyid =' . $cid
  3350. ) );
  3351. echo json_encode ( array (
  3352. "success" => true
  3353. ) );
  3354. die ();
  3355. }
  3356. function ajaxEditCompany() {
  3357. $companyname = $this->get_args ( 'companyId' ) ? $this->get_args ( 'companyId' ) : 0;
  3358. if (! empty ( $companyname )) {
  3359. Doo::loadModel ( 'company' );
  3360. $company = new company ();
  3361. $companyInfo = $company->getOne ( array (
  3362. 'where' => "cid = '" . $companyname . "'",
  3363. 'asArray' => TRUE
  3364. ) );
  3365. if (! empty ( $companyInfo )) {
  3366. Doo::loadModel ( 'district' );
  3367. $district = new district ();
  3368. $districtinfo = $district->get_lv ( 1 );
  3369. $dinfo = $district->getbyidlist ( $companyInfo ['district'] );
  3370. $html = '
  3371. <div class="contactInfo clearfix">
  3372. <div class="header">
  3373. <h1 class="companyName">' . $companyInfo ['companyname'] . '</h1>
  3374. </div>
  3375. </div>
  3376. <div class="lockRecord">
  3377. <div class="contactPanel">
  3378. <table>
  3379. <tbody><tr><th>单位全称</th><td colspan="3"><input type="text" name="companyname" id="companyname" value="' . $companyInfo ['companyname'] . '"></td></tr>
  3380. <tr><th>地区</th><td colspan="3">
  3381. <select name="lv21" id="lv21" onchange="dislv(\'lv21\',22);">
  3382. <option value="0">请选择</option>';
  3383. foreach ( $districtinfo as $key => $value ) {
  3384. if ($value ['id'] == $dinfo [0] ['id'])
  3385. $html .= '<option selected value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  3386. else
  3387. $html .= '<option value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  3388. }
  3389. $html .= '</select>
  3390. <span id="mlv22">
  3391. <select id="lv22">
  3392. <option value="' . $dinfo [1] ['id'] . '">' . $dinfo [1] ['name'] . '</option>
  3393. </select>
  3394. </span>
  3395. <span id="mlv23">
  3396. <select id="lv23">
  3397. <option value="' . $dinfo [2] ['id'] . '">' . $dinfo [2] ['name'] . '</option>
  3398. </select>&nbsp;
  3399. </span>
  3400. </td></tr>
  3401. ';
  3402. $html .= '<tr><th>性质</th><td colspan="3">';
  3403. $ntre = explode ( ",", $companyInfo ['nature'] );
  3404. foreach ( $this->nature as $key => $value ) {
  3405. $falg = true;
  3406. foreach ( $ntre as $k => $v ) {
  3407. if ($value == $v) {
  3408. $falg = false;
  3409. $html .= '<label><input type="checkbox" checked name="nature[]" value="' . $value . '">' . $value . '</label>&nbsp;';
  3410. }
  3411. }
  3412. if ($falg)
  3413. $html .= '<label><input type="checkbox" name="nature[]" value="' . $value . '">' . $value . '</label>&nbsp;';
  3414. }
  3415. $html .= ' </td></tr>
  3416. <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>
  3417. <tr><th>单位地址</th><td colspan="3"><input type="text" name="address" id="address" value="' . $companyInfo ['address'] . '"> </td></tr>
  3418. <tr><th>乘车路线</th><td colspan="3"><input type="text" name="ride" id="ride" value="' . $companyInfo ['ride'] . '"> </td></tr>
  3419. <tr><th>地标建筑</th><td colspan="3"><input type="text" name="landmarks" id="landmarks" value="' . $companyInfo ['landmarks'] . '"> </td></tr>
  3420. <tr><th>住宿参考</th><td colspan="3"><input type="text" name="stay" id="stay" value="' . $companyInfo ['stay'] . '"> </td></tr>
  3421. <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>
  3422. </tbody></table>
  3423. <div class="bsAlert bsInfo">单位全称将与该单位已存在的客户进行同步;其他单位信息不会进行同步;<br>单位信息随该单位第一位客户录入,并作为“在这添加客户”的基础数据</div>
  3424. </div>
  3425. </div>
  3426. ';
  3427. echo json_encode ( array (
  3428. "success" => true,
  3429. 'html' => $html
  3430. ) );
  3431. die ();
  3432. }
  3433. } else
  3434. echo json_encode ( array (
  3435. "success" => false,
  3436. 'html' => ''
  3437. ) );
  3438. die ();
  3439. }
  3440. function ajaxGetCompany() {
  3441. $companyname = $this->get_args ( 'companyId' ) ? $this->get_args ( 'companyId' ) : 0;
  3442. if (! empty ( $companyname )) {
  3443. Doo::loadModel ( 'company' );
  3444. $company = new company ();
  3445. $companyInfo = $company->getOne ( array (
  3446. 'where' => "cid = '" . $companyname . "'",
  3447. 'asArray' => TRUE
  3448. ) );
  3449. if (! empty ( $companyInfo )) {
  3450. Doo::loadModel ( 'client' );
  3451. Doo::loadModel ( 'staff' );
  3452. Doo::loadModel ( 'client_staff' );
  3453. Doo::loadModel ( 'longle' );
  3454. $longle = new longle ();
  3455. $client_staff = new client_staff ();
  3456. $staff = new staff ();
  3457. $client = new client ();
  3458. Doo::loadModel ( 'district' );
  3459. $district = new district ();
  3460. $clientlist = $client->getClientByCompanyId ( $companyInfo ['cid'] );
  3461. $department = $client->getDepartment ( $companyInfo ['cid'] );
  3462. Doo::loadModel ( "tagCompanyNexus" );
  3463. Doo::loadModel ( "tagCompany" );
  3464. $tag = new tagCompany ();
  3465. $tag_client = new tagCompanyNexus ();
  3466. $tagId = $tag_client->getTagClientBySCid ( $companyInfo ['cid'], $this->staff [0] ['sid'] );
  3467. $taginfo = $tag->getTagByTidL ( $tagId ['tag'] );
  3468. $taghtml = "";
  3469. foreach ( $taginfo as $key => $value ) {
  3470. $taghtml .= '<span class="contactsTag tagCol-0' . $value ['colorid'] . '">' . $value ['name'] . '</span>';
  3471. }
  3472. $html = '<div class="header">
  3473. <h1 class="companyName"><div class="fR">
  3474. <a class="icon- add" node-syn="show" href="javascript:void(0)" title="同步地址信息">S</a>
  3475. <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>
  3476. <div class="contactPanel">
  3477. <table>
  3478. <tbody>
  3479. <tr><th>单位地区</th><td><span>' . $companyInfo ['local'] . '</span></td><th>单位性质</th><td>' . $companyInfo ['nature'] . '</td></tr>
  3480. <tr><th>单位地址</th><td colspan="3">' . $companyInfo ['address'] . '</td></tr>
  3481. <tr><th>单位乘车</th><td colspan="3">' . $companyInfo ['ride'] . '</td></tr>
  3482. <tr><th>单位地标</th><td colspan="3">' . $companyInfo ['landmarks'] . '</td></tr>
  3483. <tr><th>单位住宿</th><td colspan="3">' . $companyInfo ['stay'] . '</td></tr>
  3484. <tr><td colspan="4">
  3485. ' . $taghtml . '
  3486. </td></tr>
  3487. <tr><td colspan="4" >
  3488. <a class="button" style="display:none" node-synadd="true" href="javascript:void(0)">确定同步</a>
  3489. <span node-synAdd="msg" class="bsAlert bsSuccess fL hide"></span>
  3490. <span class="hide" id="skop">已选择 <span id="tl">0</span>/<span id="bl">' . sizeof ( $clientlist ) . '</span>
  3491. <input type="checkbox" name="CASYN[]" cas-all="TR" class="hide" value="19595" style="display: inline-block;">全选客户
  3492. </td>
  3493. </tr>
  3494. </tbody></table></div>
  3495. <h2 class="cate">';
  3496. $html .= '<a href="javascript:void(0)" onclick="departmentC()" class="now">不限</a>';
  3497. foreach ( $department as $key => $value ) {
  3498. if ($value != "")
  3499. $html .= '<a href="javascript:void(0)" onclick="departmentC(\'' . $value ['department'] . '\')">' . $value ['department'] . '</a>';
  3500. }
  3501. $html .= '</h2></div><script>$(".header .cate a").click(function(){
  3502. $(this).addClass("now").siblings("a").removeClass("now");
  3503. });
  3504. </script>';
  3505. $html .= '<div class="lockRecord autoHeightR2" >';
  3506. foreach ( $clientlist as $key => $value ) {
  3507. $scinfo = $client_staff->getClientByCid ( $value ['cid'] );
  3508. $staffinfo = $staff->getUserById ( $scinfo ['sid'] );
  3509. // 客户信息
  3510. $html .= '<div class="contactPanel" id="PART_' . $value ['department'] . '">
  3511. <h1><p class="fR">' . $staffinfo [0] ['category'] . '-<a href="javascript:void(0)" onclick="getStaffInfo(\'' . $staffinfo [0] ['username'] . '\')" >
  3512. ' . $staffinfo [0] ['username'] . '</a></p>
  3513. <input type="checkbox" name="CASYN[]" CAS-NUM="TR" class="hide" value="' . $value ['cid'] . '">
  3514. <a href="javascript:void(0)" onclick="getClientInfo(\'' . $value ['cid'] . '\')" class="clientName">' . $value ['clientname'] . ' </a>
  3515. <i class="icon- sport">' . $value ['priority'] . '</i><a class="icon- edit" title="编辑客户" href="javascript:clientEdit(' . $value ['cid'] . ')">I</a></h1><table>
  3516. <tbody><tr><th>性别</th><td>' . $value ['gender'] . '</td><th>昵称</th><td>' . $value ['nicename'] . '</td></tr>
  3517. <tr><th>部门</th><td>' . $value ['department'] . '</td><th>办公室</th><td>' . $value ['office'] . '</td></tr>
  3518. <tr><th>手机</th><td>' . $value ['telephone'] . '</td><th>电话</th><td>' . $value ['phone'] . '</td></tr>
  3519. <tr><th>QQ</th><td>' . $value ['qq'] . '</td><th>邮箱</th><td>' . $value ['email'] . '</td></tr>
  3520. <tr node-ck=fz ><th>备注</th><td >' . $value ['mark'] . '</td>
  3521. </tr>';
  3522. $longleinfo = $longle->getLongleByClientid ( $value ['cid'] );
  3523. if (empty ( $longleinfo )) {
  3524. $longleinfo = array (
  3525. 0 => array (
  3526. 'lid' => '',
  3527. 'key_num' => '',
  3528. 'product' => '',
  3529. 'statusT' => ''
  3530. )
  3531. );
  3532. }
  3533. $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>';
  3534. $districtList = $district->getbyidlist ( $value ['district'] );
  3535. $localdis = '';
  3536. foreach ( $districtList as $lov ) {
  3537. $localdis .= ' ' . $lov ['name'];
  3538. }
  3539. $html .= '
  3540. <tr node-synCom=pany style="display:none" ><th>客户地区</th><td colspan="4">' . $localdis . '</td></tr>
  3541. <tr node-synCom=pany style="display:none" ><th>客户地址</th><td colspan="4">' . $value ['address'] . '</td></tr>
  3542. <tr node-synCom=pany style="display:none" ><th>客户乘车</th><td colspan="4">' . $value ['ride'] . '</td></tr>
  3543. <tr node-synCom=pany style="display:none" ><th>客户地标</th><td colspan="4">' . $value ['landmarks'] . '</td></tr>
  3544. <tr node-synCom=pany style="display:none" ><th>客户住宿</th><td colspan="4">' . $value ['stay'] . '</td></tr>';
  3545. $html .= '</tbody></table></div>';
  3546. }
  3547. $html .= "</div><script type='text/javascript'>
  3548. $(\"a[node-syn=show]\").click(function() {
  3549. $(\"a[node-synadd='true']\").show();
  3550. $('input[CAS-NUM=TR]').show();
  3551. $('#skop').show();
  3552. $('tr[node-ck=fz]').hide();
  3553. $('tr[node-synCom=pany]').show();
  3554. });
  3555. $(\"input[cas-all='TR']\").click(function() {
  3556. if (this.checked) {
  3557. $(\"input[CAS-NUM=TR]:checkbox\").each(function() {
  3558. $(this).attr(\"checked\", true);
  3559. })
  3560. }else{
  3561. $(\"input[CAS-NUM=TR]:checkbox\").each(function() {
  3562. $(this).attr(\"checked\", false);
  3563. })
  3564. }
  3565. $('#tl').html($('input[CAS-NUM=TR]:checked').length);
  3566. });
  3567. $(\"input[CAS-NUM='TR']\").click(function() {
  3568. $('#tl').html($('input[CAS-NUM=TR]:checked').length);
  3569. });
  3570. $(\"a[node-synadd='true']\").click(function() {
  3571. var id_array=new Array();
  3572. $('input[CAS-NUM=TR]:checked').each(function(){
  3573. id_array.push($(this).val());
  3574. });
  3575. if(id_array.length==0){
  3576. alert('未选中客户');
  3577. }else{
  3578. var idstr=id_array.join(',');
  3579. var url='/ajaxSetCompanyAddress';
  3580. $.ajax({
  3581. url:url,
  3582. type: 'post',
  3583. cache: false,
  3584. dataType: 'json',
  3585. data: {
  3586. cidString:idstr,
  3587. company:" . $companyInfo ['cid'] . "
  3588. },
  3589. global: true,
  3590. success: function(data){
  3591. if(data.status>0){
  3592. $(\"span[node-synAdd=msg]\").html('同步成功');
  3593. for(var i=0;i<id_array.length;i++){
  3594. $(\"td[node-address=company_\"+id_array[i]+\"]\").html('" . $companyInfo ['address'] . "');
  3595. }
  3596. $(\"a[node-synadd='true']\").hide();
  3597. $('input[CAS-NUM=TR]').hide();
  3598. $('#skop').hide();
  3599. $(\"span[node-synAdd=msg]\").show().delay(2000).fadeOut();
  3600. }else if(data.status==-1){
  3601. $(\"span[node-synAdd=msg]\").html('操作不成功');
  3602. $(\"span[node-synAdd=msg]\").show().delay(2000).fadeOut();
  3603. }else if(data.status==0){
  3604. $(\"span[node-synAdd=msg]\").html('地址已同步过');
  3605. $(\"span[node-synAdd=msg]\").show().delay(2000).fadeOut();
  3606. }
  3607. },
  3608. error:function(err){
  3609. }
  3610. });
  3611. }
  3612. });
  3613. autoFlashHeight();
  3614. </script>";
  3615. echo json_encode ( array (
  3616. "success" => true,
  3617. 'html' => $html
  3618. ) );
  3619. die ();
  3620. }
  3621. } else
  3622. echo json_encode ( array (
  3623. "success" => false,
  3624. 'html' => ''
  3625. ) );
  3626. die ();
  3627. }
  3628. function ajaxSetCompanyAddress() {
  3629. $cidString = $this->get_args ( 'cidString' ) ? $this->get_args ( 'cidString' ) : "";
  3630. $companyId = $this->get_args ( 'company' ) && is_numeric ( $this->get_args ( 'company' ) ) ? $this->get_args ( 'company' ) : 0;
  3631. if (! empty ( $cidString ) && ! empty ( $companyId )) {
  3632. Doo::loadModel ( 'client' );
  3633. $client = new client ();
  3634. Doo::loadModel ( 'company' );
  3635. $company = new company ();
  3636. $cidList = explode ( ',', $cidString );
  3637. foreach ( $cidList as $value ) {
  3638. if (! is_numeric ( $value ))
  3639. die ( 'illegal request3' );
  3640. }
  3641. $companyInfo = $company->getOne ( array (
  3642. 'where' => "cid = '" . $companyId . "'",
  3643. 'asArray' => TRUE
  3644. ) );
  3645. $client->address = $companyInfo ['address'];
  3646. $client->ride = $companyInfo ['ride'];
  3647. $client->landmarks = $companyInfo ['landmarks'];
  3648. $client->stay = $companyInfo ['stay'];
  3649. $client->local = $companyInfo ['local'];
  3650. $client->district = $companyInfo ['district'];
  3651. $falg = $client->update ( array (
  3652. 'where' => 'companyid =' . $companyInfo ['cid'] . ' and cid in (' . $cidString . ')'
  3653. ) );
  3654. echo json_encode ( array (
  3655. 'status' => $falg,
  3656. 'msg' => 'illegal request2'
  3657. ) );
  3658. die ();
  3659. }
  3660. echo json_encode ( array (
  3661. 'status' => - 1,
  3662. 'msg' => 'illegal request'
  3663. ) );
  3664. die ();
  3665. }
  3666. function checkclicomname() { // 地区区分
  3667. $companyname = $this->get_args ( 'companyname' ) ? $this->get_args ( 'companyname' ) : "";
  3668. $clientname = $this->get_args ( 'clientname' ) ? $this->get_args ( 'clientname' ) : "";
  3669. $district1 = $this->get_args ( 'district1' ) ? $this->get_args ( 'district1' ) : 0;
  3670. $district2 = $this->get_args ( 'district2' ) ? $this->get_args ( 'district2' ) : 0;
  3671. $district3 = $this->get_args ( 'district3' ) ? $this->get_args ( 'district3' ) : 0;
  3672. Doo::loadModel ( 'client' );
  3673. $client = new client ();
  3674. $local = $district1 . "," . $district2 . "," . $district3;
  3675. $companyname = trim ( $companyname );
  3676. $clientname = trim ( $clientname );
  3677. $clientinfo = $client->getClientToName ( $clientname, $companyname, $local );
  3678. if (! empty ( $clientinfo )) {
  3679. echo json_encode ( array (
  3680. 'success' => false
  3681. ) );
  3682. } else {
  3683. echo json_encode ( array (
  3684. 'success' => true
  3685. ) );
  3686. }
  3687. }
  3688. function ajaxGetClientInfoN() {
  3689. $clientname = $this->get_args ( 'client' ) ? $this->get_args ( 'client' ) : "";
  3690. if ($clientname == "") {
  3691. echo json_encode ( array (
  3692. "success" => false
  3693. ) );
  3694. die ();
  3695. }
  3696. Doo::loadModel ( 'client' );
  3697. Doo::loadModel ( 'client_staff' );
  3698. Doo::loadModel ( 'longle' );
  3699. Doo::loadModel ( 'company' );
  3700. Doo::loadModel ( 'service_log' );
  3701. $service_log = new service_log ();
  3702. $company = new company ();
  3703. $longle = new longle ();
  3704. $client = new client ();
  3705. $client_staff = new client_staff ();
  3706. $clientInfo = $client->getOne ( array (
  3707. "where" => ' cid like "' . $clientname . '"',
  3708. 'asArray' => TRUE
  3709. ) );
  3710. if (empty ( $clientInfo )) {
  3711. echo json_encode ( array (
  3712. "success" => false,
  3713. 'html' => ''
  3714. ) );
  3715. die ();
  3716. }
  3717. // 获取锁
  3718. $longleInfo = $longle->getLongleByClient ( $clientname );
  3719. $k = "";
  3720. foreach ( $longleInfo as $key => $value ) {
  3721. if ($value ['status'] == 6 || $value ['status'] == 7)
  3722. $k .= '<a href="javascript:void(0)" class="disenable" onclick="getLock(' . $value ['lid'] . ')" >' . $value ['key_num'] . '/' . $value ['product'] . '/' . $value ['statusT'] . '</a>&nbsp; ';
  3723. else
  3724. $k .= '<a href="javascript:void(0)" onclick="getLock(' . $value ['lid'] . ')" >' . $value ['key_num'] . '/' . $value ['product'] . '/' . $value ['statusT'] . '</a>&nbsp; ';
  3725. }
  3726. // 获取办事人
  3727. $staffInfo = $client_staff->getClientByCid ( $clientInfo ['cid'] );
  3728. // 获取公司信息
  3729. $companyInfo = $company->getCompanyByCid ( $clientInfo ['companyid'] );
  3730. $serviceLog = $service_log->getServiceByClientid ( $clientInfo ['cid'] );
  3731. $u = "";
  3732. $order = array (
  3733. "\r\n",
  3734. "\n",
  3735. "\r"
  3736. );
  3737. $replace = '</br>';
  3738. foreach ( $serviceLog as $key => $value ) {
  3739. $datetime = explode ( "-", $value ['date'] );
  3740. $u .= '<div class="infoFlowList">
  3741. <div class="dateTitle">
  3742. <em class="month"><span class="num">' . $datetime ['1'] . '</span><span class="text">-' . $datetime ['2'] . '</span></em>
  3743. <span class="year">' . $datetime ['0'] . '</span>
  3744. </div>
  3745. <ul class="flowList">';
  3746. if ($value ['status'] == 1)
  3747. $u .= '<li class="item iconService">上门服务</li>';
  3748. elseif ($value ['status'] == 2)
  3749. $u .= '<li class="item iconPhone">电话拜访</li>';
  3750. elseif ($value ['status'] == 3)
  3751. $u .= '<li class="item iconOther">其他</li>';
  3752. $u .= '
  3753. <li class="item">' . $value ['category'] . '<a href="javascript:void(0)" onclick="getStaffInfo(\'' . $value ['staffname'] . '\')" >' . $value ['staffname'] . '</a></li>
  3754. <li class="item">
  3755. ' . str_replace ( $order, $replace, $value ['mark'] ) . '
  3756. </li>
  3757. </ul>
  3758. </div>';
  3759. }
  3760. Doo::loadModel ( "tag_client" );
  3761. Doo::loadModel ( "tag" );
  3762. $tag = new tag ();
  3763. $tag_client = new tag_client ();
  3764. $tagId = $tag_client->getTagClientBySCid ( $clientInfo ['cid'], $this->staff [0] ['sid'] );
  3765. $taginfo = $tag->getTagByTidL ( $tagId ['tag'] );
  3766. // $taghtml="";
  3767. //
  3768. // foreach ($taginfo as $key=>$value){
  3769. // $taghtml.='<span class="contactsTag tagCol-0'.$value['colorid'].'">'.$value['name'].'</span>';
  3770. // }
  3771. $mhtml = "";
  3772. $dhtml = "";
  3773. for($month = 1; $month <= 12; $month ++) {
  3774. if (date ( "m" ) == $month)
  3775. $mhtml .= '<option selected value="' . $month . '">' . $month . '月</option>';
  3776. else
  3777. $mhtml .= '<option value="' . $month . '">' . $month . '月</option>';
  3778. }
  3779. for($day = 1; $day <= 31; $day ++) {
  3780. if (date ( "d" ) == $day)
  3781. $dhtml .= '<option selected value="' . $day . '">' . $day . '日</option>';
  3782. else
  3783. $dhtml .= '<option value="' . $day . '">' . $day . '日</option>';
  3784. }
  3785. // $b="";
  3786. // if(!empty($staffInfo))
  3787. // $b='<p class="fR">'.$staffInfo['category'].'-<a href="javascript:void(0)" onclick="getStaffInfo(\''.$staffInfo['username'].'\')" >'.$staffInfo['username'].'</a></p>'.$clientInfo['clientname'].' ';
  3788. //
  3789. $m = "";
  3790. if (! empty ( $companyInfo )) {
  3791. $m = '
  3792. <table width="100%">
  3793. <tbody>
  3794. <tr><th>单位全称</th><td colspan="3"><a href="javascript:void(0)" >' . $companyInfo [0] ['companyname'] . '</a></td></tr>
  3795. <tr><th>地区</th><td>' . $companyInfo [0] ['local'] . '</td><th>部门/职位</th><td>' . $clientInfo ['department'] . '/' . $clientInfo ['position'] . '</td></tr>
  3796. <tr><th>传真</th><td>' . $companyInfo [0] ['fax'] . '</td><th>办公室</th><td>' . $companyInfo [0] ['office'] . '</td></tr>
  3797. <tr><th>单位地址</th><td colspan="3">' . $companyInfo [0] ['address'] . '</td></tr>
  3798. <tr><th>乘车路线</th><td colspan="3">' . $companyInfo [0] ['ride'] . '</td></tr>
  3799. <tr><th>地标建筑</th><td colspan="3">' . $companyInfo [0] ['landmarks'] . '</td></tr>
  3800. <tr><th>参考住宿</th><td colspan="3">' . $clientInfo ['stay'] . '</td></tr>
  3801. <tr><th>单位主页</th><td colspan="3">' . $clientInfo ['webservice'] . '</td></tr>
  3802. </tbody></table>
  3803. ';
  3804. }
  3805. $clientHtml = array (
  3806. 'html' => '
  3807. <div class="modal-dialog ">
  3808. <div class="modal-content">
  3809. <div class="modal-header">
  3810. <h3><span class="fR"><a>' . $staffInfo ['category'] . ' ' . $staffInfo ['username'] . '</a></span>' . $clientInfo ['clientname'] . '</h3>
  3811. </div>
  3812. <div class="modal-body">
  3813. <div class="modalClientTable">
  3814. <table width="100%">
  3815. <tbody><tr><th>性别</th><td>' . $clientInfo ['gender'] . '</td><th>昵称</th><td>' . $clientInfo ['nicename'] . '</td></tr>
  3816. <tr><th>手机</th><td>' . $clientInfo ['telephone'] . '</td><th>QQ</th><td>' . $clientInfo ['qq'] . '</td></tr>
  3817. <tr><th>电话</th><td>' . $clientInfo ['phone'] . '</td><th>邮箱</th><td>' . $clientInfo ['email'] . '</td></tr>
  3818. <tr><th>软件锁</th><td colspan="3">' . $k . '</td></tr>
  3819. <tr><td colspan="4">
  3820. </td></tr>
  3821. </tbody>
  3822. </table>
  3823. ' . $m . '
  3824. <div class="clearfix">
  3825. ' . $u . '
  3826. </div>
  3827. </div>
  3828. </div>
  3829. <div class="modal-footer">
  3830. <a href="javascript:void(0)" onclick="closeClick()" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a>
  3831. </div>
  3832. </div></div>
  3833. '
  3834. );
  3835. echo json_encode ( $clientHtml );
  3836. }
  3837. function ajaxGetClientInfo() {
  3838. $clientname = $this->get_args ( 'client' ) ? $this->get_args ( 'client' ) : "";
  3839. if ($clientname == "") {
  3840. echo json_encode ( array (
  3841. "success" => false
  3842. ) );
  3843. die ();
  3844. }
  3845. Doo::loadModel ( 'client' );
  3846. Doo::loadModel ( 'client_staff' );
  3847. Doo::loadModel ( 'longle' );
  3848. Doo::loadModel ( 'company' );
  3849. Doo::loadModel ( 'service_log' );
  3850. Doo::loadModel ( "district" );
  3851. $district = new district ();
  3852. $service_log = new service_log ();
  3853. $company = new company ();
  3854. $longle = new longle ();
  3855. $client = new client ();
  3856. $client_staff = new client_staff ();
  3857. $nameStr = explode ( ",", $clientname );
  3858. // $clientname=$nameStr[1];
  3859. if (! empty ( $nameStr [0] )) {
  3860. $clientInfo = $client->getOne ( array (
  3861. "where" => ' cid = "' . $nameStr [0] . '"',
  3862. 'asArray' => TRUE
  3863. ) );
  3864. } elseif (! empty ( $nameStr [1] ))
  3865. $clientInfo = $client->getOne ( array (
  3866. "where" => ' clientname = "' . $nameStr [1] . '"',
  3867. 'asArray' => TRUE
  3868. ) );
  3869. else
  3870. $clientInfo = array ();
  3871. if (empty ( $clientInfo )) {
  3872. echo json_encode ( array (
  3873. "success" => false,
  3874. 'html' => ''
  3875. ) );
  3876. die ();
  3877. }
  3878. // 获取锁
  3879. $longleInfo = $longle->getLongleByClientid ( $clientInfo ['cid'] );
  3880. $k = "";
  3881. foreach ( $longleInfo as $key => $value ) {
  3882. if ($value ['status'] == 6 || $value ['status'] == 7)
  3883. $k .= '<a href="javascript:void(0)" class="disenable" onclick="getLock(' . $value ['lid'] . ')" >' . $value ['key_num'] . '/' . $value ['product'] . '/' . $value ['statusT'] . '</a>&nbsp; ';
  3884. else
  3885. $k .= '<a href="javascript:void(0)" onclick="getLock(' . $value ['lid'] . ')" >' . $value ['key_num'] . '/' . $value ['product'] . '/' . $value ['statusT'] . '</a>&nbsp; ';
  3886. }
  3887. // 获取办事人
  3888. $staffInfo = $client_staff->getClientByCid ( $clientInfo ['cid'] );
  3889. $b = "";
  3890. if (! empty ( $staffInfo ))
  3891. $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>';
  3892. // 获取公司信息
  3893. $companyInfo = $company->getCompanyByCid ( $clientInfo ['companyid'] );
  3894. $serviceLog = $service_log->getServiceByClientid ( $clientInfo ['cid'] );
  3895. $local = $district->getbyidlist ( $clientInfo ['district'] );
  3896. if (! isset ( $local [1] ))
  3897. $local [1] ['name'] = "";
  3898. if (! isset ( $local [2] ))
  3899. $local [2] ['name'] = "";
  3900. $m = "";
  3901. if (! empty ( $companyInfo )) {
  3902. $m = '<div class="contactPanel">
  3903. <table>
  3904. <tbody>
  3905. <tr><th>单位全称</th><td colspan="3"><a href="javascript:void(0)" onclick="getCompany(\'' . $companyInfo [0] ['cid'] . '\')">' . $companyInfo [0] ['companyname'] . '</a></td></tr>
  3906. <tr><th>单位主页</th><td colspan="3">' . $clientInfo ['webservice'] . '</td></tr>
  3907. <tr><th>客户地区</th><td>' . $local [0] ['name'] . ',' . $local [1] ['name'] . ',' . $local [2] ['name'] . '</td><th>部门/职位</th><td>' . $clientInfo ['department'] . '/' . $clientInfo ['position'] . '</td></tr>
  3908. <tr><th>客户传真</th><td>' . $clientInfo ['fax'] . '</td><th>办公室</th><td>' . $clientInfo ['office'] . '</td></tr>
  3909. <tr><th>客户地址</th><td colspan="3">' . $clientInfo ['address'] . '</td></tr>
  3910. <tr><th>客户乘车</th><td colspan="3">' . $clientInfo ['ride'] . '</td></tr>
  3911. <tr><th>客户地标</th><td colspan="3">' . $clientInfo ['landmarks'] . '</td></tr>
  3912. <tr><th>客户住宿</th><td colspan="3">' . $clientInfo ['stay'] . '</td></tr>
  3913. </tbody></table>
  3914. </div>';
  3915. }
  3916. $u = "";
  3917. $order = array (
  3918. "\r\n",
  3919. "\n",
  3920. "\r"
  3921. );
  3922. $replace = '</br>';
  3923. foreach ( $serviceLog as $key => $value ) {
  3924. $datetime = explode ( "-", $value ['date'] );
  3925. $u .= '<div class="infoFlowList">
  3926. <div class="dateTitle">
  3927. <em class="month"><span class="num">' . $datetime ['1'] . '</span><span class="text">-' . $datetime ['2'] . '</span></em>
  3928. <span class="year">' . $datetime ['0'] . '</span>
  3929. </div>
  3930. <ul class="flowList">';
  3931. if ($value ['status'] == 1)
  3932. $u .= '<li class="item iconService">上门服务<';
  3933. elseif ($value ['status'] == 2)
  3934. $u .= '<li class="item iconPhone">电话拜访<';
  3935. elseif ($value ['status'] == 3)
  3936. $u .= '<li class="item iconOther">其他<';
  3937. $u .= $value ['category'] . '<a href="javascript:void(0)" onclick="getStaffInfo(\'' . $value ['staffname'] . '\')" >' . $value ['staffname'] . '</a></li>
  3938. <li class="item">
  3939. ' . str_replace ( $order, $replace, $value ['mark'] ) . '
  3940. </li>
  3941. </ul>
  3942. </div>';
  3943. }
  3944. Doo::loadModel ( "tag_client" );
  3945. Doo::loadModel ( "tag" );
  3946. $tag = new tag ();
  3947. $tag_client = new tag_client ();
  3948. $tagId = $tag_client->getTagClientBySCid ( $clientInfo ['cid'], $this->staff [0] ['sid'] );
  3949. $taginfo = $tag->getTagByTidL ( $tagId ['tag'] );
  3950. $taghtml = "";
  3951. foreach ( $taginfo as $key => $value ) {
  3952. $taghtml .= '<span class="contactsTag tagCol-0' . $value ['colorid'] . '">' . $value ['name'] . '</span>';
  3953. }
  3954. $mhtml = "";
  3955. $dhtml = "";
  3956. $yhtml = "";
  3957. for($year = 2020; $year >= 2004; $year --) {
  3958. if (date ( "Y" ) == $year)
  3959. $yhtml .= '<option selected value="' . $year . '">' . $year . '年</option>';
  3960. else
  3961. $yhtml .= '<option value="' . $year . '">' . $year . '年</option>';
  3962. }
  3963. for($month = 1; $month <= 12; $month ++) {
  3964. if (date ( "m" ) == $month)
  3965. $mhtml .= '<option selected value="' . $month . '">' . $month . '月</option>';
  3966. else
  3967. $mhtml .= '<option value="' . $month . '">' . $month . '月</option>';
  3968. }
  3969. for($day = 1; $day <= 31; $day ++) {
  3970. if (date ( "d" ) == $day)
  3971. $dhtml .= '<option selected value="' . $day . '">' . $day . '日</option>';
  3972. else
  3973. $dhtml .= '<option value="' . $day . '">' . $day . '日</option>';
  3974. }
  3975. $clientHtml = array (
  3976. 'html' => '<div class="contactInfo clearfix">
  3977. <div class="contactPanel">
  3978. <h1>' . $b . '<a data-original-title="编辑客户" data-toggle="ctooltip" data-placement="right" href="javascript:clientEdit(' . $clientInfo ['cid'] . ')" class="icon- edit">I</a></h1>
  3979. <table>
  3980. <tbody><tr><th>性别</th><td>' . $clientInfo ['gender'] . '</td><th>昵称</th><td>' . $clientInfo ['nicename'] . '</td></tr>
  3981. <tr><th>手机</th><td>' . $clientInfo ['telephone'] . '</td><th>QQ</th><td>' . $clientInfo ['qq'] . '</td></tr>
  3982. <tr><th>电话</th><td>' . $clientInfo ['phone'] . '</td><th>邮箱</th><td>' . $clientInfo ['email'] . '</td></tr>
  3983. <tr><th>软件锁</th><td colspan="3">' . $k . '</td></tr>
  3984. <tr><th>备注</th><td colspan="3">' . $clientInfo ['mark'] . '</td></tr>
  3985. <tr><td colspan="4">
  3986. ' . $taghtml . '
  3987. </td></tr>
  3988. </tbody></table>
  3989. </div>
  3990. ' . $m . '
  3991. </div>
  3992. <div class="lockRecord autoHeightR1" >
  3993. <!--添加记录按钮-->
  3994. <div class="addRecord addRecordButton clearfix" >
  3995. <a href="#" onclick="slideupInfo(this)">+ 打开添加服务记录</a>
  3996. </div>
  3997. <!--添加记录-->
  3998. <div class="addRecord addRecordForm clearfix hide">
  3999. <a onclick="slidedownInfo(this)" class="fR slidedownInfo">- 关闭添加记录</a>
  4000. <form name="lk" action="/addServiceLog" method="post" >
  4001. <div class="control-group">
  4002. <div class="controls">
  4003. <label class="radio inline">
  4004. <input type="radio" name="logstatus" id="status" checked value="2">电话拜访
  4005. </label>
  4006. <label class="radio inline">
  4007. <input type="radio" name="logstatus" id="status" value="1" >上门服务
  4008. </label>
  4009. <label class="radio inline">
  4010. <input type="radio" name="logstatus" id="status" value="3">其他
  4011. </label>
  4012. </div>
  4013. </div>
  4014. <div class="control-group">
  4015. <div class="controls">时间:
  4016. <select name="y" id="y">
  4017. ' . $yhtml . '
  4018. </select>
  4019. <select name="m" id="m">
  4020. ' . $mhtml . '
  4021. </select>
  4022. <select name="d" id="d">
  4023. ' . $dhtml . '
  4024. </select>
  4025. </div>
  4026. </div>
  4027. <link href="' . WEB_SITE_GLOBAL . 'css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
  4028. <!--添加记录-备注-->
  4029. <!--<div class="control-group">
  4030. <div class="controls">
  4031. <select name="date" id="date">
  4032. <option value="2013">2013</option>
  4033. </select>
  4034. </div>
  4035. </div>-->
  4036. <div class="control-group">
  4037. <div class="controls" onclick="slideupInfo()">
  4038. <textarea name="mark" id="mark" style="width:95%" rows="5"></textarea>
  4039. <div class="bsAlert bsWarning"><b>含泪告知:</b>客户记录暂时无法修改!删除!,添加时请谨慎。点击确定添加成功后,信息会立即出现在下方!注意咯,别猛戳‘确定添加’导致重复添加了哦~</div>
  4040. </div>
  4041. </div>
  4042. <div class="control-group">
  4043. <div class="controls">
  4044. <div style="display:inline-block;margin-right:10px"><label><input name="Remind" onclick="reFK()" type="checkbox" value="1"> 添加提醒</label></div>
  4045. <span id="reHL" class="hide">
  4046. <div>
  4047. 限期:
  4048. <input type="date" name="time" id="dtp_input2" value="" class="hide"/>
  4049. </div>
  4050. <div>
  4051. 备注:<input id="remark" name="remark" type="text"></span>
  4052. </div>
  4053. </div>
  4054. <div class="control-group">
  4055. <div class="controls clearfix">
  4056. <input type="button" value="确定添加" id="conSer" onclick="aServiceLog(\'' . $this->staff [0] ['category'] . '\',\'' . $this->staff [0] ['username'] . '\',' . $clientInfo ['cid'] . ')" class="button"></input>
  4057. <div id="load"></div>
  4058. </div>
  4059. </div>
  4060. </div>
  4061. </form>
  4062. </div>
  4063. <!--添加记录按钮-->
  4064. <!--记录列表-->
  4065. <div id="kl"></div>
  4066. ' . $u . '
  4067. <script type="text/javascript">autoFlashHeight();</script> </div>'
  4068. );
  4069. echo json_encode ( $clientHtml );
  4070. }
  4071. function ajaxGetCompanyInfo() {
  4072. }
  4073. function checkClient() {
  4074. $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : "";
  4075. $company = $this->get_args ( 'company' ) ? $this->get_args ( 'company' ) : "";
  4076. if (! empty ( $name )&&! empty ( $company )) {
  4077. Doo::loadModel ( 'client' );
  4078. $client = new client ();
  4079. $clientInfo = $client->getClientByName2 ( $name, $company );
  4080. if (! empty ( $clientInfo ))
  4081. echo json_encode ( array (
  4082. "success" => true
  4083. ) );
  4084. else
  4085. echo json_encode ( array (
  4086. "success" => false
  4087. ) );
  4088. } else {
  4089. echo json_encode ( array (
  4090. "success" => false
  4091. ) );
  4092. }
  4093. }
  4094. function searchClient() {
  4095. $searchDbInforItem = $this->get_args ( 'searchDbInforItem' ) ? $this->get_args ( 'searchDbInforItem' ) : "";
  4096. if (! empty ( $searchDbInforItem )) {
  4097. Doo::loadModel ( 'client' );
  4098. $client = new client ();
  4099. $clientInfo = $client->getClientByName ( $searchDbInforItem );
  4100. echo json_encode ( $clientInfo );
  4101. } else {
  4102. echo json_encode ( array (
  4103. 0 => array (
  4104. 'clientname' => ''
  4105. )
  4106. ) );
  4107. }
  4108. }
  4109. function searchCompany() {
  4110. $searchDbInforItem = $this->get_args ( 'searchDbInforItem' ) ? $this->get_args ( 'searchDbInforItem' ) : "";
  4111. if (! empty ( $searchDbInforItem )) {
  4112. Doo::loadModel ( 'company' );
  4113. $company = new company ();
  4114. $clientInfo = $company->searchCompany ( $searchDbInforItem );
  4115. echo json_encode ( $clientInfo );
  4116. } else {
  4117. echo json_encode ( array (
  4118. 0 => array (
  4119. 'companyname' => '',
  4120. 'local' => ''
  4121. )
  4122. ) );
  4123. }
  4124. }
  4125. function checkCompany() {
  4126. $searchDbInforItem = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : "";
  4127. $searchDbInforItem = explode ( '-', $searchDbInforItem );
  4128. $this->nature ['naturelenght'] = 15;
  4129. Doo::loadModel ( 'district' );
  4130. $district = new district ();
  4131. $d = $district->get_lv ( 1 );
  4132. $html = '<option vlaue="0">请选择</option>';
  4133. foreach ( $d as $key => $value ) {
  4134. $html .= '<option value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  4135. }
  4136. $this->nature ['district'] = $html;
  4137. if (! empty ( $searchDbInforItem )) {
  4138. Doo::loadModel ( 'company' );
  4139. $company = new company ();
  4140. if (! isset ( $searchDbInforItem [1] )) {
  4141. echo json_encode ( array (
  4142. "success" => false,
  4143. 'nature' => $this->nature
  4144. ) );
  4145. die ();
  4146. }
  4147. $clientInfo = $company->getCompanyByName ( $searchDbInforItem [0], $searchDbInforItem [1] );
  4148. if (! empty ( $clientInfo ))
  4149. echo json_encode ( array (
  4150. "success" => true,
  4151. 'data' => $clientInfo
  4152. ) );
  4153. else
  4154. echo json_encode ( array (
  4155. "success" => false,
  4156. 'nature' => $this->nature
  4157. ) );
  4158. } else {
  4159. echo json_encode ( array (
  4160. "success" => false,
  4161. 'nature' => $this->nature
  4162. ) );
  4163. }
  4164. }
  4165. function checkLongle() {
  4166. $searchDbInforItem = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : "";
  4167. $searchDbInforItem = explode ( ' ', $searchDbInforItem );
  4168. if (! empty ( $searchDbInforItem )) {
  4169. Doo::loadModel ( 'longle' );
  4170. $longle = new longle ();
  4171. $clientInfo = $longle->getLongleBykeynum ( $searchDbInforItem [0] );
  4172. if (! empty ( $clientInfo ))
  4173. echo json_encode ( array (
  4174. "success" => true
  4175. ) );
  4176. else
  4177. echo json_encode ( array (
  4178. "success" => false
  4179. ) );
  4180. } else {
  4181. echo json_encode ( array (
  4182. "success" => false
  4183. ) );
  4184. }
  4185. }
  4186. function searchLongle() {
  4187. $searchDbInforItem = $this->get_args ( 'searchDbInforItem' ) ? $this->get_args ( 'searchDbInforItem' ) : "";
  4188. if (! empty ( $searchDbInforItem )) {
  4189. Doo::loadModel ( 'longle' );
  4190. $longle = new longle ();
  4191. $longleInfo = $longle->getLongleBykeynum2 ( $searchDbInforItem );
  4192. echo json_encode ( $longleInfo );
  4193. } else {
  4194. echo json_encode ( array (
  4195. 0 => array (
  4196. 'clientname' => ''
  4197. )
  4198. ) );
  4199. }
  4200. }
  4201. function updateChangeCompany() {
  4202. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4203. $clientID = $this->get_args ( 'clientID' ) ? $this->get_args ( 'clientID' ) : 0;
  4204. $companyname = $this->get_args ( 'companyname' ) ? $this->get_args ( 'companyname' ) : "";
  4205. Doo::loadModel ( 'company' );
  4206. Doo::loadModel ( 'client' );
  4207. $client = new client ();
  4208. $company = new company ();
  4209. $companyname = explode ( "-", $companyname );
  4210. if (isset ( $companyname [1] ))
  4211. $k = $company->getCompanyByName ( $companyname [0], $companyname [1] );
  4212. else
  4213. $k = array ();
  4214. if (! empty ( $cid ) && ! empty ( $k ) && ! empty ( $clientID )) {
  4215. $client->cid = $clientID;
  4216. $client->companyid = $cid;
  4217. $client->companyname = $companyname [0];
  4218. $client->update ();
  4219. } else {
  4220. $local1 = $this->get_args ( 'lv21' ) ? $this->get_args ( 'lv21' ) : 0;
  4221. $local2 = $this->get_args ( 'lv22' ) ? $this->get_args ( 'lv22' ) : 0;
  4222. $local3 = $this->get_args ( 'lv23' ) ? $this->get_args ( 'lv23' ) : 0;
  4223. Doo::loadModel ( 'district' );
  4224. $district = new district ();
  4225. // 更新公司信息
  4226. $lv1 = $district->getbyid ( $local1 );
  4227. $lv2 = $district->getbyid ( $local2 );
  4228. $lv3 = $district->getbyid ( $local3 );
  4229. if (empty ( $local1 ) || empty ( $local2 ))
  4230. return "/";
  4231. if (! empty ( $local1 ) && ! empty ( $local2 ))
  4232. $company->local = $lv1 [0] ['name'] . "," . $lv2 [0] ['name'] . "," . $lv3 [0] ['name'];
  4233. if (! empty ( $local1 ) && ! empty ( $local2 ))
  4234. $company->district = $local1 . "," . $local2 . "," . $local3;
  4235. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  4236. $fax = $this->get_args ( 'fax' ) ? $this->get_args ( 'fax' ) : "";
  4237. $webservice = $this->get_args ( 'webservice' ) ? $this->get_args ( 'webservice' ) : "";
  4238. $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
  4239. $landmarks = $this->get_args ( 'landmarks' ) ? $this->get_args ( 'landmarks' ) : "";
  4240. $stay = $this->get_args ( 'stay' ) ? $this->get_args ( 'stay' ) : "";
  4241. $ride = $this->get_args ( 'ride' ) ? $this->get_args ( 'ride' ) : "";
  4242. $nature = implode ( ",", $nature );
  4243. $company->companyname = $companyname [0];
  4244. $company->ride = $ride;
  4245. $company->fax = $fax;
  4246. $company->webservice = $webservice;
  4247. $company->address = $address;
  4248. $company->landmarks = $landmarks;
  4249. $company->stay = $stay;
  4250. $company->nature = $nature;
  4251. $cid = $company->insert ();
  4252. $client->cid = $clientID;
  4253. $client->companyid = $cid;
  4254. $client->companyname = $companyname [0];
  4255. $client->update ();
  4256. }
  4257. return "/contacts";
  4258. }
  4259. function AddClientInfo() { // 不编辑公司
  4260. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4261. $clientname = $this->get_args ( 'clientname' ) ? $this->get_args ( 'clientname' ) : "";
  4262. $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : "";
  4263. $nicename = $this->get_args ( 'nicename' ) ? $this->get_args ( 'nicename' ) : "";
  4264. $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : "";
  4265. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";
  4266. $email = $this->get_args ( 'email' ) ? $this->get_args ( 'email' ) : "";
  4267. $unit = $this->get_args ( 'unit' ) ? $this->get_args ( 'unit' ) : "";
  4268. $fax = $this->get_args ( 'fax' ) ? $this->get_args ( 'fax' ) : "";
  4269. $webservice = $this->get_args ( 'webservice' ) ? $this->get_args ( 'webservice' ) : "";
  4270. $department = $this->get_args ( 'department' ) ? $this->get_args ( 'department' ) : "";
  4271. $position = $this->get_args ( 'position' ) ? $this->get_args ( 'position' ) : "";
  4272. $office = $this->get_args ( 'office' ) ? $this->get_args ( 'office' ) : "";
  4273. $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
  4274. $ride = $this->get_args ( 'ride' ) ? $this->get_args ( 'ride' ) : "";
  4275. $landmarks = $this->get_args ( 'landmarks' ) ? $this->get_args ( 'landmarks' ) : "";
  4276. $qq = $this->get_args ( 'qq' ) ? $this->get_args ( 'qq' ) : "";
  4277. $priority = $this->get_args ( 'priority' ) ? $this->get_args ( 'priority' ) : 5;
  4278. $stay = $this->get_args ( 'stay' ) ? $this->get_args ( 'stay' ) : "";
  4279. $mark = $this->get_args ( 'mark' ) ? $this->get_args ( 'mark' ) : "";
  4280. $lv21 = $this->get_args ( 'lv21' ) ? $this->get_args ( 'lv21' ) : "";
  4281. $lv22 = $this->get_args ( 'lv22' ) ? $this->get_args ( 'lv22' ) : "";
  4282. $lv23 = $this->get_args ( 'lv23' ) ? $this->get_args ( 'lv23' ) : "";
  4283. if (! empty ( $cid ) && ! empty ( $clientname )) {
  4284. Doo::loadModel ( 'client' );
  4285. Doo::loadModel ( 'district' );
  4286. $district = new district ();
  4287. $client = new client ();
  4288. $client->cid = $cid;
  4289. $client->clientname = $clientname;
  4290. $client->gender = $gender;
  4291. $client->nicename = $nicename;
  4292. $client->telephone = $telephone;
  4293. $client->phone = $phone;
  4294. $client->email = $email;
  4295. // if(!empty($unit)){
  4296. // $client->unit=$unit;
  4297. // $client->companyname=$unit;
  4298. // }
  4299. if (! empty ( $lv21 ) && ! empty ( $lv22 ) && ! empty ( $lv23 )) {
  4300. $client->district = $lv21 . "," . $lv22 . "," . $lv23;
  4301. }
  4302. if (! empty ( $client->district )) {
  4303. $districtList = $district->find ( array (
  4304. 'where' => 'id in(' . $client->district . ')',
  4305. 'asArray' => true
  4306. ) );
  4307. $jsonString = array ();
  4308. foreach ( $districtList as $value ) {
  4309. array_push ( $jsonString, $value ['name'] );
  4310. }
  4311. $jsonString = implode ( ",", $jsonString );
  4312. if (! empty ( $jsonString ))
  4313. $client->local = $jsonString;
  4314. }
  4315. $client->fax = $fax;
  4316. $client->webservice = $webservice;
  4317. $client->department = $department;
  4318. $client->position = $position;
  4319. $client->office = $office;
  4320. $client->address = $address;
  4321. $client->ride = $ride;
  4322. $client->landmarks = $landmarks;
  4323. $client->qq = $qq;
  4324. $client->stay = $stay;
  4325. $client->priority = $priority;
  4326. $client->mark = $mark;
  4327. $client->updatetime = time ();
  4328. $client->update ();
  4329. // Doo::loadModel ( 'company' );
  4330. // $company = new company();
  4331. // $companyid=$client->getOne(array('where'=>' cid='.$cid,'asArray'=>true));
  4332. // $company->office=$office;
  4333. // $company->fax=$fax;
  4334. // $company->address=$address;
  4335. // $company->ride=$ride;
  4336. // $company->landmarks=$landmarks;
  4337. // $company->cid=$companyid['companyid'];
  4338. // if(!empty($unit)){
  4339. // $company->companyname=$unit;
  4340. // }
  4341. // $company->update();
  4342. $clientInfo = $client->getOne ( array (
  4343. 'where' => ' cid=' . $cid,
  4344. 'asArray' => true
  4345. ) );
  4346. // 日常行为
  4347. Doo::loadModel ( "action_log" );
  4348. $action_log = new action_log ();
  4349. $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'] . ')';
  4350. $action_log->sid = $this->staff [0] ['sid'];
  4351. $action_log->cid = $this->staff [0] ['cid'];
  4352. $action_log->updatetime = date ( "Y-m-d" );
  4353. $action_log->time = date ( "H:i" );
  4354. $action_log->class = $action_log->iconContacts;
  4355. $action_log->status = 2;
  4356. $action_log->districtid = $clientInfo ['district'];
  4357. $local = $district->getbyidlist ( $clientInfo ['district'] );
  4358. $action_log->city = $local [0] ['name'];
  4359. $action_log->province = $local [1] ['name'];
  4360. $action_log->company = $clientInfo ['companyname'];
  4361. Doo::loadModel ( 'company' );
  4362. $company = new company ();
  4363. $companyInfo = $company->getOne ( array (
  4364. 'where' => ' companyname="' . $clientInfo ['companyname'] . '"',
  4365. 'asArray' => true
  4366. ) );
  4367. $nature = explode ( ',', $companyInfo ['nature'] );
  4368. $action_log->nature = $nature [0];
  4369. $action_log->insert ();
  4370. echo json_encode ( array (
  4371. "success" => true
  4372. ) );
  4373. die ();
  4374. } else
  4375. echo json_encode ( array (
  4376. "success" => false
  4377. ) );
  4378. die ();
  4379. }
  4380. function ajaxClientInfo() {
  4381. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4382. if (! empty ( $cid )) {
  4383. Doo::loadModel ( 'client' );
  4384. Doo::loadModel ( 'company' );
  4385. $company = new company ();
  4386. $client = new client ();
  4387. $info = $client->getOne ( array (
  4388. 'where' => ' cid=' . $cid,
  4389. 'asArray' => true
  4390. ) );
  4391. $cinfo = $company->getOne ( array (
  4392. 'where' => ' cid=' . $info ['companyid'],
  4393. 'asArray' => true
  4394. ) );
  4395. Doo::loadModel ( 'district' );
  4396. $district = new district ();
  4397. $districtLv1 = $district->get_lv ( 1 );
  4398. $info ['districtList'] = $district->getbyidlist ( $info ['district'] );
  4399. $optionHtml = '<option vlaue="0">请选择</option>';
  4400. foreach ( $districtLv1 as $key => $value ) {
  4401. if ($value ['name'] == $info ['districtList'] [0] ['name']) {
  4402. $optionHtml .= '<option selected value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  4403. } else
  4404. $optionHtml .= '<option value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  4405. }
  4406. $districtLv2 = $district->get_lvByid ( 2, $info ['districtList'] [0] ['id'] );
  4407. $optionHtml2 = '';
  4408. foreach ( $districtLv2 as $key => $value ) {
  4409. if ($value ['name'] == $info ['districtList'] [1] ['name'])
  4410. $optionHtml2 .= '<option selected value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  4411. else
  4412. $optionHtml2 .= '<option value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  4413. }
  4414. $districtLv3 = $district->get_lvByid ( 2, $info ['districtList'] [1] ['id'] );
  4415. $optionHtml3 = '';
  4416. foreach ( $districtLv3 as $key => $value ) {
  4417. if ($value ['name'] == $info ['districtList'] [2] ['name'])
  4418. $optionHtml3 .= '<option selected value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  4419. else
  4420. $optionHtml3 .= '<option value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  4421. }
  4422. $info ['districtLv1'] = $optionHtml;
  4423. $info ['districtLv2'] = $optionHtml2;
  4424. $info ['districtLv3'] = $optionHtml3;
  4425. $info ['companyInfo'] = $cinfo;
  4426. echo json_encode ( array (
  4427. "success" => true,
  4428. 'html' => $info
  4429. ) );
  4430. die ();
  4431. } else
  4432. echo json_encode ( array (
  4433. "success" => false,
  4434. 'html' => ''
  4435. ) );
  4436. die ();
  4437. }
  4438. /**
  4439. * 为客户添加服务日志
  4440. */
  4441. function ajaxAddServiceLog() {
  4442. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : "";
  4443. $clientid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "";
  4444. $mark = $this->get_args ( 'mark' ) ? $this->get_args ( 'mark' ) : "";
  4445. $m = $this->get_args ( 'm' ) ? $this->get_args ( 'm' ) : "";
  4446. $d = $this->get_args ( 'd' ) ? $this->get_args ( 'd' ) : "";
  4447. $y = $this->get_args ( 'y' ) ? $this->get_args ( 'y' ) : date ( "Y" );
  4448. $Remind = $this->get_args ( 'Remind' ) ? $this->get_args ( 'Remind' ) : 0;
  4449. $time = $this->get_args ( 'time' ) ? $this->get_args ( 'time' ) : 0;
  4450. $remark = $this->get_args ( 'remark' ) ? $this->get_args ( 'remark' ) : "";
  4451. if (! empty ( $status ) && ! empty ( $clientid )) {
  4452. Doo::loadModel ( 'service_log' );
  4453. Doo::loadModel ( 'client_staff' );
  4454. Doo::loadModel ( 'client' );
  4455. Doo::loadModel ( 'district' );
  4456. $district = new district ();
  4457. $client = new client ();
  4458. $clientStaff = new client_staff ();
  4459. $service_log = new service_log ();
  4460. $service_log->status = $status;
  4461. $service_log->clientid = $clientid;
  4462. $service_log->mark = htmlspecialchars ( $mark );
  4463. $service_log->date = $y . "-" . $m . "-" . $d;
  4464. $service_log->category = $this->staff [0] ['category'];
  4465. $service_log->staffname = $this->staff [0] ['username'];
  4466. $service_log->staffid = $this->staff [0] ['sid'];
  4467. $service_log->insert ();
  4468. // 日常行为
  4469. Doo::loadModel ( "action_log" );
  4470. Doo::loadModel ( "client" );
  4471. $client = new client ();
  4472. // 记录服务时间
  4473. $client->cid = $clientid;
  4474. $client->servicetime = time ();
  4475. $client->update ();
  4476. $action_log = new action_log ();
  4477. $clientInfo = $client->getOne ( array (
  4478. 'where' => ' cid=' . $clientid,
  4479. 'asArray' => TRUE
  4480. ) );
  4481. $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'] . ')添加新客户记录。';
  4482. $action_log->sid = $this->staff [0] ['sid'];
  4483. $action_log->cid = $this->staff [0] ['cid'];
  4484. $action_log->updatetime = date ( "Y-m-d" );
  4485. $action_log->time = date ( "H:i" );
  4486. $action_log->status = 3;
  4487. $action_log->districtid = $clientInfo ['district'];
  4488. $local = $district->getbyidlist ( $clientInfo ['district'] );
  4489. $action_log->city = $local [0] ['name'];
  4490. $action_log->province = $local [1] ['name'];
  4491. $action_log->company = $clientInfo ['companyname'];
  4492. Doo::loadModel ( 'company' );
  4493. $company = new company ();
  4494. $companyInfo = $company->getOne ( array (
  4495. 'where' => ' companyname="' . $clientInfo ['companyname'] . '"',
  4496. 'asArray' => true
  4497. ) );
  4498. $nature = explode ( ',', $companyInfo ['nature'] );
  4499. $action_log->nature = $nature [0];
  4500. $action_log->class = $action_log->iconContacts;
  4501. $action_log->insert ();
  4502. // 更新信息中心服务日志统计数量
  4503. $redis = new Redis ();
  4504. $redis->connect ( '127.0.0.1', '6379' );
  4505. $categoryCondition = " and cid=" . $this->staff [0] ['cid'];
  4506. $sidCondition = " and sid=" . $this->staff [0] ['sid'];
  4507. // actionlog免查询值 $alCondition='';
  4508. $alCondition = ' aid>' . REMIT . ' and ';
  4509. // 个人服务日志数量redis值
  4510. $redisKeyCS = date ( 'Y-m-d' ) . 'SL_' . $this->staff [0] ['cid'] . '_' . $this->staff [0] ['sid'];
  4511. $action_log = new action_log ();
  4512. $actionLogLongle = $action_log->find ( array (
  4513. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  4514. 'where' => $alCondition . " status=3 " . $categoryCondition . $sidCondition . " and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) ",
  4515. 'groupby' => 'date_format(updatetime,"%m-%d")',
  4516. 'asArray' => true
  4517. ) );
  4518. $statisticsLongle = array ();
  4519. for($d = 0; $d <= 29; $d ++) {
  4520. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  4521. $falgLongle = true;
  4522. foreach ( $actionLogLongle as $value ) {
  4523. if ($value ['updatetime'] == $MD) {
  4524. array_push ( $statisticsLongle, $value ['count'] );
  4525. $falgLongle = false;
  4526. break;
  4527. }
  4528. }
  4529. if ($falgLongle)
  4530. array_push ( $statisticsLongle, 0 );
  4531. }
  4532. $statisticsLongle = array_reverse ( $statisticsLongle );
  4533. $jsl = json_encode ( $statisticsLongle );
  4534. $redis->set ( $redisKeyCS, $jsl );
  4535. // 办事处服务日志数量reids值
  4536. $redisKeyC = date ( 'Y-m-d' ) . 'SL_' . $this->staff [0] ['cid'] . '_';
  4537. $action_log = new action_log ();
  4538. $actionLogLongle = $action_log->find ( array (
  4539. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  4540. 'where' => $alCondition . " status=3 " . $categoryCondition . " and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) ",
  4541. 'groupby' => 'date_format(updatetime,"%m-%d")',
  4542. 'asArray' => true
  4543. ) );
  4544. $statisticsLongle = array ();
  4545. for($d = 0; $d <= 29; $d ++) {
  4546. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  4547. $falgLongle = true;
  4548. foreach ( $actionLogLongle as $value ) {
  4549. if ($value ['updatetime'] == $MD) {
  4550. array_push ( $statisticsLongle, $value ['count'] );
  4551. $falgLongle = false;
  4552. break;
  4553. }
  4554. }
  4555. if ($falgLongle)
  4556. array_push ( $statisticsLongle, 0 );
  4557. }
  4558. $statisticsLongle = array_reverse ( $statisticsLongle );
  4559. $jsl = json_encode ( $statisticsLongle );
  4560. $redis->set ( $redisKeyC, $jsl );
  4561. // 全员处服务日志数量的redis值
  4562. $redisKey = date ( 'Y-m-d' ) . 'SL__';
  4563. $action_log = new action_log ();
  4564. $actionLogLongle = $action_log->find ( array (
  4565. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  4566. 'where' => $alCondition . " status=3 and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) ",
  4567. 'groupby' => 'date_format(updatetime,"%m-%d")',
  4568. 'asArray' => true
  4569. ) );
  4570. $statisticsLongle = array ();
  4571. for($d = 0; $d <= 29; $d ++) {
  4572. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  4573. $falgLongle = true;
  4574. foreach ( $actionLogLongle as $value ) {
  4575. if ($value ['updatetime'] == $MD) {
  4576. array_push ( $statisticsLongle, $value ['count'] );
  4577. $falgLongle = false;
  4578. break;
  4579. }
  4580. }
  4581. if ($falgLongle)
  4582. array_push ( $statisticsLongle, 0 );
  4583. }
  4584. $statisticsLongle = array_reverse ( $statisticsLongle );
  4585. $jsl = json_encode ( $statisticsLongle );
  4586. $redis->set ( $redisKey, $jsl );
  4587. if (! empty ( $Remind )) {
  4588. Doo::loadModel ( 'remind' );
  4589. $remindObj = new remind ();
  4590. $datetime1 = new DateTime ( date ( 'Y-m-d' ) );
  4591. $datetime2 = new DateTime ( $time );
  4592. $interval = $datetime1->diff ( $datetime2 );
  4593. $remindObj->day = $interval->format ( '%a' );
  4594. $remindObj->remark = $remark;
  4595. $remindObj->time = date ( "Y-m-d" );
  4596. $remindObj->clientName = $clientInfo ['clientname'];
  4597. $remindObj->clientID = $clientid;
  4598. $remindObj->companyName = $clientInfo ['companyname'];
  4599. $remindObj->companyID = $companyInfo ['cid'];
  4600. $remindObj->staffID = $this->staff [0] ['sid'];
  4601. if ($status == 1)
  4602. $remindObj->class = "iconService";
  4603. if ($status == 2)
  4604. $remindObj->class = "iconPhone";
  4605. if ($status == 3)
  4606. $remindObj->class = "iconOther";
  4607. $remindObj->insert ();
  4608. }
  4609. echo json_encode ( array (
  4610. "success" => true,
  4611. 'html' => ''
  4612. ) );
  4613. die ();
  4614. } else
  4615. echo json_encode ( array (
  4616. "success" => false,
  4617. 'html' => ''
  4618. ) );
  4619. die ();
  4620. }
  4621. function _getLongleLogHtml($longleLog = array()) {
  4622. $html = "";
  4623. foreach ( $longleLog as $key => $value ) {
  4624. $dateline = explode ( "-", $value ['dateline'] );
  4625. $html .= '<div class="infoFlowList">
  4626. <div class="dateTitle">
  4627. <em class="month"><span class="num">' . $dateline [1] . '</span><span class="text">-' . $dateline [2] . '</span></em>
  4628. <span class="year">' . $dateline [0] . '</span>
  4629. </div>
  4630. ';
  4631. // 备注
  4632. if ($value ['status'] == 8) {
  4633. $html .= '
  4634. <ul class="flowList">
  4635. <li class="item iconLock">备注<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')" >' . $value ['operator'] . '</a></li>
  4636. <li class="item">' . $value ['mark'] . '</li>
  4637. </ul>';
  4638. // 生成
  4639. } elseif ($value ['status'] == 1) {
  4640. $html .= '<ul class="flowList">
  4641. <li class="item iconGenerate">生成<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')" >' . $value ['operator'] . '</a></li>
  4642. </ul>';
  4643. // 接收
  4644. } elseif ($value ['status'] == 2) {
  4645. $html .= '<ul class="flowList">
  4646. <li class="item iconReceive">接收<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')" >' . $value ['operator'] . '</a></li>
  4647. </ul>';
  4648. // 借出
  4649. } elseif ($value ['status'] == 3) {
  4650. $html .= '<ul class="flowList">
  4651. <li class="item iconBorrow">借出<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')" >' . $value ['operator'] . '</a></li>
  4652. <li class="item">' . $value ['product'] . '</li>
  4653. <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\'' . $value ['clientid'] . "," . $value ['client'] . '\')" >' . $value ['client'] . '</a></li>
  4654. </ul>';
  4655. // 销售
  4656. } elseif ($value ['status'] == 4) {
  4657. $html .= '<ul class="flowList">
  4658. <li class="item iconSell">销售<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')" >' . $value ['operator'] . '</a></li>
  4659. <li class="item">' . $value ['product'] . '</li>
  4660. <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\'' . $value ['clientid'] . "," . $value ['client'] . '\')" >' . $value ['client'] . '</a></li>
  4661. </ul>';
  4662. // 升级
  4663. } elseif ($value ['status'] == 5) {
  4664. $html .= '<ul class="flowList">
  4665. <li class="item iconUpdate">升级<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')" >' . $value ['operator'] . '</a></li>
  4666. <li class="item">' . $value ['product'] . '</li>
  4667. <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\'' . $value ['clientid'] . "," . $value ['client'] . '\')" >' . $value ['client'] . '</a></li>
  4668. </ul>';
  4669. // 更换
  4670. } elseif ($value ['status'] == 6) {
  4671. $html .= '<ul class="flowList">
  4672. <li class="item iconReplace">更换<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')">' . $value ['operator'] . '</a></li>
  4673. <li class="item"><a href="javascript:void(0);" onclick="getLockByName(\'' . $value ['new_key_num'] . '\')">' . $value ['new_key_num'] . '</a>
  4674. <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\'' . $value ['clientid'] . "," . $value ['client'] . '\')" >' . $value ['client'] . '</a></li>
  4675. </ul>';
  4676. // 回收
  4677. } elseif ($value ['status'] == 7) {
  4678. Doo::loadModel ( 'staff' );
  4679. $staff = new staff ();
  4680. $staffinfo = $staff->getOne ( array (
  4681. 'where' => ' username like "' . $value ['responsible'] . '"',
  4682. 'asArray' => true
  4683. ) );
  4684. if (empty ( $staffinfo ))
  4685. $staffinfo ['category'] = "";
  4686. $html .= '<ul class="flowList">
  4687. <li class="item iconRecycle">收回<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')">' . $value ['operator'] . '</a></li>
  4688. <li class="item">' . $staffinfo ['category'] . '<a href="javascript:void(0);" id="ajaxStaff" data="' . $value ['responsible'] . '">' . $value ['responsible'] . '</a></li>
  4689. </ul>';
  4690. } elseif ($value ['status'] == 9) {
  4691. $html .= '<ul class="flowList">
  4692. <li class="item iconGif">赠送 &lt; ' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')">' . $value ['operator'] . '</a></li>
  4693. <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\'' . $value ['clientid'] . "," . $value ['client'] . '\')" >' . $value ['client'] . '</a></li>
  4694. </ul>';
  4695. }
  4696. $html .= '</div>';
  4697. }
  4698. return $html;
  4699. }
  4700. function adminLock() {
  4701. $emsg = isset ( $this->params ['emsg'] ) ? $this->params ['emsg'] : "";
  4702. $data ['emsg'] = "";
  4703. if ($emsg != "")
  4704. $data ['emsg'] = "请填写完整的数据";
  4705. $data ['memu'] = "keyonline";
  4706. $data ['staff'] = $this->staff;
  4707. if ($this->staff [0] ['isadmin'] != 1)
  4708. return "/adminmyinfo";
  4709. Doo::loadModel ( 'L_category' );
  4710. $L_category = new L_category ();
  4711. $data ['category'] = $L_category->getCategory ();
  4712. $data ['time'] = time ();
  4713. $this->render ( "/admin/admin_addlock", $data );
  4714. }
  4715. function adminAddLock() {
  4716. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4717. $path = $this->get_args ( 'path' ) ? $this->get_args ( 'path' ) : "";
  4718. if ($cid != 0 && $path != "") {
  4719. Doo::loadModel ( 'longle' );
  4720. Doo::loadModel ( 'L_category' );
  4721. $L_category = new L_category ();
  4722. Doo::loadModel ( 'longle_log' );
  4723. $exlArray = $this->_format_excel_to_array ( DOO::conf ()->SITE_PATH . "upload/" . iconv ( "UTF-8", "GB2312", $path ) );
  4724. // print_r($exlArray);die;
  4725. // echo json_encode($exlArray);die;
  4726. $category = $L_category->getCategoryById ( $cid );
  4727. foreach ( $exlArray as $key => $value ) {
  4728. // 锁记录
  4729. $longle = new longle ();
  4730. $longle->key_num = str_replace ( "'", "", $value ['key_num'] );
  4731. $longle->product = str_replace ( "'", "", $value ['product'] );
  4732. $longle->make_day = $value ['make_day'];
  4733. $longle->alloted_time = $value ['alloted_time'];
  4734. $longle->status = 1;
  4735. $longle->statusT = "生成";
  4736. $longle->cid = $cid;
  4737. $longle->category = $category [0] ['title'];
  4738. $longle->SerialNumber = $value ['SerialNumber'];
  4739. $longle->version = $value ['version'];
  4740. $lid = $longle->insert ();
  4741. // 锁日志记录
  4742. $longle_log = new longle_log ();
  4743. $longle_log->lid = $lid;
  4744. $longle_log->status = 1;
  4745. $longle_log->statusT = "生成";
  4746. $longle_log->operator = $this->staff [0] ['username'];
  4747. $longle_log->product = $longle->product;
  4748. $longle_log->category = $this->staff [0] ['category'];
  4749. $longle_log->dateline = date ( "Y-m-d" );
  4750. $id = $longle_log->insert ();
  4751. }
  4752. // 记录日常行为
  4753. Doo::loadModel ( "action_log" );
  4754. $action_log = new action_log ();
  4755. $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>个锁';
  4756. $action_log->sid = $this->staff [0] ['sid'];
  4757. $action_log->cid = $this->staff [0] ['cid'];
  4758. $action_log->class = $action_log->iconGenerate;
  4759. $action_log->updatetime = date ( "Y-m-d" );
  4760. $action_log->time = date ( "H:i" );
  4761. $action_log->status = 11;
  4762. $action_log->insert ();
  4763. return "/keyonline";
  4764. } else
  4765. return "/adminlock/error";
  4766. }
  4767. function avatarCM() {
  4768. $vid = isset ( $this->params ['vid'] ) ? $this->params ['vid'] : 0;
  4769. if (! empty ( $vid )) {
  4770. Doo::loadModel ( "verify" );
  4771. $verify = new verify ();
  4772. Doo::loadModel ( 'staff' );
  4773. $staff = new staff ();
  4774. $list = $verify->getOne ( array (
  4775. 'where' => 'vid=' . $vid,
  4776. 'asArray' => true
  4777. ) );
  4778. if (empty ( $list ))
  4779. return "/adminverify";
  4780. $avatar = json_decode ( $list ['staff'] );
  4781. foreach ( $avatar as $key => $value ) {
  4782. $uinfo = $staff->getOne ( array (
  4783. 'where' => 'sid=' . $value [0],
  4784. 'asArray' => true
  4785. ) );
  4786. $avatar [$key] ['2'] = $uinfo ['avatar'];
  4787. }
  4788. $verify->staff = json_encode ( $avatar );
  4789. $verify->update ( array (
  4790. 'where' => 'vid=' . $vid
  4791. ) );
  4792. }
  4793. return "/adminverify";
  4794. }
  4795. function adminmyinfo() {
  4796. $data ['memu'] = "adminmyinfo";
  4797. $data ['staff'] = $this->staff;
  4798. $birArray = explode ( '-', $this->staff [0] ['birthday'] );
  4799. $data ['year'] = $birArray [0];
  4800. $year = date ( 'Y' );
  4801. $yearHtml = "";
  4802. for(; $year >= 1900; $year --) {
  4803. $yearHtml .= '<option ';
  4804. if ($data ['year'] == $year)
  4805. $yearHtml .= 'selected';
  4806. $yearHtml .= ' value="' . $year . '">' . $year . '</option>';
  4807. }
  4808. $data ['yearHtml'] = $yearHtml;
  4809. $data ['month'] = 01;
  4810. $data ['day'] = 01;
  4811. if (isset ( $birArray [1] )) {
  4812. $data ['month'] = $birArray [1];
  4813. $data ['day'] = $birArray [2];
  4814. }
  4815. $data ['msg'] = urldecode ( $this->params ['msg'] );
  4816. $this->render ( "/admin/admin_myinfo", $data );
  4817. }
  4818. function updateMyinfo() {
  4819. $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : 0;
  4820. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : 0;
  4821. $email = $this->get_args ( 'email' ) ? $this->get_args ( 'email' ) : "";
  4822. $qq = is_numeric ( $this->get_args ( 'qq' ) ) ? $_POST ['qq'] : 0;
  4823. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4824. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4825. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : "";
  4826. $position = $this->get_args ( 'position' ) ? $this->get_args ( 'position' ) : "";
  4827. $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : "男";
  4828. $oldpassword = $this->get_args ( 'oldpassword' ) ? $this->get_args ( 'oldpassword' ) : "";
  4829. $newpassword = $this->get_args ( 'newpassword' ) ? $this->get_args ( 'newpassword' ) : "";
  4830. $rnewpassword = $this->get_args ( 'rnewpassword' ) ? $this->get_args ( 'rnewpassword' ) : "";
  4831. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  4832. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  4833. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  4834. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  4835. Doo::loadModel ( 'staff' );
  4836. $staff = new staff ();
  4837. Doo::loadModel ( 'staffDynamic' );
  4838. $staffDynamic = new staffDynamic ();
  4839. $staff->sid = $this->staff [0] ['sid'];
  4840. if (! empty ( $remittanceName ))
  4841. $staff->remittanceName = $remittanceName;
  4842. if (! empty ( $bankName ))
  4843. $staff->bankName = $bankName;
  4844. if (! empty ( $bankNumber ))
  4845. $staff->bankNumber = $bankNumber;
  4846. if (! empty ( $coupletNumber ))
  4847. $staff->coupletNumber = $coupletNumber;
  4848. $content = "";
  4849. $ext = "更新了他的";
  4850. if ($telephone != 0 && $this->staff [0] ['telephone'] != $telephone) {
  4851. $staff->telephone = $telephone;
  4852. $content .= "<b>手机</b>&nbsp;";
  4853. }
  4854. if ($phone != 0 && $this->staff [0] ['phone'] != $phone) {
  4855. $staff->phone = $phone;
  4856. $content .= "<b>电话</b>&nbsp;";
  4857. }
  4858. if ($qq != 0 && $this->staff [0] ['qq'] != $qq) {
  4859. $staff->qq = $qq;
  4860. $content .= "<b>QQ</b>&nbsp;";
  4861. }
  4862. if ($year != 2014) {
  4863. $staff->birthday = $year . "-" . $month . "-" . $day;
  4864. $content .= "<b>生日</b>&nbsp;";
  4865. }
  4866. if ($email != "" && filter_var ( $email, FILTER_VALIDATE_EMAIL ) && $this->staff [0] ['email'] != $email) {
  4867. $staff->email = $email;
  4868. $content .= "<b>邮箱</b>&nbsp;";
  4869. }
  4870. if (! empty ( $position )) {
  4871. $staff->position = $position;
  4872. $content .= "<b>职位</b>&nbsp;";
  4873. }
  4874. $staff->gender = $gender;
  4875. $msg = "更新成功";
  4876. if ($this->staff [0] ['passwork'] == md5 ( $oldpassword )) {
  4877. if ($newpassword == $rnewpassword && (! empty ( $newpassword )))
  4878. $staff->passwork = md5 ( $newpassword );
  4879. else
  4880. $msg = "密码不一致";
  4881. } else {
  4882. if ($oldpassword != "")
  4883. $msg = "密码错误";
  4884. }
  4885. if (! empty ( $content )) {
  4886. $staffDynamic->content = $ext . $content;
  4887. $staffDynamic->cid = $this->staff [0] ['cid'];
  4888. $staffDynamic->category = $this->staff [0] ['category'];
  4889. $staffDynamic->time = time ();
  4890. $staffDynamic->sid = $this->staff [0] ['sid'];
  4891. $staffDynamic->staff = $this->staff [0] ['username'];
  4892. $staffDynamic->insert ();
  4893. }
  4894. $staff->update ( array (
  4895. 'where' => ' sid=' . $this->staff [0] ['sid']
  4896. ) );
  4897. return "/adminmyinfo/" . $msg;
  4898. }
  4899. function admincontacts() {
  4900. $data ['memu'] = "admincontacts";
  4901. $data ['staff'] = $this->staff;
  4902. Doo::loadModel ( 'L_category' );
  4903. Doo::loadModel ( 'staff' );
  4904. $staff = new staff ();
  4905. $L_category = new L_category ();
  4906. $this->render ( "/admin/admin_addContacts", $data );
  4907. }
  4908. /**
  4909. * 微信通知设置
  4910. */
  4911. // function notificationConf() {
  4912. // Doo::loadModel ( "notificationConf" );
  4913. // $notificationConf = new notificationConf ();
  4914. // $detail = $notificationConf->getNotificationConfBySid ( $this->staff [0] ['sid'] );
  4915. // $rule = json_decode ( $detail ['conf'], true );
  4916. // $data ['rule'] = $rule;
  4917. // $data ['memu'] = "notificationConf";
  4918. // $data ['staff'] = $this->staff;
  4919. // $this->render ( "/admin/invoiceNotificationConf", $data );
  4920. // }
  4921. // function ajaxSetNotificationConf() {
  4922. // $notificationType = $this->get_args ( 'notificationType' ) ? $this->get_args ( 'notificationType' ) : "";
  4923. // $notificationValue = $this->get_args ( 'notificationValue' ) ? $this->get_args ( 'notificationValue' ) : '';
  4924. // if (! empty ( $notificationType ) && ! empty ( $notificationValue ) && ! empty ( $this->staff [0] ['sid'] )) {
  4925. // Doo::loadModel ( "notificationConf" );
  4926. // $notificationConf = new notificationConf ();
  4927. // $detail = $notificationConf->getNotificationConfBySid ( $this->staff [0] ['sid'] );
  4928. // if (empty ( $detail )) {
  4929. // $rule = array (
  4930. // $notificationType => $notificationValue
  4931. // );
  4932. // $rule = json_encode ( $rule );
  4933. // $item = array (
  4934. // 'sid' => $this->staff [0] ['sid'],
  4935. // 'conf' => $rule
  4936. // );
  4937. // $notificationConf->addNotification ( $item );
  4938. // } else {
  4939. // $rule = json_decode ( $detail ['conf'], true );
  4940. // $rule [$notificationType] = $notificationValue;
  4941. // $rule = json_encode ( $rule );
  4942. // $item = array (
  4943. // 'nid' => $detail ['nid'],
  4944. // 'conf' => $rule
  4945. // );
  4946. // $notificationConf->setNotificationByCondition ( $item );
  4947. // }
  4948. // echo json_encode ( array (
  4949. // 'status' => 1,
  4950. // 'msgType' => $notificationType,
  4951. // 'msg' => ''
  4952. // ) );
  4953. // die ();
  4954. // }
  4955. // echo json_encode ( array (
  4956. // 'status' => 2,
  4957. // 'msgType' => $notificationType,
  4958. // 'msg' => 'illegal request'
  4959. // ) );
  4960. // die ();
  4961. // }
  4962. function eMailTask() {
  4963. Doo::loadModel ( 'tag' );
  4964. $tag = new tag ();
  4965. Doo::loadModel ( 'district' );
  4966. $district = new district ();
  4967. $tagList = $tag->getAllBySid ( $this->staff [0] ['sid'] );
  4968. $districtList = $district->get_lv ( 1 );
  4969. $data ['tagList'] = $tagList;
  4970. $data ['districtList'] = $districtList;
  4971. $data ['memu'] = "eMailTask";
  4972. $data ['staff'] = $this->staff;
  4973. $data ['mailMemu'] = 'eMailTask';
  4974. $data ['nature'] = $this->nature;
  4975. $this->render ( "/mail_create", $data );
  4976. }
  4977. function eMialCenter() {
  4978. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4979. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 0;
  4980. Doo::loadModel ( 'eMailList' );
  4981. $eMailList = new eMailList ();
  4982. Doo::loadModel ( 'tag' );
  4983. $tag = new tag ();
  4984. Doo::loadModel ( 'staff' );
  4985. $staff = new staff ();
  4986. $dateCondition = "status!=2 and Year(date) =" . $year;
  4987. if (! empty ( $month ))
  4988. $dateCondition = "Year(date) =" . $year . " and Month(date) = " . $month;
  4989. $mailList = $eMailList->find ( array (
  4990. 'where' => $dateCondition,
  4991. 'asc' => 'status',
  4992. 'desc' => 'elid',
  4993. 'asArray' => true
  4994. ) );
  4995. foreach ( $mailList as $key => $value ) {
  4996. $mailList [$key] ['clientName2'] = $mailList [$key] ['clientName3'] = array ();
  4997. $mailList [$key] ['clientName'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName'] ) ), true );
  4998. if (! empty ( $value ['clientName2'] ))
  4999. $mailList [$key] ['clientName2'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName2'] ) ), true );
  5000. if (! empty ( $value ['clientName3'] ))
  5001. $mailList [$key] ['clientName3'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName3'] ) ), true );
  5002. $mailList [$key] ['illegalEmail'] = json_decode ( $value ['illegalEmail'], true );
  5003. $mailList [$key] ['sendEmail'] = json_decode ( $value ['sendEmail'], true );
  5004. $mailList [$key] ['clientCount'] = count ( $mailList [$key] ['clientName'] ) + count ( $mailList [$key] ['clientName2'] ) + count ( $mailList [$key] ['clientName3'] );
  5005. $mailList [$key] ['tag'] = array ();
  5006. $kks = $staff->getOne ( array (
  5007. 'where' => 'username like "' . $value ['staffName'] . '"',
  5008. 'asArray' => true
  5009. ) );
  5010. $mailList [$key] ['category'] = $kks ['category'];
  5011. if (! empty ( $value ['tag'] ))
  5012. $mailList [$key] ['tag'] = $tag->find ( array (
  5013. 'where' => 'tid in ( ' . $value ['tag'] . ') ',
  5014. 'asArray' => true
  5015. ) );
  5016. }
  5017. $dateHtml = "";
  5018. $now = date ( "Y" );
  5019. for($YEARD = 2014; $YEARD <= 2050; $YEARD ++) {
  5020. if ($YEARD <= $now) {
  5021. $dateHtml .= '<option ';
  5022. if ($year == $YEARD)
  5023. $dateHtml .= ' selected ';
  5024. $dateHtml .= ' value="' . $YEARD . '">' . $YEARD . '</option>';
  5025. }
  5026. }
  5027. $monthHtml = '<option value="0">所有月份</option>';
  5028. for($i = 1; $i <= 12; $i ++) {
  5029. $monthHtml .= '<option ';
  5030. if ($i == $month)
  5031. $monthHtml .= ' selected ';
  5032. $monthHtml .= ' value="' . $i . '">' . $i . '</option>';
  5033. }
  5034. $data ['monthHtml'] = $monthHtml;
  5035. $data ['dateHtml'] = $dateHtml;
  5036. $data ['mailList'] = $mailList;
  5037. $data ['memu'] = "eMailTask";
  5038. $data ['staff'] = $this->staff;
  5039. $data ['mailMemu'] = 'eMialCenter';
  5040. $data ['nature'] = $this->nature;
  5041. $this->render ( "/mailCenter", $data );
  5042. }
  5043. function authMail() {
  5044. $elid = isset ( $this->params ['elid'] ) ? $this->params ['elid'] : 0;
  5045. if (! empty ( $elid )) {
  5046. Doo::loadModel ( 'eMailList' );
  5047. $eMailList = new eMailList ();
  5048. $eMailList->examine = 2;
  5049. $eMailList->mark = $this->staff [0] ['username'] . "已同意";
  5050. $eMailList->update ( array (
  5051. 'where' => 'elid=' . $elid,
  5052. 'asArray' => true
  5053. ) );
  5054. }
  5055. return '/eMialCenter';
  5056. }
  5057. function editMailView() {
  5058. $elid = isset ( $this->params ['elid'] ) ? $this->params ['elid'] : 0;
  5059. Doo::loadModel ( 'tag' );
  5060. $tag = new tag ();
  5061. Doo::loadModel ( 'district' );
  5062. $district = new district ();
  5063. Doo::loadModel ( 'eMailList' );
  5064. $eMList = new eMailList ();
  5065. $mail = $eMList->getOne ( array (
  5066. 'where' => 'elid =' . $elid . '',
  5067. 'asArray' => true
  5068. ) );
  5069. if (empty ( $mail ))
  5070. return "/eMailList";
  5071. $mail ['tagList'] = explode ( ",", $mail ['tag'] );
  5072. $tagList = $tag->getAllBySid ( $this->staff [0] ['sid'] );
  5073. $districtList = $district->get_lv ( 1 );
  5074. $tagHtml = '';
  5075. foreach ( $tagList as $key => $value ) {
  5076. $tagHtml .= '<label><span data-original-title="' . $value ['name'] . '" data-toggle="ctooltip" data-placement="right" class="contactsTag tagCol-0' . $value ['colorid'] . '">
  5077. <input type="checkbox" name="tagId[]"';
  5078. foreach ( $mail ['tagList'] as $k => $v ) {
  5079. if ($value ['tid'] == $v) {
  5080. $tagHtml .= ' checked ';
  5081. break;
  5082. }
  5083. }
  5084. $tagHtml .= ' value="' . $value ['tid'] . '"></span></label>';
  5085. }
  5086. $districtHtml = '';
  5087. foreach ( $districtList as $key => $value ) {
  5088. $districtHtml .= '<option value="' . $value ['id'] . '"';
  5089. if ($value ['id'] == $mail ['districtId'])
  5090. $districtHtml .= 'selected';
  5091. $districtHtml .= '>' . $value ['name'] . '</option>';
  5092. }
  5093. $natureHtml = '';
  5094. $natList = explode ( ",", $mail ['nature'] );
  5095. foreach ( $this->nature as $key => $value ) {
  5096. $natureHtml .= '<label><input type="checkbox" name="nature[]" ';
  5097. foreach ( $natList as $k => $v ) {
  5098. if ($value == $v) {
  5099. $natureHtml .= ' checked ';
  5100. break;
  5101. }
  5102. }
  5103. $natureHtml .= 'value="' . $value . '">' . $value . '</label>';
  5104. }
  5105. $data ['natureHtml'] = $natureHtml;
  5106. $data ['districtHtml'] = $districtHtml;
  5107. $data ['tagHtml'] = $tagHtml;
  5108. $data ['mail'] = $mail;
  5109. $data ['tagList'] = $tagList;
  5110. $data ['districtList'] = $districtList;
  5111. $data ['memu'] = "eMailTask";
  5112. $data ['staff'] = $this->staff;
  5113. $data ['mailMemu'] = 'eMailList';
  5114. $data ['nature'] = $this->nature;
  5115. $this->render ( "/mailEdit", $data );
  5116. }
  5117. function editEmail() {
  5118. $title = $this->get_args ( 'title' ) ? $this->get_args ( 'title' ) : "";
  5119. $skin = $this->get_args ( 'skin' ) ? $this->get_args ( 'skin' ) : "";
  5120. $content = isset ( $_POST ['content'] ) ? $_POST ['content'] : "";
  5121. $tagId = $this->get_args ( 'tagId' ) ? $this->get_args ( 'tagId' ) : array ();
  5122. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : array ();
  5123. $natureNULL = $this->get_args ( 'natureNULL' ) ? $this->get_args ( 'natureNULL' ) : "";
  5124. $did = $this->get_args ( 'did' ) ? $this->get_args ( 'did' ) : "";
  5125. $stype = $this->get_args ( 'stype' ) ? $this->get_args ( 'stype' ) : "";
  5126. $elid = $this->get_args ( 'elid' ) ? $this->get_args ( 'elid' ) : "";
  5127. if (! empty ( $title ) && ! empty ( $elid ) && (! empty ( $tagId ) || ! empty ( $did ))) {
  5128. Doo::loadModel ( 'eMailList' );
  5129. $eMailList = new eMailList ();
  5130. $etid = $eMailList->getOne ( array (
  5131. 'select' => 'etid,annexName,annex',
  5132. 'where' => 'elid=' . $elid,
  5133. 'asArray' => true
  5134. ) );
  5135. Doo::loadModel ( 'eMailTemplate' );
  5136. $eMailTemplate = new eMailTemplate ();
  5137. Doo::loadModel ( 'eMailJournal' );
  5138. $eMailJournal = new eMailJournal ();
  5139. if ($natureNULL != 'NULL') {
  5140. if (empty ( $tagId ) && ! empty ( $did ) && empty ( $nature ))
  5141. die ( '请选择性质' );
  5142. }
  5143. // annex
  5144. $annexPath = "";
  5145. $annexEXT = $this->_GetFileEXT ( $_FILES ["annex"] ["name"] );
  5146. $annexName = "";
  5147. if (isset ( $_FILES ['annex'] ['name'] )) {
  5148. 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)) {
  5149. $path = DOO::conf ()->SITE_PATH . "upload/emailAnnex/";
  5150. if (! file_exists ( $path . $_FILES ["annex"] ["name"] )) {
  5151. $fileName = time () . "." . $annexEXT;
  5152. $annexName = $_FILES ['annex'] ['name'];
  5153. $annexPath = $path . $fileName;
  5154. move_uploaded_file ( $_FILES ["annex"] ["tmp_name"], $annexPath );
  5155. $annexPath = $this->webPath . $fileName;
  5156. }
  5157. }
  5158. }
  5159. if (! empty ( $annexPath )) {
  5160. $annexHtml = '<table style="width:100%;margin:10px 0">
  5161. <thead>
  5162. <tr>
  5163. <th align="left" colspan="2" style="background-color:ff6501;color:#fff;font-size:16px;padding:5px">下载附件:</th>
  5164. </tr>
  5165. </thead>
  5166. <tbody>
  5167. <tr>
  5168. <td style="padding:5px"><a href="' . $annexPath . '" target="_blank" style="font-size:16px">' . $annexName . '</a></td>
  5169. <td>&nbsp;</td>
  5170. </tr>
  5171. </tbody>
  5172. </table>';
  5173. } elseif (! empty ( $etid ['annexName'] ) && empty ( $annexPath ))
  5174. $annexHtml = $etid ['annex'];
  5175. $smartcostMail = 'smartcost_mail_1';
  5176. $info = "";
  5177. // html template
  5178. if ($skin == 1) {
  5179. $html = '<div><table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  5180. <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">
  5181. <tbody><tr>
  5182. <td style="background-color:#ff6501;padding:20px 0 25px;" align="center">
  5183. <span style="vertical-align:bottom;font-size:20px;color:#fff;">' . $title . '</span>
  5184. </td></tr><tr><td>
  5185. <table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;border-top:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  5186. <tbody><tr><td style="padding: 0 40px;" align="left">
  5187. <p style="margin-top:40px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
  5188. </td></tr><tr><td style="padding: 0 40px;" align="left">
  5189. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>' . $this->staff [0] ['username'] . '</b>:</p>
  5190. <p style="margin-top:0px;margin-bottom:20px;color:#383838;font-size:16px;line-height:32px;">
  5191. ' . $content . '</p>
  5192. </td></tr>
  5193. <tr><td align="left" style="padding: 0 40px;background:#fff">
  5194. ' . $annexHtml . '
  5195. </td></tr>
  5196. <tr> <td style="padding: 20px 40px;border-top:1px dashed #ddd" align="left">
  5197. <p style="margin-bottom:10px;color:#383838;font-size:16px;line-height:22px;border-left:2px solid #FF6501;padding-left:5px">
  5198. 纵横公路造价软件' . $this->staff [0] ['category'] . '办事处</p>
  5199. <table>
  5200. <tr><th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td></tr>
  5201. <tr><th align="right">联系人:</th><td>' . $this->staff [0] ['username'] . '</td></tr>
  5202. <tr><th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr>
  5203. <tr><th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td></tr>
  5204. <tr><th align="right">邮箱:</th><td>' . $this->staff [0] ['email'] . '</td></tr>
  5205. </table></td></tr></tbody></table></td></tr><tr>
  5206. <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>
  5207. </tr></tbody></table></td></tr></tbody></table></div>';
  5208. $info = '<table><tr><th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td></tr>
  5209. <tr><th align="right">联系人:</th><td>' . $this->staff [0] ['username'] . '</td></tr>
  5210. <tr><th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr>
  5211. <tr><th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td></tr>
  5212. <tr><th align="right">邮箱:</th><td>' . $this->staff [0] ['email'] . '</td></tr></table>';
  5213. } elseif ($skin == 2) {
  5214. $smartcostMail = 'smartcost_mail_2';
  5215. $html = '<table cellspacing="0" cellpadding="0" style="background-color:#e4e4e4; width:100%;"><tbody><tr><td>
  5216. <table align="center" cellspacing="0" cellpadding="0" style="background-color:#f8f8f8; width:640px;margin-bottom:20px">
  5217. <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;">
  5218. <b><span name="titleHtml">' . $title . '</span></b></p></td>
  5219. </tr><tr><td><table align="center" cellspacing="0" cellpadding="0" style="border:1px solid #ddd;"><tbody><tr>
  5220. <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>
  5221. </tr><tr><td align="center" style="background-color:#fff;"><img width="640" height="191" src="http://zonghengvideo.qiniudn.com/hero.jpg"></td>
  5222. </tr><tr><td align="left" style="background-color:#fff;padding:40px;border-bottom:1px solid #ddd;">
  5223. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
  5224. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>' . $this->staff [0] ['username'] . '</b>:</p>
  5225. <p name="contentHtml" style="margin-top:0px;margin-bottom:15px;color:#383838;font-size:16px;line-height:32px;">' . $content . '</p></td>
  5226. </tr>
  5227. <tr><td align="left" style="padding: 0 40px;background:#fff">
  5228. ' . $annexHtml . '
  5229. </td></tr>
  5230. <tr><td style="padding: 10px 0;background:#EEF2F5"><table><tbody><tr>
  5231. <td style="font-size:14pxl;color:#333;padding:0 20px"><b>纵横公路造价软件' . $this->staff [0] ['category'] . '办事处</b><br>' . $this->staff [0] ['username'] . '</td>
  5232. <td><table><tbody><tr style="font-size:12px;color:#666">
  5233. <th align="right">电话:</th><td style="padding:0 20px 0 0">' . $this->staff [0] ['phone'] . '</td>
  5234. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr><tr style="font-size:12px;color:#666">
  5235. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5236. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  5237. </tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr>
  5238. <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>
  5239. </tr></tbody></table></td></tr></tbody> </table>';
  5240. $info = '<table><tbody><tr style="font-size:12px;color:#666">
  5241. <th align="right">电话:</th><td style="padding:0 20px 0 0">' . $this->staff [0] ['phone'] . '</td>
  5242. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr><tr style="font-size:12px;color:#666">
  5243. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5244. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  5245. </tr></tbody></table>';
  5246. } else {
  5247. $smartcostMail = 'smartcost_mail_3';
  5248. $html = '<table cellspacing="0" cellpadding="0" style="background-color:#ECF0E1; width:100%">
  5249. <tbody>
  5250. <tr>
  5251. <td>
  5252. <table align="center" cellspacing="0" cellpadding="0" style="width:698px;margin-bottom:30px;margin-top:30px;">
  5253. <tbody>
  5254. <tr>
  5255. <td>
  5256. <table align="center" cellspacing="0" cellpadding="0" style="border:1px solid #ccc;width:100%;border-top:none">
  5257. <tbody>
  5258. <tr>
  5259. <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;">
  5260. <div style="position:relative;text-align:right">
  5261. <b style="font-size:24px;color:#8A9F98;z-index:999"><span name="titleHtml">' . $title . '</span></b>
  5262. <div style="width:80px;height:80px;position:absolute;top:0;left:0"><img src="http://zonghengvideo.qiniudn.com/zonghenglogo.png"></div>
  5263. </div>
  5264. </td>
  5265. </tr>
  5266. <tr>
  5267. <td align="left" style="background-color:#fff;padding:40px;border-bottom:1px solid #ddd;">
  5268. <p style="margin-top:0px;margin-bottom:10px;color:#666;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
  5269. <p style="margin-top:0px;margin-bottom:10px;color:#666;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>' . $this->staff [0] ['username'] . '</b>:</p>
  5270. <p name="contentHtml" style="margin-top:0px;margin-bottom:15px;color:#666;font-size:16px;line-height:32px;">' . $content . '</p></td>
  5271. </tr>
  5272. <tr><td align="left" style="padding: 0 40px;background:#fff">
  5273. ' . $annexHtml . '
  5274. </td></tr>
  5275. <tr>
  5276. <td style="padding: 10px 0 0;background:#F6F6F6;">
  5277. <table>
  5278. <tbody><tr>
  5279. <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>
  5280. <td>
  5281. <table style="width:100%">
  5282. <tbody><tr style="font-size:12px;color:#496781">
  5283. <th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td>
  5284. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td>
  5285. </tr>
  5286. <tr style="font-size:12px;color:#496781">
  5287. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5288. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  5289. </tr>
  5290. </tbody></table>
  5291. </td>
  5292. </tr>
  5293. </tbody></table>
  5294. </td>
  5295. </tr>
  5296. <tr>
  5297. <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>
  5298. </tr>
  5299. </tbody>
  5300. </table></td>
  5301. </tr>
  5302. </tbody>
  5303. </table></td>
  5304. </tr>
  5305. </tbody>
  5306. </table>';
  5307. $info = '<table><tr style="font-size:12px;color:#496781"><th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td>
  5308. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr><tr style="font-size:12px;color:#496781">
  5309. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5310. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td></tr></table>
  5311. ';
  5312. }
  5313. Doo::loadModel ( 'tag_client' );
  5314. $tagClient = new tag_client ();
  5315. Doo::loadModel ( 'client' );
  5316. $client = new client ();
  5317. Doo::loadModel ( 'company' );
  5318. $company = new company ();
  5319. $eMailTemplate->title = $title;
  5320. $eMailTemplate->skin = $skin;
  5321. $eMailTemplate->content = $content;
  5322. if (! empty ( $tagId ))
  5323. $eMailTemplate->tag = implode ( ",", $tagId );
  5324. $eMailTemplate->staffId = $this->staff [0] ['sid'];
  5325. $eMailTemplate->staffName = $this->staff [0] ['username'];
  5326. $eMailTemplate->status = 0;
  5327. $eMailTemplate->html = $html;
  5328. if (! empty ( $annexPath )) {
  5329. $eMailTemplate->annex = $annexPath;
  5330. $eMailTemplate->annexName = $annexName;
  5331. }
  5332. $etid = $eMailTemplate->update ( array (
  5333. 'where' => 'etid=' . $etid ['etid']
  5334. ) );
  5335. // create email list
  5336. $tagCondition = "";
  5337. $tagArray = array ();
  5338. foreach ( $tagId as $value ) {
  5339. array_push ( $tagArray, " tag like '%" . $value . "%' " );
  5340. }
  5341. if (! empty ( $tagArray ))
  5342. $tagCondition = ' and (' . implode ( " or ", $tagArray ) . ')';
  5343. $clientList = $tagClient->find ( array (
  5344. 'select' => 'client',
  5345. 'where' => 'sid=' . $this->staff [0] ['sid'] . $tagCondition,
  5346. 'asArray' => true
  5347. ) );
  5348. $clientArray = array ();
  5349. foreach ( $clientList as $value ) {
  5350. array_push ( $clientArray, $value ['client'] );
  5351. }
  5352. $clientEmailList = array ();
  5353. if (! empty ( $clientArray ))
  5354. $clientEmailList = $client->find ( array (
  5355. 'select' => 'email,cid,nicename as clientname,companyname',
  5356. 'where' => 'cid in (' . implode ( ",", $clientArray ) . ')',
  5357. 'asArray' => true
  5358. ) );
  5359. //
  5360. if ($stype == 2) {
  5361. // 获取性质相关数据
  5362. $cidList = '';
  5363. if ($natureNULL == '') {
  5364. $nD = array ();
  5365. foreach ( $nature as $key => $value ) {
  5366. array_push ( $nD, ' nature like "' . $value . '"' );
  5367. // $nD=' nature like "'.$value.'"';
  5368. }
  5369. $nD = implode ( ' or ', $nD );
  5370. $companycid = $company->find ( array (
  5371. 'select' => 'cid',
  5372. 'where' => $nD,
  5373. 'asArray' => true
  5374. ) );
  5375. $cidList = array ();
  5376. foreach ( $companycid as $key => $value ) {
  5377. array_push ( $cidList, $value ['cid'] );
  5378. }
  5379. $cidList = implode ( ',', $cidList );
  5380. if (! empty ( $cidList ))
  5381. $cidList = ' and companyid in (' . $cidList . ')';
  5382. else
  5383. $cidList = '';
  5384. }
  5385. // 'select'=>'email,cid,nicename as clientname,companyname,district'
  5386. $clientEmailList = $client->find ( array (
  5387. 'select' => 'email,cid,nicename as clientname,companyname,district',
  5388. 'where' => 'district like "' . $did . ',%" ' . $cidList,
  5389. 'asArray' => true
  5390. ) );
  5391. }
  5392. // ;datediff(curdate(), 'date')>=10
  5393. $eMailJournal->delete ( array (
  5394. 'where' => "datediff(curdate(), date)>=7"
  5395. ) );
  5396. $eMailJournal->delete ( array (
  5397. 'where' => 'DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(date)'
  5398. ) );
  5399. $checkMail = $eMailJournal->find ( array (
  5400. 'where' => 'DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(date)',
  5401. ' groupby' => 'email',
  5402. 'asArray' => true
  5403. ) );
  5404. $emailNameList = $emailArray = $illegalEmail = $sendEmail = array ();
  5405. Doo::db ()->beginTransaction ();
  5406. foreach ( $clientEmailList as $value ) {
  5407. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  5408. if (! empty ( $checkMail )) {
  5409. $falg = true;
  5410. foreach ( $checkMail as $v ) {
  5411. if ($v ['email'] == $value ['email']) {
  5412. $Bdate = strtotime ( $v ['date'] ) + 7 * 24 * 3600;
  5413. if ($Bdate <= time ()) {
  5414. array_push ( $emailArray, $value ['email'] );
  5415. array_push ( $emailNameList, $value );
  5416. $eMailJournal->date = date ( "Y-m-d" );
  5417. $eMailJournal->update ( array (
  5418. 'where' => 'ejid=' . $v ['ejid']
  5419. ) );
  5420. } else {
  5421. array_push ( $sendEmail, $value );
  5422. }
  5423. $falg = false;
  5424. break;
  5425. }
  5426. }
  5427. if ($falg) {
  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 ( $emailArray, $value ['email'] );
  5438. array_push ( $emailNameList, $value );
  5439. $eMailJournal->clientId = $value ['cid'];
  5440. $eMailJournal->status = 1;
  5441. $eMailJournal->email = $value ['email'];
  5442. $eMailJournal->date = date ( "Y-m-d" );
  5443. $eMailJournal->insert ();
  5444. }
  5445. } else {
  5446. array_push ( $illegalEmail, $value );
  5447. }
  5448. }
  5449. Doo::db ()->commit ();
  5450. // echo json_encode($illegalEmail);
  5451. // json_encode(array_slice($illegalEmail,0,100))
  5452. // $kk=gzcompress();
  5453. // $ll=gzuncompress($kk);
  5454. // ."</br>".strlen($kk)."</br>".strlen($ll);die;
  5455. $size = floor ( count ( $emailArray ) / 3 );
  5456. if (! empty ( $emailArray )) {
  5457. if (count ( $emailArray ) < 3) {
  5458. $list = array (
  5459. 0 => $emailArray,
  5460. 1 => array (),
  5461. 2 => array ()
  5462. );
  5463. } else
  5464. $list = array_chunk ( $emailArray, $size );
  5465. } else
  5466. $list = array (
  5467. 0 => array (),
  5468. 1 => array (),
  5469. 2 => array ()
  5470. );
  5471. $emailJson = array ();
  5472. foreach ( $list as $value ) {
  5473. $em = array ();
  5474. foreach ( $value as $v ) {
  5475. array_push ( $em, $v );
  5476. }
  5477. array_push ( $emailJson, $em );
  5478. }
  5479. $size = floor ( count ( $emailNameList ) / 3 );
  5480. if (! empty ( $emailNameList )) {
  5481. if (count ( $emailNameList ) < 3) {
  5482. $list = array (
  5483. 0 => $emailNameList,
  5484. 1 => array (),
  5485. 2 => array ()
  5486. );
  5487. } else
  5488. $list = array_chunk ( $emailNameList, $size );
  5489. } else
  5490. $list = array (
  5491. 0 => array (),
  5492. 1 => array (),
  5493. 2 => array ()
  5494. );
  5495. $emailNameJson = array ();
  5496. foreach ( $list as $value ) {
  5497. $em = array ();
  5498. foreach ( $value as $v ) {
  5499. array_push ( $em, $v );
  5500. }
  5501. array_push ( $emailNameJson, $em );
  5502. }
  5503. //
  5504. $eMailList->date = date ( "Y-m-d" );
  5505. $eMailList->clientEmail = base64_encode ( gzcompress ( json_encode ( $emailJson [0] ) ) );
  5506. $eMailList->clientEmail2 = base64_encode ( gzcompress ( json_encode ( $emailJson [1] ) ) );
  5507. $eMailList->clientEmail3 = base64_encode ( gzcompress ( json_encode ( $emailJson [2] ) ) );
  5508. $eMailList->clientName = base64_encode ( gzcompress ( json_encode ( $emailNameJson [0] ) ) );
  5509. $eMailList->clientName2 = base64_encode ( gzcompress ( json_encode ( $emailNameJson [1] ) ) );
  5510. $eMailList->clientName3 = base64_encode ( gzcompress ( json_encode ( $emailNameJson [2] ) ) );
  5511. $eMailList->illegalEmail = json_encode ( array_slice ( $illegalEmail, 0, 100 ) ); // json_encode($illegalEmail);
  5512. $eMailList->sendEmail = json_encode ( $sendEmail );
  5513. $eMailList->templateName = $smartcostMail;
  5514. $eMailList->eTitle = $title;
  5515. $eMailList->html = $html;
  5516. $eMailList->content = $content;
  5517. $eMailList->info = $info;
  5518. if (! empty ( $annexName )) {
  5519. $eMailList->annex = $annexHtml;
  5520. $eMailList->annexName = $annexName;
  5521. }
  5522. if ($stype == 1) {
  5523. $eMailList->tag = implode ( ",", $tagId );
  5524. $eMailList->districtId = "";
  5525. $eMailList->nature = "";
  5526. }
  5527. if ($stype == 2) {
  5528. $eMailList->districtId = $did;
  5529. $eMailList->nature = implode ( ",", $nature );
  5530. $eMailList->tag = "";
  5531. }
  5532. $eMailList->update ( array (
  5533. 'where' => 'elid=' . $elid
  5534. ) );
  5535. return "/eMailList";
  5536. }
  5537. return "/eMailTask";
  5538. }
  5539. function createEmail() {
  5540. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  5541. $title = $this->get_args ( 'title' ) ? $this->get_args ( 'title' ) : "";
  5542. $skin = $this->get_args ( 'skin' ) ? $this->get_args ( 'skin' ) : "";
  5543. $content = isset ( $_POST ['content'] ) ? $_POST ['content'] : "";
  5544. $tagId = $this->get_args ( 'tagId' ) ? $this->get_args ( 'tagId' ) : array ();
  5545. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : array ();
  5546. $natureNULL = $this->get_args ( 'natureNULL' ) ? $this->get_args ( 'natureNULL' ) : "";
  5547. $did = $this->get_args ( 'did' ) ? $this->get_args ( 'did' ) : "";
  5548. $stype = $this->get_args ( 'stype' ) ? $this->get_args ( 'stype' ) : "";
  5549. if (! empty ( $title ) && (! empty ( $tagId ) || ! empty ( $did ))) {
  5550. Doo::loadModel ( 'eMailTemplate' );
  5551. $eMailTemplate = new eMailTemplate ();
  5552. Doo::loadModel ( 'eMailJournal' );
  5553. $eMailJournal = new eMailJournal ();
  5554. if ($natureNULL != 'NULL') {
  5555. if (empty ( $tagId ) && ! empty ( $did ) && empty ( $nature )) {
  5556. header ( 'Content-Type:text/html;charset=utf-8' );
  5557. die ( '请选择性质' );
  5558. }
  5559. }
  5560. // annex
  5561. $annexPath = "";
  5562. $annexEXT = $this->_GetFileEXT ( $_FILES ["annex"] ["name"] );
  5563. $annexName = "";
  5564. if (isset ( $_FILES ['annex'] ['name'] )) {
  5565. 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)) {
  5566. $path = DOO::conf ()->SITE_PATH . "upload/emailAnnex/";
  5567. if (! file_exists ( $path . $_FILES ["annex"] ["name"] )) {
  5568. $fileName = time () . "." . $annexEXT;
  5569. $annexName = $_FILES ['annex'] ['name'];
  5570. $annexPath = $path . $fileName;
  5571. move_uploaded_file ( $_FILES ["annex"] ["tmp_name"], $annexPath );
  5572. $annexPath = $this->webPath . $fileName;
  5573. }
  5574. }
  5575. }
  5576. $annexHtml = '<table style="width:100%;margin:10px 0">
  5577. <thead>
  5578. <tr>
  5579. <th align="left" colspan="2">下载附件:</th>
  5580. </tr>
  5581. </thead>
  5582. <tbody>
  5583. <tr>
  5584. <td><a href="' . $annexPath . '" target="_blank">' . $annexName . '</a></td>
  5585. <td>&nbsp;</td>
  5586. </tr>
  5587. </tbody>
  5588. </table>';
  5589. $smartcostMail = 'smartcost_mail_1';
  5590. $info = "";
  5591. // html template
  5592. if ($skin == 1) {
  5593. $html = '<div><table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  5594. <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">
  5595. <tbody><tr>
  5596. <td style="background-color:#ff6501;padding:20px 0 25px;" align="center">
  5597. <span style="vertical-align:bottom;font-size:20px;color:#fff;">' . $title . '</span>
  5598. </td></tr><tr><td>
  5599. <table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;border-top:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  5600. <tbody><tr><td style="padding: 0 40px;" align="left">
  5601. <p style="margin-top:40px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;"><b>CLIENTNAME</b></p>
  5602. </td></tr><tr><td style="padding: 0 40px;" align="left">
  5603. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;">您好,我是纵横公路造价软件 <b>' . $this->staff [0] ['username'] . '</b>:</p>
  5604. <p style="margin-top:0px;margin-bottom:20px;color:#383838;font-size:16px;line-height:32px;">
  5605. ' . $content . '</p>
  5606. </td></tr>
  5607. <tr><td align="left" style="padding: 0 40px;background:#fff">
  5608. ' . $annexHtml . '
  5609. </td></tr>
  5610. <tr>
  5611. <td style="padding: 10px 0 0;background:#F6F6F6;">
  5612. <table>
  5613. <tr>
  5614. <td style="font-size:14pxl;color:#666;padding:0 20px"><b>纵横软件公司' . $this->staff [0] ['category'] . '服务中心</b><br>' . $this->staff [0] ['username'] . '<br>
  5615. <a href="[图片]http://www.smartcost.com.cn" style="color:#666;font-size:12px;text-decoration:underline;">[图片]smartcost.com.cn</a></td>
  5616. <td>
  5617. <table>
  5618. <tr style="font-size:12px;color:#666">
  5619. <th align="right">电话:</th><td style="padding:0 20px 0 0">' . $this->staff [0] ['phone'] . '</td>
  5620. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td>
  5621. </tr>
  5622. <tr style="font-size:12px;color:#666">
  5623. <th align="right">Q Q:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5624. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  5625. </tr>
  5626. </table>
  5627. </td>
  5628. </tr>
  5629. </table>
  5630. </td></tr></tbody></table></td></tr><tr>
  5631. <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>
  5632. </tr></tbody></table></td></tr></tbody></table></div>';
  5633. $info = '<table><tr><th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td></tr>
  5634. <tr><th align="right">联系人:</th><td>' . $this->staff [0] ['username'] . '</td></tr>
  5635. <tr><th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr>
  5636. <tr><th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td></tr>
  5637. <tr><th align="right">邮箱:</th><td>' . $this->staff [0] ['email'] . '</td></tr></table>';
  5638. } elseif ($skin == 2) {
  5639. $smartcostMail = 'smartcost_mail_2';
  5640. $html = '<table cellspacing="0" cellpadding="0" style="background-color:#e4e4e4; width:100%;"><tbody><tr><td>
  5641. <table align="center" cellspacing="0" cellpadding="0" style="background-color:#f8f8f8; width:640px;margin-bottom:20px">
  5642. <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;">
  5643. <b><span name="titleHtml">' . $title . '</span></b></p></td>
  5644. </tr><tr><td><table align="center" cellspacing="0" cellpadding="0" style="border:1px solid #ddd;"><tbody><tr>
  5645. <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>
  5646. </tr><tr><td align="center" style="background-color:#fff;"><img width="640" height="191" src="http://zonghengvideo.qiniudn.com/hero.jpg"></td>
  5647. </tr><tr><td align="left" style="background-color:#fff;padding:40px;border-bottom:1px solid #ddd;">
  5648. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;"><b>CLIENTNAME</b></p>
  5649. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;">您好,我是纵横公路造价软件 <b>' . $this->staff [0] ['username'] . '</b>:</p>
  5650. <p name="contentHtml" style="margin-top:0px;margin-bottom:15px;color:#383838;font-size:16px;line-height:32px;">' . $content . '</p></td>
  5651. </tr>
  5652. <tr><td align="left" style="padding: 0 40px;background:#fff">
  5653. ' . $annexHtml . '
  5654. </td></tr>
  5655. <tr>
  5656. <td style="padding: 10px 0;background:#F6F6F6">
  5657. <table>
  5658. <tbody>
  5659. <tr>
  5660. <td style="font-size:14pxl;color:#333;padding:0 20px">
  5661. <b>纵横公路造价软件' . $this->staff [0] ['category'] . '服务中心</b><br>' . $this->staff [0] ['username'] . '</td>
  5662. <td>
  5663. <table>
  5664. <tbody>
  5665. <tr style="font-size:12px;color:#666">
  5666. <th align="right">电话:</th><td style="padding:0 20px 0 0">' . $this->staff [0] ['phone'] . '</td>
  5667. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr><tr style="font-size:12px;color:#666">
  5668. <th align="right">Q Q:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5669. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  5670. </tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr>
  5671. <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>
  5672. </tr></tbody></table></td></tr></tbody> </table>';
  5673. $info = '<table><tbody><tr style="font-size:12px;color:#666">
  5674. <th align="right">电话:</th><td style="padding:0 20px 0 0">' . $this->staff [0] ['phone'] . '</td>
  5675. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr><tr style="font-size:12px;color:#666">
  5676. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5677. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  5678. </tr></tbody></table>';
  5679. } else {
  5680. $smartcostMail = 'smartcost_mail_3';
  5681. $html = '<table cellspacing="0" cellpadding="0" style="background-color:#ECF0E1; width:100%">
  5682. <tbody>
  5683. <tr>
  5684. <td>
  5685. <table align="center" cellspacing="0" cellpadding="0" style="width:698px;margin-bottom:30px;margin-top:30px;">
  5686. <tbody>
  5687. <tr>
  5688. <td>
  5689. <table align="center" cellspacing="0" cellpadding="0" style="border:1px solid #ccc;width:100%;border-top:none">
  5690. <tbody>
  5691. <tr>
  5692. <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;">
  5693. <div style="position:relative;text-align:right">
  5694. <b style="font-size:24px;color:#8A9F98;z-index:999"><span name="titleHtml">' . $title . '</span></b>
  5695. <div style="width:80px;height:80px;position:absolute;top:0;left:0"><img src="http://zonghengvideo.qiniudn.com/zonghenglogo.png"></div>
  5696. </div>
  5697. </td>
  5698. </tr>
  5699. <tr>
  5700. <td align="left" style="background-color:#fff;padding:40px;border-bottom:1px solid #ddd;">
  5701. <p style="margin-top:0px;margin-bottom:10px;color:#666;font-size:16px;line-height:32px;"><b>CLIENTNAME</b></p>
  5702. <p style="margin-top:0px;margin-bottom:10px;color:#666;font-size:16px;line-height:32px;">您好,我是纵横公路造价软件 <b>' . $this->staff [0] ['username'] . '</b>:</p>
  5703. <p name="contentHtml" style="margin-top:0px;margin-bottom:15px;color:#666;font-size:16px;line-height:32px;">' . $content . '</p></td>
  5704. </tr>
  5705. <tr><td align="left" style="padding: 0 40px;background:#fff">
  5706. ' . $annexHtml . '
  5707. </td></tr>
  5708. <tr>
  5709. <td style="padding: 10px 0 0;background:#F6F6F6;">
  5710. <table>
  5711. <tbody><tr>
  5712. <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>
  5713. <td>
  5714. <table style="width:100%">
  5715. <tbody><tr style="font-size:12px;color:#496781">
  5716. <th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td>
  5717. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td>
  5718. </tr>
  5719. <tr style="font-size:12px;color:#496781">
  5720. <th align="right">Q Q:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5721. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  5722. </tr>
  5723. </tbody></table>
  5724. </td>
  5725. </tr>
  5726. </tbody></table>
  5727. </td>
  5728. </tr>
  5729. <tr>
  5730. <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>
  5731. </tr>
  5732. </tbody>
  5733. </table></td>
  5734. </tr>
  5735. </tbody>
  5736. </table></td>
  5737. </tr>
  5738. </tbody>
  5739. </table>';
  5740. $info = '<table><tr style="font-size:12px;color:#496781"><th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td>
  5741. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr><tr style="font-size:12px;color:#496781">
  5742. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5743. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td></tr></table>
  5744. ';
  5745. }
  5746. $eMailTemplate->title = $title;
  5747. $eMailTemplate->skin = $skin;
  5748. $eMailTemplate->content = $content;
  5749. if (! empty ( $tagId ))
  5750. $eMailTemplate->tag = implode ( ",", $tagId );
  5751. $eMailTemplate->staffId = $this->staff [0] ['sid'];
  5752. $eMailTemplate->staffName = $this->staff [0] ['username'];
  5753. $eMailTemplate->status = 0;
  5754. $eMailTemplate->html = $html;
  5755. $eMailTemplate->annex = $annexPath;
  5756. $eMailTemplate->annexName = $annexName;
  5757. $etid = $eMailTemplate->insert ();
  5758. // create email list
  5759. Doo::loadModel ( 'tag_client' );
  5760. $tagClient = new tag_client ();
  5761. Doo::loadModel ( 'client' );
  5762. $client = new client ();
  5763. Doo::loadModel ( 'eMailList' );
  5764. $eMailList = new eMailList ();
  5765. Doo::loadModel ( 'company' );
  5766. $company = new company ();
  5767. $tagCondition = "";
  5768. $tagArray = array ();
  5769. foreach ( $tagId as $value ) {
  5770. array_push ( $tagArray, " tag like '%" . $value . "%' " );
  5771. }
  5772. if (! empty ( $tagArray ))
  5773. $tagCondition = ' and (' . implode ( " or ", $tagArray ) . ')';
  5774. $clientList = $tagClient->find ( array (
  5775. 'select' => 'client',
  5776. 'where' => 'sid=' . $this->staff [0] ['sid'] . $tagCondition,
  5777. 'asArray' => true
  5778. ) );
  5779. $clientArray = array ();
  5780. foreach ( $clientList as $value ) {
  5781. array_push ( $clientArray, $value ['client'] );
  5782. }
  5783. $clientEmailList = array ();
  5784. if (! empty ( $clientArray ))
  5785. $clientEmailList = $client->find ( array (
  5786. 'select' => 'email,cid,nicename as clientname,companyname',
  5787. 'where' => 'cid in (' . implode ( ",", $clientArray ) . ')',
  5788. 'asArray' => true
  5789. ) );
  5790. //
  5791. if ($stype == 2) {
  5792. // 获取性质相关数据
  5793. $cidList = '';
  5794. if ($natureNULL == '') {
  5795. $nD = array ();
  5796. foreach ( $nature as $key => $value ) {
  5797. array_push ( $nD, ' nature like "' . $value . '"' );
  5798. // $nD=' nature like "'.$value.'"';
  5799. }
  5800. $nD = implode ( ' or ', $nD );
  5801. $companycid = $company->find ( array (
  5802. 'select' => 'cid',
  5803. 'where' => $nD,
  5804. 'asArray' => true
  5805. ) );
  5806. $cidList = array ();
  5807. foreach ( $companycid as $key => $value ) {
  5808. array_push ( $cidList, $value ['cid'] );
  5809. }
  5810. $cidList = implode ( ',', $cidList );
  5811. if (! empty ( $cidList ))
  5812. $cidList = ' and companyid in (' . $cidList . ')';
  5813. else
  5814. $cidList = '';
  5815. }
  5816. // 'select'=>'email,cid,nicename as clientname,companyname,district'
  5817. $clientEmailList = $client->find ( array (
  5818. 'select' => 'email,cid,nicename as clientname,companyname,district',
  5819. 'where' => 'district like "' . $did . ',%" ' . $cidList,
  5820. 'asArray' => true
  5821. ) );
  5822. }
  5823. // ;datediff(curdate(), 'date')>=10
  5824. $eMailJournal->delete ( array (
  5825. 'where' => "datediff(curdate(), date)>=7"
  5826. ) );
  5827. $checkMail = $eMailJournal->find ( array (
  5828. 'where' => 'DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(date)',
  5829. ' groupby' => 'email',
  5830. 'asArray' => true
  5831. ) );
  5832. $emailNameList = $emailArray = $illegalEmail = $sendEmail = array ();
  5833. Doo::db ()->beginTransaction ();
  5834. foreach ( $clientEmailList as $value ) {
  5835. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  5836. if (! empty ( $checkMail )) {
  5837. $falg = true;
  5838. foreach ( $checkMail as $v ) {
  5839. if ($v ['email'] == $value ['email']) {
  5840. $Bdate = strtotime ( $v ['date'] ) + 7 * 24 * 3600;
  5841. if ($Bdate <= time ()) {
  5842. array_push ( $emailArray, $value ['email'] );
  5843. array_push ( $emailNameList, $value );
  5844. $eMailJournal->date = date ( "Y-m-d" );
  5845. $eMailJournal->update ( array (
  5846. 'where' => 'ejid=' . $v ['ejid']
  5847. ) );
  5848. } else {
  5849. array_push ( $sendEmail, $value );
  5850. }
  5851. $falg = false;
  5852. break;
  5853. }
  5854. }
  5855. if ($falg) {
  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 ( $emailArray, $value ['email'] );
  5866. array_push ( $emailNameList, $value );
  5867. $eMailJournal->clientId = $value ['cid'];
  5868. $eMailJournal->status = 1;
  5869. $eMailJournal->email = $value ['email'];
  5870. $eMailJournal->date = date ( "Y-m-d" );
  5871. // $eMailJournal->insert();
  5872. }
  5873. } else {
  5874. array_push ( $illegalEmail, $value );
  5875. }
  5876. }
  5877. Doo::db ()->commit ();
  5878. // echo json_encode($illegalEmail);
  5879. // json_encode(array_slice($illegalEmail,0,100))
  5880. // $kk=gzcompress();
  5881. // $ll=gzuncompress($kk);
  5882. // ."</br>".strlen($kk)."</br>".strlen($ll);die;
  5883. $size = floor ( count ( $emailArray ) / 3 );
  5884. if (! empty ( $emailArray )) {
  5885. if (count ( $emailArray ) < 3) {
  5886. $list = array (
  5887. 0 => $emailArray,
  5888. 1 => array (),
  5889. 2 => array ()
  5890. );
  5891. } else
  5892. $list = array_chunk ( $emailArray, $size );
  5893. } else
  5894. $list = array (
  5895. 0 => array (),
  5896. 1 => array (),
  5897. 2 => array ()
  5898. );
  5899. $emailJson = array ();
  5900. foreach ( $list as $value ) {
  5901. $em = array ();
  5902. foreach ( $value as $v ) {
  5903. array_push ( $em, $v );
  5904. }
  5905. array_push ( $emailJson, $em );
  5906. }
  5907. $size = floor ( count ( $emailNameList ) / 3 );
  5908. if (! empty ( $emailNameList )) {
  5909. if (count ( $emailNameList ) < 3) {
  5910. $list = array (
  5911. 0 => $emailNameList,
  5912. 1 => array (),
  5913. 2 => array ()
  5914. );
  5915. } else
  5916. $list = array_chunk ( $emailNameList, $size );
  5917. } else
  5918. $list = array (
  5919. 0 => array (),
  5920. 1 => array (),
  5921. 2 => array ()
  5922. );
  5923. $emailNameJson = array ();
  5924. foreach ( $list as $value ) {
  5925. $em = array ();
  5926. foreach ( $value as $v ) {
  5927. array_push ( $em, $v );
  5928. }
  5929. array_push ( $emailNameJson, $em );
  5930. }
  5931. //
  5932. $eMailList->date = date ( "Y-m-d" );
  5933. $eMailList->clientEmail = base64_encode ( gzcompress ( json_encode ( $emailJson [0] ) ) );
  5934. $eMailList->clientEmail2 = base64_encode ( gzcompress ( json_encode ( $emailJson [1] ) ) );
  5935. $eMailList->clientEmail3 = base64_encode ( gzcompress ( json_encode ( $emailJson [2] ) ) );
  5936. $eMailList->clientName = base64_encode ( gzcompress ( json_encode ( $emailNameJson [0] ) ) );
  5937. $eMailList->clientName2 = base64_encode ( gzcompress ( json_encode ( $emailNameJson [1] ) ) );
  5938. $eMailList->clientName3 = base64_encode ( gzcompress ( json_encode ( $emailNameJson [2] ) ) );
  5939. $eMailList->illegalEmail = json_encode ( array_slice ( $illegalEmail, 0, 100 ) ); // json_encode($illegalEmail);
  5940. $eMailList->sendEmail = json_encode ( $sendEmail );
  5941. $eMailList->etid = $etid;
  5942. $eMailList->templateName = $smartcostMail;
  5943. $eMailList->eTitle = $title;
  5944. $eMailList->html = $html;
  5945. $eMailList->content = $content;
  5946. $eMailList->info = $info;
  5947. if (! empty ( $annexName ))
  5948. $eMailList->annex = $annexHtml;
  5949. $eMailList->annexName = $annexName;
  5950. $eMailList->staffId = $this->staff [0] ['sid'];
  5951. $eMailList->staffName = $this->staff [0] ['username'];
  5952. if ($stype == 1)
  5953. $eMailList->tag = implode ( ",", $tagId );
  5954. if ($stype == 2) {
  5955. $eMailList->districtId = $did;
  5956. $eMailList->nature = implode ( ",", $nature );
  5957. }
  5958. $eMailList->insert ();
  5959. // 创建邮件地址
  5960. // 'http://sendcloud.sohu.com/webapi/list_member.add.json';
  5961. // print_r($emailJson);
  5962. // die;
  5963. return "/eMailList";
  5964. }
  5965. return "/eMailTask";
  5966. }
  5967. function eMailList() {
  5968. Doo::loadModel ( 'eMailList' );
  5969. $eMailList = new eMailList ();
  5970. Doo::loadModel ( 'tag' );
  5971. $tag = new tag ();
  5972. $mailList = $eMailList->find ( array (
  5973. 'where' => 'staffId=' . $this->staff [0] ['sid'],
  5974. 'desc' => 'elid',
  5975. 'asArray' => true
  5976. ) );
  5977. foreach ( $mailList as $key => $value ) {
  5978. $mailList [$key] ['clientName2'] = $mailList [$key] ['clientName3'] = array ();
  5979. $mailList [$key] ['clientName'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName'] ) ), true );
  5980. if (! empty ( $value ['clientName2'] ))
  5981. $mailList [$key] ['clientName2'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName2'] ) ), true );
  5982. if (! empty ( $value ['clientName3'] ))
  5983. $mailList [$key] ['clientName3'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName3'] ) ), true );
  5984. $mailList [$key] ['illegalEmail'] = json_decode ( $value ['illegalEmail'], true );
  5985. $mailList [$key] ['sendEmail'] = json_decode ( $value ['sendEmail'], true );
  5986. $mailList [$key] ['clientCount'] = count ( $mailList [$key] ['clientName'] ) + count ( $mailList [$key] ['clientName2'] ) + count ( $mailList [$key] ['clientName3'] );
  5987. $mailList [$key] ['tag'] = array ();
  5988. if (! empty ( $value ['tag'] ))
  5989. $mailList [$key] ['tag'] = $tag->find ( array (
  5990. 'where' => 'tid in ( ' . $value ['tag'] . ') ',
  5991. 'asArray' => true
  5992. ) );
  5993. }
  5994. $data ['mailList'] = $mailList;
  5995. $data ['memu'] = "eMailTask";
  5996. $data ['staff'] = $this->staff;
  5997. $data ['mailMemu'] = 'eMailList';
  5998. $this->render ( "/mail_list", $data );
  5999. }
  6000. function showEmailContent() {
  6001. $elid = isset ( $this->params ['elid'] ) ? $this->params ['elid'] : 0;
  6002. Doo::loadModel ( 'eMailList' );
  6003. $eMList = new eMailList ();
  6004. $isSend = $eMList->getOne ( array (
  6005. 'where' => 'elid =' . $elid . '',
  6006. 'asArray' => true
  6007. ) );
  6008. echo htmlspecialchars ( $isSend ['content'] );
  6009. }
  6010. function postEmail() {
  6011. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  6012. $elid = isset ( $this->params ['elid'] ) ? $this->params ['elid'] : 0;
  6013. $send = isset ( $this->params ['send'] ) ? $this->params ['send'] : 0;
  6014. Doo::loadModel ( 'eMailList' );
  6015. $eMList = new eMailList ();
  6016. if (! empty ( $elid )) {
  6017. $isSend = $eMList->getOne ( array (
  6018. 'select' => 'send' . $send,
  6019. 'where' => 'elid =' . $elid . ' and status=0 and send' . $send . '=1',
  6020. 'asArray' => true
  6021. ) );
  6022. if (! empty ( $isSend ))
  6023. die ( '这批邮件已经发送' );
  6024. if ($send == 1)
  6025. $send = '';
  6026. $eMailList = $eMList->getOne ( array (
  6027. 'select' => 'eTitle,staffName,clientName' . $send . ' as clientName,clientEmail' . $send . ' as clientEmail,annex,info,content,templateName',
  6028. 'where' => 'elid =' . $elid . ' and status=0',
  6029. 'asArray' => true
  6030. ) );
  6031. if ($send == "")
  6032. $send = 1;
  6033. $sql = "update `CLD_eMailList` set send" . $send . "='1' where elid = '" . $elid . "'";
  6034. Doo::db ()->query ( $sql );
  6035. $isSend = $eMList->getOne ( array (
  6036. 'where' => 'elid =' . $elid . ' and status=0 and send1=1 and send2=1 and send3=1',
  6037. 'asArray' => true
  6038. ) );
  6039. if (! empty ( $isSend )) {
  6040. $sql = "update `CLD_eMailList` set status='2' where elid = '" . $elid . "'";
  6041. Doo::db ()->query ( $sql );
  6042. }
  6043. $toFormatMail = array ();
  6044. $sub = array ();
  6045. // file_put_contents("test.txt", "This is another something.<br/>", FILE_APPEND);
  6046. // sleep(4);
  6047. // die;
  6048. $toMail = json_decode ( gzuncompress ( base64_decode ( $eMailList ['clientEmail'] ) ), true );
  6049. // $toMailCount=count($toMail);
  6050. $subMail = json_decode ( gzuncompress ( base64_decode ( $eMailList ['clientName'] ) ), true );
  6051. $chunkMail = array_chunk ( $toMail, 80 );
  6052. $chunkSubMail = array_chunk ( $subMail, 80 );
  6053. $vii = 0;
  6054. foreach ( $chunkMail as $key => $value ) {
  6055. $l = $s = $c = $i = $cate = $con = $annex = array ();
  6056. $toFormatMail ['to'] = $value;
  6057. $cn = $chunkSubMail [$key];
  6058. foreach ( $cn as $v ) {
  6059. array_push ( $l, $eMailList ['eTitle'] );
  6060. array_push ( $s, $eMailList ['staffName'] );
  6061. array_push ( $c, $v ['clientname'] );
  6062. array_push ( $annex, $eMailList ['annex'] );
  6063. array_push ( $i, $eMailList ['info'] );
  6064. // array_push($con, $eMailList['content']);
  6065. array_push ( $cate, $this->staff [0] ['category'] );
  6066. }
  6067. $sub ['%eTitle%'] = $l;
  6068. $sub ['%staffName%'] = $s;
  6069. $sub ['%clientName%'] = $c;
  6070. $sub ['%category%'] = $cate;
  6071. $sub ['%info%'] = $i;
  6072. // $sub['%content%']=$con;
  6073. $sub ['%annex%'] = $annex;
  6074. $toFormatMail ['sub'] = $sub;
  6075. $url = 'http://sendcloud.sohu.com/webapi/mail.send_template.xml';
  6076. $param = array (
  6077. 'api_user' => 'cldmail',
  6078. 'api_key' => 'cDO1GjtY1seH',
  6079. 'template_invoke_name' => $eMailList ['templateName'],
  6080. 'from' => $this->staff [0] ['email'],
  6081. 'fromname' => '纵横' . $eMailList ['staffName'],
  6082. 'subject' => $eMailList ['eTitle'],
  6083. 'substitution_vars' => json_encode ( $toFormatMail )
  6084. );
  6085. $post_data = http_build_query ( $param );
  6086. $ch = curl_init ();
  6087. curl_setopt ( $ch, CURLOPT_POST, 1 );
  6088. curl_setopt ( $ch, CURLOPT_URL, $url );
  6089. curl_setopt ( $ch, CURLOPT_HEADER, false ); // 设定是否输出页面内容
  6090. curl_setopt ( $ch, CURLOPT_NOBODY, false );
  6091. curl_setopt ( $ch, CURLOPT_POSTFIELDS, $post_data );
  6092. $result = curl_exec ( $ch );
  6093. curl_close ( $ch );
  6094. /*
  6095. * if($result=='success'){ $eM=new eMailList(); $eM->status='2'; $eM->update(array('where'=>'elid=?','param'=>array($elid))); }
  6096. */
  6097. }
  6098. // die;
  6099. return '/eMailList';
  6100. }
  6101. }
  6102. function a() {
  6103. $substitution_vars = $this->get_args ( 'substitution_vars' );
  6104. file_put_contents ( DOO::conf ()->SITE_PATH . 'upload/' . "_" . time () . "_" . rand ( 100, 999 ) . ".log", $substitution_vars );
  6105. }
  6106. function deleteEmail() {
  6107. $elid = isset ( $this->params ['elid'] ) ? $this->params ['elid'] : 0;
  6108. if (! empty ( $elid )) {
  6109. $sql = "DELETE FROM `CLD_eMailList` where elid = '" . $elid . "'";
  6110. Doo::db ()->query ( $sql );
  6111. return '/eMailList';
  6112. }
  6113. }
  6114. /**
  6115. * 发送post请求
  6116. * @param string $url 请求地址
  6117. * @param array $post_data post键值对数据
  6118. * @return string
  6119. */
  6120. function sendPost($url, $post_data) {
  6121. $postdata = http_build_query ( $post_data );
  6122. // X-Amzn-Authorization: AWS3 AWSAccessKeyId=AKIAIDSE5VYNX5ERJHXQ,Signature=lBP67vCvGlDMBQ=dofZxg8E8SUEXAMPLE,Algorithm=HmacSHA256,SignedHeaders=qG1BdSh9QyYPlWLnjqvjDXjyPdFjl7fUSkfs0Hk2
  6123. $options = array (
  6124. 'http' => array (
  6125. 'method' => 'POST',
  6126. 'header' => '
  6127. Content-Type: application/x-www-form-urlencoded
  6128. ',
  6129. 'content' => $postdata,
  6130. 'timeout' => 15 * 60
  6131. )
  6132. ); // 超时时间(单位:s)
  6133. $context = stream_context_create ( $options );
  6134. $result = file_get_contents ( $url, false, $context );
  6135. return $result;
  6136. }
  6137. function avatar() {
  6138. $result = array ();
  6139. $result ['success'] = false;
  6140. $successNum = 0;
  6141. // 定义一个变量用以储存当前头像的序号
  6142. $avatarNumber = 1;
  6143. $i = 0;
  6144. $msg = '';
  6145. // 上传目录
  6146. $dir = DOO::conf ()->SITE_PATH . "global/avatar";
  6147. // 遍历所有文件域
  6148. while ( list ( $key, $val ) = each ( $_FILES ) ) {
  6149. if ($_FILES [$key] ['error'] > 0)
  6150. $msg .= $_FILES [$key] ['error'];
  6151. else {
  6152. $fileName = 'avatar_' . $this->staff [0] ['sid'];
  6153. // 原始图片(file 域的名称:__source,如果客户端定义可以上传的话,可在此处理)。
  6154. if ($key == '__source') { // 当前头像基于原图的初始化参数,用于修改头像时保证界面的视图跟保存头像时一致。帮助提升用户体验度。修改头像时设置默认加载的原图的url为此图片的url+该参数即可。
  6155. $initParams = $_POST ["__initParams"];
  6156. $virtualPath = $dir . "/" . $fileName . "_" . $avatarNumber . ".jpg";
  6157. $result ['sourceUrl'] = '/' . $virtualPath . $initParams;
  6158. move_uploaded_file ( $_FILES [$key] ["tmp_name"], $virtualPath );
  6159. $successNum ++;
  6160. } else if (strpos ( $key, '__avatar' ) === 0) { // 头像图片(file 域的名称:__avatar1,2,3...)。
  6161. $virtualPath = $dir . "/" . $fileName . "_" . $avatarNumber . ".jpg";
  6162. $result ['avatarUrls'] [$i] = '/' . $virtualPath;
  6163. move_uploaded_file ( $_FILES [$key] ["tmp_name"], $virtualPath );
  6164. $avatarNumber ++;
  6165. $successNum ++;
  6166. $i ++;
  6167. }
  6168. }
  6169. }
  6170. $result ['msg'] = $msg;
  6171. if ($successNum > 0)
  6172. $result ['success'] = true;
  6173. // 返回图片的保存结果(返回内容为json字符串)
  6174. Doo::loadModel ( 'staff' );
  6175. $staff = new staff ();
  6176. $staff->sid = $this->staff [0] ['sid'];
  6177. $staff->avatar = "/global/avatar/" . $fileName;
  6178. $staff->update ();
  6179. echo json_encode ( $result );
  6180. }
  6181. function lockUpload() {
  6182. // move_uploaded_file($_FILES['Filedata']['tmp_name'], "/upload/".$_FILES['Filedata']['name']);
  6183. if (isset ( $_FILES ['Filedata'] ['name'] )) {
  6184. $file = $_FILES ['Filedata'] ['tmp_name'];
  6185. $error = false;
  6186. if (! is_uploaded_file ( $file )) {
  6187. $error = '400 Bad Request';
  6188. }
  6189. if ($error) {
  6190. header ( 'HTTP/1.0 ' . $error );
  6191. die ( 'Error ' . $error );
  6192. } else {
  6193. include (DOO::conf ()->SITE_PATH . 'protected/plugin/io.han.php');
  6194. $this->IoHandler = new IoHandler ();
  6195. $pics = explode ( '.', $_FILES ['Filedata'] ['name'] );
  6196. // $filedir=$_POST['time'];
  6197. // 调用定义物理路径
  6198. $t = DOO::conf ()->SITE_PATH . "upload/";
  6199. $this->IoHandler->MakeDir ( $t );
  6200. $filename = $this->_GetFileEXT ( $_FILES ['Filedata'] ['name'] );
  6201. if ($filename != 'xlsx')
  6202. return "";
  6203. // $upload_dir = $t."/".time().rand(10,100).".".$filename;
  6204. $upload_file = iconv ( "UTF-8", "GB2312", $_FILES ["Filedata"] ["name"] );
  6205. $upload_dir = $t . "/" . $upload_file;
  6206. $k = move_uploaded_file ( $file, $upload_dir );
  6207. if ($k) {
  6208. // "series/".$filedir."/".
  6209. $m = round ( $_FILES ['Filedata'] ['size'] / 1024 / 1024, 2 );
  6210. echo $pics [0] . "." . $filename . "#" . $m . "#" . $_FILES ['Filedata'] ['size'];
  6211. }
  6212. }
  6213. }
  6214. }
  6215. function getAuthentication() {
  6216. }
  6217. function loadCVS() {
  6218. Doo::loadModel ( 'longle' );
  6219. $longle = new longle ();
  6220. $list = $longle->find ( array (
  6221. 'select' => 'key_num',
  6222. 'asArray' => TRUE
  6223. ) );
  6224. $file = fopen ( DOO::conf ()->SITE_PATH . "upload/key2.csv", 'r' );
  6225. while ( $data = fgetcsv ( $file ) ) {
  6226. $goods_list [$data [0]] = $data [1];
  6227. }
  6228. fclose ( $file );
  6229. $sqlArray = array ();
  6230. $sql = 'UPDATE CLD_longle SET SerialNumber = CASE key_num ';
  6231. foreach ( $list as $key => $value ) {
  6232. if (array_key_exists ( $value ['key_num'], $goods_list )) {
  6233. // echo $value['key_num'].'-'.$goods_list[$value['key_num']].'<br/>';
  6234. // $longle->SerialNumber=$goods_list[$value['key_num']];
  6235. // $longle->update(array('where'=>'key_num="'.$value['key_num'].'"'));
  6236. $sql .= ' WHEN "' . $value ['key_num'] . '" THEN "' . $goods_list [$value ['key_num']] . '" ';
  6237. array_push ( $sqlArray, '"' . $value ['key_num'] . '"' );
  6238. unset ( $goods_list [$value ['key_num']] );
  6239. }
  6240. }
  6241. $sql .= 'END WHERE key_num IN (' . implode ( ',', $sqlArray ) . ')';
  6242. echo $sql . '<br/>--------------------------------<br/>';
  6243. foreach ( $goods_list as $key => $value ) {
  6244. echo $key . ',' . $value . '<br/>';
  6245. }
  6246. }
  6247. private function getRandChar($length) {
  6248. $str = null;
  6249. $strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
  6250. $max = strlen ( $strPol ) - 1;
  6251. for($i = 0; $i < $length; $i ++) {
  6252. $str .= $strPol [rand ( 0, $max )]; // rand($min,$max)生成介于min和max两个数之间的一个随机整数
  6253. }
  6254. return $str;
  6255. }
  6256. // private function getReceiptCount(){
  6257. // $status=2;
  6258. // $year=date('Y');
  6259. // Doo::loadModel('receipt');
  6260. // $receipt=new receipt();
  6261. // $dateCondition=" and Year(date) =".$year;
  6262. // $approvalCondition=' and nowStaff like "%'.$this->staff[0]['sid'].'%" ';
  6263. // $receiptList=$receipt->find(array('where'=>' status='.$status.$dateCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  6264. // return count($receiptList);
  6265. // }
  6266. // private function getExeCount(){
  6267. // Doo::loadModel('receipt');
  6268. // $receipt=new receipt();
  6269. // $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));
  6270. // return count($receiptList);
  6271. // }
  6272. /**
  6273. * 格式化excel文件为数组
  6274. * @param unknown_type $file_url
  6275. * @param unknown_type $mcid
  6276. */
  6277. function _format_excel_to_array($file_url = "") {
  6278. if (! file_exists ( $file_url ))
  6279. return array ();
  6280. Doo::loadClass ( 'PHPExcel' );
  6281. $PHPExcel = new PHPExcel ();
  6282. $PHPReader = new PHPExcel_Reader_Excel2007 ();
  6283. if (! $PHPReader->canRead ( $file_url )) {
  6284. $PHPReader = new PHPExcel_Reader_Excel5 ();
  6285. if (! $PHPReader->canRead ( $file_url )) {
  6286. echo 'no Excel';
  6287. return;
  6288. }
  6289. }
  6290. $PHPExcel = $PHPReader->load ( $file_url );
  6291. /**
  6292. * 读取excel文件中的第一个工作表
  6293. */
  6294. $currentSheet = $PHPExcel->getSheet ( 0 );
  6295. /**
  6296. * 取得最大的列号
  6297. */
  6298. $allColumn = $currentSheet->getHighestColumn ();
  6299. /**
  6300. * 取得一共有多少行
  6301. */
  6302. $allRow = $currentSheet->getHighestRow ();
  6303. $excel_array = array ();
  6304. for($currentRow = 2; $currentRow <= $allRow; $currentRow ++) {
  6305. $excel_column = array ();
  6306. // 后期改进
  6307. if ($allColumn == 'AM')
  6308. $allColumn = 'Z';
  6309. /**
  6310. * 从第A列开始输出
  6311. */
  6312. for($currentColumn = 'A'; $currentColumn <= $allColumn; $currentColumn ++) {
  6313. $val = $currentSheet->getCellByColumnAndRow ( ord ( $currentColumn ) - 65, $currentRow )->getValue ();
  6314. /**
  6315. * ord()将字符转为十进制数 iconv ( 'utf-8', 'gb2312',
  6316. */
  6317. $val = "'" . addslashes ( $val ) . "'";
  6318. if ($currentColumn == 'A')
  6319. $excel_column ['key_num'] = $val;
  6320. elseif ($currentColumn == 'C')
  6321. $excel_column ['product'] = $val;
  6322. elseif ($currentColumn == 'D') {
  6323. $val = str_replace ( "'", "", $val );
  6324. $excel_column ['make_day'] = $this->excelTime ( $val );
  6325. } elseif ($currentColumn == 'E') {
  6326. $val = str_replace ( "'", "", $val );
  6327. $excel_column ['alloted_time'] = $this->excelTime ( $val );
  6328. } elseif ($currentColumn == 'F') {
  6329. $val = str_replace ( "'", "", $val );
  6330. $excel_column ['version'] = $val;
  6331. } elseif ($currentColumn == 'B') {
  6332. $val = str_replace ( "'", "", $val );
  6333. $excel_column ['SerialNumber'] = $val;
  6334. }
  6335. }
  6336. array_push ( $excel_array, $excel_column );
  6337. }
  6338. return $excel_array;
  6339. }
  6340. function excelTime($date, $time = false) {
  6341. if (function_exists ( 'GregorianToJD' )) {
  6342. if (is_numeric ( $date )) {
  6343. $jd = GregorianToJD ( 1, 1, 1970 );
  6344. $gregorian = JDToGregorian ( $jd + intval ( $date ) - 25569 );
  6345. $date = explode ( '/', $gregorian );
  6346. $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" : '');
  6347. return $date_str;
  6348. }
  6349. } else {
  6350. $date = $date > 25568 ? $date + 1 : 25569;
  6351. /* There was a bug if Converting date before 1-1-1970 (tstamp 0) */
  6352. $ofs = (70 * 365 + 17 + 2) * 86400;
  6353. $date = date ( "Y-m-d", ($date * 86400) - $ofs ) . ($time ? " 00:00:00" : '');
  6354. }
  6355. return $date;
  6356. }
  6357. function _GetFileEXT($filename) {
  6358. $pics = explode ( '.', $filename );
  6359. $num = count ( $pics );
  6360. return $pics [$num - 1];
  6361. }
  6362. /**
  6363. * 获取get或者POST值
  6364. * @param string $name 属性名称
  6365. * @return fixed 值
  6366. */
  6367. function get_args($name) {
  6368. if (isset ( $_GET [$name] )) {
  6369. if (is_array ( $_GET [$name] ))
  6370. return $_GET [$name];
  6371. else {
  6372. return addslashes ( $_GET [$name] );
  6373. }
  6374. } elseif (isset ( $_POST [$name] )) {
  6375. if (is_array ( $_POST [$name] ))
  6376. return $_POST [$name];
  6377. else {
  6378. return addslashes ( $_POST [$name] );
  6379. }
  6380. } else {
  6381. return false;
  6382. }
  6383. }
  6384. function get_previous($on_page = 1) {
  6385. return $on_page != 0 ? $on_page - 1 : $on_page;
  6386. }
  6387. /**
  6388. * 获得分页数据
  6389. * @param unknown_type $table
  6390. * @param unknown_type $condition
  6391. * @param unknown_type $on_page
  6392. * @param unknown_type $page_size
  6393. */
  6394. function get_Tpage($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $tagSQL) {
  6395. $page_c = "";
  6396. $page ['previous'] = $this->get_previous ( $on_page );
  6397. $page ['on_page'] = $on_page;
  6398. $total_count = $this->get_table_Tcount ( $table, $condition, $tagSQL );
  6399. $total = intval ( $total_count / $page_size );
  6400. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  6401. $page ['total_data'] = $total_count;
  6402. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  6403. $i = 1;
  6404. $page_max = 1;
  6405. if ($on_page > 10) {
  6406. $page_max = intval ( $on_page / 10 ) + 1;
  6407. $i = intval ( $on_page / 10 ) * 10 - 1;
  6408. }
  6409. $page ['page'] = $page_c;
  6410. $page ['lower'] = (-- $on_page) * $page_size;
  6411. return $page;
  6412. }
  6413. /**
  6414. * 获得分页数据
  6415. * @param unknown_type $table
  6416. * @param unknown_type $condition
  6417. * @param unknown_type $on_page
  6418. * @param unknown_type $page_size
  6419. */
  6420. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page", $staffid = "", $search, $tooltip, $cateid, $tagSQL) {
  6421. $page_c = "";
  6422. $page ['previous'] = $this->get_previous ( $on_page );
  6423. $page ['on_page'] = $on_page;
  6424. $total_count = $this->get_table_count ( $table, $condition, $staffid, $search, $tooltip, $cateid, $tagSQL );
  6425. $total = intval ( $total_count / $page_size );
  6426. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  6427. $page ['total_data'] = $total_count;
  6428. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  6429. $i = 1;
  6430. $page_max = 1;
  6431. if ($on_page > 10) {
  6432. $page_max = intval ( $on_page / 10 ) + 1;
  6433. $i = intval ( $on_page / 10 ) * 10 - 1;
  6434. }
  6435. for(; $i <= $page ['total_page']; $i ++) {
  6436. if ($i == $on_page) {
  6437. if ($other == "page")
  6438. $page_c .= '<a href="javascript:void(0);" class="current">' . $i . '</a>';
  6439. else
  6440. $page_c .= '&nbsp;<span class="current">' . $i . '</span>&nbsp;';
  6441. } else if ($other == "page")
  6442. $page_c .= '<a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a>';
  6443. else
  6444. $page_c .= '&nbsp;<a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a>&nbsp;';
  6445. if ($i == (10 * $page_max))
  6446. break;
  6447. }
  6448. $page ['page'] = $page_c;
  6449. $page ['lower'] = (-- $on_page) * $page_size;
  6450. return $page;
  6451. }
  6452. /**
  6453. * 获取总页数
  6454. * @param unknown_type $table
  6455. * @param unknown_type $condition
  6456. */
  6457. public function get_table_Tcount($table = "", $condition = "", $tagSQL) {
  6458. if ($tagSQL)
  6459. $sql = "select count(*) as count from CLD_tagCompanyNexus as a left join CLD_company as b on (a.company=b.cid ) where " . $condition;
  6460. else
  6461. $sql = "select count(*) as count from CLD_company where " . $condition;
  6462. $query = Doo::db ()->query ( $sql );
  6463. $result = $query->fetch ();
  6464. return $result ['count'];
  6465. }
  6466. /**
  6467. * 获取总页数
  6468. * @param unknown_type $table
  6469. * @param unknown_type $condition
  6470. */
  6471. public function get_table_count($table = "", $condition = "", $staffid = "", $search, $tooltip, $cateid, $tagSQL) {
  6472. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  6473. // echo $staffid;die;
  6474. //
  6475. if (! empty ( $staffid )) {
  6476. // $staffid="and a.sid= '".$staffid."'"; " . $table . " as a left join on (a.cid=b.cid ".$staffid.")
  6477. $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;
  6478. } else {
  6479. if (strlen ( $condition ) == 1 || empty ( $condition ))
  6480. $sql = "select count(*) as count from CLD_client as a " . $condition;
  6481. else
  6482. $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;
  6483. }
  6484. if (! empty ( $search ))
  6485. $sql = "select count(*) as count from CLD_client as a where 1 " . $condition;
  6486. if (! empty ( $tooltip )) {
  6487. $condition = str_replace ( "a.", "c.", $condition );
  6488. if ($tagSQL)
  6489. $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;
  6490. else
  6491. $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;
  6492. }
  6493. // echo $sql;
  6494. $query = Doo::db ()->query ( $sql );
  6495. $result = $query->fetch ();
  6496. return $result ['count'];
  6497. }
  6498. }
  6499. ?>