MainController.php 228 KB

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