MainController.php 199 KB

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