MainController.php 245 KB

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