MainController.php 261 KB

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