MainController.php 241 KB

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