MainController.php 197 KB

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