MainController.php 226 KB

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