MainController.php 246 KB

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