MainController.php 197 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164
  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. $staffList=$staff->find(array ('where' => "isadmin= 0",'asArray' => TRUE));
  1839. Doo::db()->beginTransaction();
  1840. foreach ($staffList as $key=>$value){// not in(1,2)
  1841. $sum=$longle->count(array ('where' => "status!= 1 and responsible ='".$value['username']."'",'asArray' => TRUE));
  1842. $a=$longle->count(array ('where' => "status!= 2 and status!= 1 and responsible ='".$value['username']."'",'asArray' => TRUE));
  1843. $b=$sum-$a;
  1844. $staffList[$key]['sum']=$sum;
  1845. $staffList[$key]['a']=$a;
  1846. $staffList[$key]['b']=$b;
  1847. }
  1848. Doo::db()->commit();
  1849. $data['staffList']=$staffList;
  1850. $data['memu']="keyStatistics";
  1851. $this->render ( "lock_count", $data );
  1852. }
  1853. function addDoLockLog(){
  1854. Doo::loadModel ( 'longle_log' );
  1855. Doo::loadModel ( 'longle' );
  1856. Doo::loadModel("action_log");
  1857. Doo::loadModel ( 'client' );
  1858. $clientobj = new client ();
  1859. $longle = new longle ();
  1860. $longle_log = new longle_log ();
  1861. Doo::loadModel ( 'district' );
  1862. $district = new district ();
  1863. $status=isset($_POST['longleStatus'])?$_POST['longleStatus']:0;
  1864. $lid=isset($_POST['klid'])?$_POST['klid']:0;
  1865. if(empty($lid))
  1866. return "/keyonline/";
  1867. $linfo=$longle->getLongleByLid($lid);
  1868. if($status==0)
  1869. return "/keyonline/".$lid;
  1870. elseif($status==3){
  1871. $client=isset($_POST['browseClient'])?$_POST['browseClient']:"";
  1872. $client=explode('-', $client);
  1873. $product=isset($_POST['browseProduct'])?$_POST['browseProduct']:"";
  1874. $clientname=$clientobj->getClientByName2($client[0],$client[1]);
  1875. if(empty($clientname))
  1876. return "/keyonline/".$lid;
  1877. if($client[0]!=""){
  1878. $longle->client=$client[0];
  1879. $longle->clientid=$clientname[0]['cid'];
  1880. }
  1881. // if($product!="")
  1882. // $longle->product=$product;
  1883. $longle->statusT="借出";
  1884. $longle_log->client=$client[0];
  1885. $longle_log->clientid=$clientname[0]['cid'];
  1886. $longle_log->product=$linfo[0]['product'];
  1887. $longle_log->statusT="借出";
  1888. //日常行为
  1889. $action_log=new action_log();
  1890. $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'].')';
  1891. $action_log->sid=$this->staff[0]['sid'];
  1892. $action_log->cid=$this->staff[0]['cid'];
  1893. $action_log->updatetime=date("Y-m-d");
  1894. $action_log->time=date("H:i");
  1895. $action_log->status=4;
  1896. $action_log->districtid=$clientname[0]['district'];
  1897. $local=$district->getbyidlist($clientname[0]['district']);
  1898. $action_log->city=$local[0]['name'];
  1899. $action_log->province=$local[1]['name'];
  1900. $action_log->company=$clientname[0]['companyname'];
  1901. Doo::loadModel('company');
  1902. $company=new company();
  1903. $companyInfo=$company->getOne(array('where'=>' companyname="'.$clientname[0]['companyname'].'"','asArray'=>true));
  1904. $nature=explode(',', $companyInfo['nature']);
  1905. $action_log->nature=$nature[0];
  1906. $action_log->class=$action_log->iconBorrow;
  1907. $action_log->insert();
  1908. }elseif($status==4){
  1909. $product=isset($_POST['sellProduct'])?$_POST['sellProduct']:"";
  1910. $client=isset($_POST['sellClient'])?$_POST['sellClient']:"";
  1911. $client=explode('-', $client);
  1912. $clientname=$clientobj->getClientByName2($client[0],$client[1]);
  1913. if(empty($clientname))
  1914. return "/keyonline/".$lid;
  1915. if($client[0]!=""){
  1916. $longle->client=$client[0];
  1917. $longle->clientid=$clientname[0]['cid'];
  1918. }
  1919. // if($product!="")
  1920. // $longle->product=$product;
  1921. $longle->statusT="销售";
  1922. $longle_log->client=$client[0];
  1923. $longle_log->clientid=$clientname[0]['cid'];
  1924. $longle_log->product=$linfo[0]['product'];
  1925. $longle_log->statusT="销售";
  1926. //日常行为
  1927. $action_log=new action_log();
  1928. $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'].')';
  1929. $action_log->sid=$this->staff[0]['sid'];
  1930. $action_log->cid=$this->staff[0]['cid'];
  1931. $action_log->updatetime=date("Y-m-d");
  1932. $action_log->time=date("H:i");
  1933. $action_log->status=5;
  1934. $action_log->districtid=$clientname[0]['district'];
  1935. $local=$district->getbyidlist($clientname[0]['district']);
  1936. $action_log->city=$local[0]['name'];
  1937. $action_log->province=$local[1]['name'];
  1938. $action_log->company=$clientname[0]['companyname'];
  1939. Doo::loadModel('company');
  1940. $company=new company();
  1941. $companyInfo=$company->getOne(array('where'=>' companyname="'.$clientname[0]['companyname'].'"','asArray'=>true));
  1942. $nature=explode(',', $companyInfo['nature']);
  1943. $action_log->nature=$nature[0];
  1944. $action_log->class=$action_log->iconSell;
  1945. $action_log->insert();
  1946. }elseif($status==5){
  1947. $product=isset($_POST['newProduct'])?$_POST['newProduct']:"";
  1948. if($product!="")
  1949. $longle->product=$linfo[0]['product']."+".$product;
  1950. $longle->statusT="升级";
  1951. $longle_log->product=$linfo[0]['product']."+".$product;
  1952. $longle_log->statusT="升级";
  1953. $longle_log->client=$linfo[0]['client'];
  1954. $longle_log->clientid=$linfo[0]['clientid'];
  1955. $clientname=$clientobj->getOne( array ('where' => "cid= '".$linfo[0]['clientid']."'",'asArray' => TRUE));
  1956. //日常行为
  1957. $action_log=new action_log();
  1958. $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>';
  1959. $action_log->sid=$this->staff[0]['sid'];
  1960. $action_log->cid=$this->staff[0]['cid'];
  1961. $action_log->updatetime=date("Y-m-d");
  1962. $action_log->time=date("H:i");
  1963. $action_log->class=$action_log->iconUpdate;
  1964. $action_log->sid=$this->staff[0]['sid'];
  1965. $action_log->cid=$this->staff[0]['cid'];
  1966. $action_log->status=7;
  1967. $action_log->insert();
  1968. }elseif($status==6){
  1969. $key_num=isset($_POST['key_num'])?$_POST['key_num']:"";
  1970. $key_num2=explode("-", $key_num);
  1971. $key_num=$key_num2[0]."-".$key_num2[1];
  1972. //if($key_num!="")
  1973. // $longle->key_num=$key_num;
  1974. //新锁拷贝记录
  1975. $newLongle=new longle();
  1976. //$newLongle->product=$linfo[0]['product'];
  1977. $newLongle->statusT="更换";
  1978. $newLongle->status=6;
  1979. $newLongle->client=$linfo[0]['client'];
  1980. $newLongle->clientid=$linfo[0]['clientid'];
  1981. $newlid=$newLongle->update(array('where'=>' key_num= \''.$key_num."'"));
  1982. $longleinfo=$longle->getOne(array('where'=>' key_num =\''.$key_num."'",'asArray'=>true));
  1983. $longleLog=$longle_log->getOne(array('where'=>' lid ='.$linfo[0]['lid'],'desc'=>'logid','asArray'=>true));
  1984. //新记录日志
  1985. $newlongle_log=new longle_log();
  1986. $newlongle_log->statusT="更换";
  1987. $newlongle_log->status=6;
  1988. $newlongle_log->client=$linfo[0]['client'];
  1989. $newlongle_log->new_key_num=$linfo[0]['key_num'];
  1990. $newlongle_log->product=$linfo[0]['product'];
  1991. $newlongle_log->category=$this->staff[0]['category'];
  1992. $newlongle_log->dateline=date("Y-m-d");
  1993. $newlongle_log->operator=$this->staff[0]['username'];
  1994. $newlongle_log->lid=$longleinfo['lid'];
  1995. $newlongle_log->insert();
  1996. $newlongle_log=new longle_log();
  1997. $newlongle_log->statusT=$longleLog['statusT'];
  1998. $newlongle_log->status=$longleLog['status'];
  1999. $newlongle_log->client=$longleLog['client'];
  2000. $newlongle_log->new_key_num=$longleLog['new_key_num'];
  2001. $newlongle_log->product=$longleLog['product'];
  2002. $newlongle_log->category=$longleLog['category'];
  2003. $newlongle_log->dateline=$longleLog['dateline'];
  2004. $newlongle_log->operator=$longleLog['operator'];
  2005. $newlongle_log->lid=$longleinfo['lid'];
  2006. $newlongle_log->insert();
  2007. $newLongle=new longle();
  2008. $newLongle->statusT=$longleLog['statusT'];
  2009. $newLongle->status=$longleLog['status'];
  2010. $newlid=$newLongle->update(array('where'=>' key_num= \''.$key_num."'"));
  2011. //新锁状态拷贝
  2012. $longle->statusT="更换";
  2013. $longle_log->new_key_num=$key_num;
  2014. $longle_log->statusT="更换";
  2015. $longle_log->client=$linfo[0]['client'];
  2016. $clientname=$clientobj->getOne( array ('where' => "cid= '".$linfo[0]['clientid']."'",'asArray' => TRUE));
  2017. //日常行为
  2018. $action_log=new action_log();
  2019. $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'].')';
  2020. $action_log->sid=$this->staff[0]['sid'];
  2021. $action_log->cid=$this->staff[0]['cid'];
  2022. $action_log->updatetime=date("Y-m-d");
  2023. $action_log->time=date("H:i");
  2024. $action_log->class=$action_log->iconReplace;
  2025. $action_log->sid=$this->staff[0]['sid'];
  2026. $action_log->cid=$this->staff[0]['cid'];
  2027. $action_log->status=8;
  2028. $action_log->insert();
  2029. }elseif($status==7){
  2030. $longle->statusT="收回";
  2031. $longle_log->statusT="收回";
  2032. $longle_log->responsible=$linfo[0]['responsible'];
  2033. //日常行为
  2034. $action_log=new action_log();
  2035. $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>';
  2036. $action_log->sid=$this->staff[0]['sid'];
  2037. $action_log->cid=$this->staff[0]['cid'];
  2038. $action_log->updatetime=date("Y-m-d");
  2039. $action_log->time=date("H:i");
  2040. $action_log->class=$action_log->iconRecycle;
  2041. $action_log->sid=$this->staff[0]['sid'];
  2042. $action_log->cid=$this->staff[0]['cid'];
  2043. $action_log->status=9;
  2044. $action_log->insert();
  2045. }elseif($status==8){
  2046. $mark=isset($_POST['mark'])?$_POST['mark']:"";
  2047. if (empty($mark)){
  2048. echo json_encode(array('msg'=>2));die;
  2049. }
  2050. $longle_log->mark=$mark;
  2051. //日常行为
  2052. $action_log=new action_log();
  2053. $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>添加新备注。';
  2054. $action_log->sid=$this->staff[0]['sid'];
  2055. $action_log->cid=$this->staff[0]['cid'];
  2056. $action_log->updatetime=date("Y-m-d");
  2057. $action_log->time=date("H:i");
  2058. $action_log->sid=$this->staff[0]['sid'];
  2059. $action_log->cid=$this->staff[0]['cid'];
  2060. $action_log->status=10;
  2061. $action_log->class=$action_log->iconLock;
  2062. $action_log->insert();
  2063. }elseif($status==9){
  2064. $longle->statusT="赠送";
  2065. $longle_log->statusT="赠送";
  2066. $client=isset($_POST['giftClient'])?$_POST['giftClient']:"";
  2067. $client=explode('-', $client);
  2068. $clientname=$clientobj->getClientByName2($client[0],$client[1]);
  2069. if(empty($clientname))
  2070. return "/keyonline/".$lid;
  2071. if($client[0]!=""){
  2072. $longle->client=$client[0];
  2073. $longle->clientid=$clientname[0]['cid'];
  2074. }
  2075. $longle_log->client=$client[0];
  2076. $longle_log->clientid=$clientname[0]['cid'];
  2077. //日常行为
  2078. $action_log=new action_log();
  2079. $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'].')';
  2080. $action_log->updatetime=date("Y-m-d");
  2081. $action_log->time=date("H:i");
  2082. $action_log->class=$action_log->iconRecycle;
  2083. $action_log->sid=$this->staff[0]['sid'];
  2084. $action_log->cid=$this->staff[0]['cid'];
  2085. $action_log->status=6;
  2086. $action_log->districtid=$clientname[0]['district'];
  2087. $local=$district->getbyidlist($clientname[0]['district']);
  2088. $action_log->city=$local[0]['name'];
  2089. $action_log->province=$local[1]['name'];
  2090. $action_log->company=$clientname[0]['companyname'];
  2091. Doo::loadModel('company');
  2092. $company=new company();
  2093. $companyInfo=$company->getOne(array('where'=>' companyname="'.$clientname[0]['companyname'].'"','asArray'=>true));
  2094. $nature=explode(',', $companyInfo['nature']);
  2095. $action_log->nature=$nature[0];
  2096. $action_log->insert();
  2097. }
  2098. //记录使用过的状态
  2099. $statuslog=$status.",".$linfo[0]['statuslog'];
  2100. $ar=explode(',', $statuslog);
  2101. $statuslog=implode(',', array_unique(array_filter($ar)));
  2102. $longle->statuslog=$statuslog;
  2103. if($linfo[0]['status']<=2){
  2104. if($status>=4&&$status<=2){
  2105. return "/keyonline/".$lid;
  2106. }
  2107. }
  2108. if($lid!=0){
  2109. $longle->lid=$lid;
  2110. if($status!=8)
  2111. $longle->status=$status;
  2112. //if($status!=8)
  2113. $longle->responsible=$this->staff[0]['username'];
  2114. $longle->update();
  2115. }
  2116. $longle_log->lid=$lid;
  2117. $longle_log->status=$status;
  2118. $longle_log->operator=$this->staff[0]['username'];
  2119. //责任人
  2120. $longle_log->category=$this->staff[0]['category'];
  2121. $longle_log->dateline=date("Y-m-d");
  2122. $longle_log->insert();
  2123. echo json_encode(array('msg'=>1));die;
  2124. //return "/keyonline/".$lid;
  2125. }
  2126. function ajaxGetLongleByName(){
  2127. Doo::loadModel ( 'longle_log' );
  2128. Doo::loadModel ( 'longle' );
  2129. $longle = new longle ();
  2130. $longle_log = new longle_log ();
  2131. $name=isset($_POST['name'])?$_POST['name']:"";
  2132. if(empty($name)){
  2133. echo json_encode(array("success"=>false));die;
  2134. }
  2135. $ky=$longle->getLongleBykeynum($name);
  2136. $t=$longle_log->getLongleByLid($ky[0]['lid']);
  2137. if(isset($t[0]))
  2138. $tk=$t[0];
  2139. else
  2140. $tk=array();
  2141. $longleLog=$tk;
  2142. $longleLog['klid']=$t[0]['lid'];
  2143. $longleLog['longle']=$ky[0];
  2144. $longleLog['longleLogHtml']=$this->_getLongleLogHtml($t);
  2145. echo json_encode($longleLog);
  2146. }
  2147. function ajaxGetLongleN(){
  2148. Doo::loadModel ( 'longle_log' );
  2149. Doo::loadModel ( 'longle' );
  2150. $longle = new longle ();
  2151. $longle_log = new longle_log ();
  2152. $keynum=isset($_POST['keynum'])?$_POST['keynum']:"";
  2153. if(empty($keynum)){
  2154. echo json_encode(array("success"=>false));die;
  2155. }
  2156. $ky=$longle->getLongleBykeynum($keynum);
  2157. if(!empty($ky)){
  2158. $t=$longle_log->getLongleByLid($ky[0]['lid']);
  2159. if(isset($t[0]))
  2160. $tk=$t[0];
  2161. else
  2162. $tk=array();
  2163. $longleLog=$tk;
  2164. $longleLog['klid']=$ky[0]['lid'];
  2165. $longleLog['longle']=$ky[0];
  2166. $longleLog['longleLogHtml']=$this->_getLongleLogHtml($t);
  2167. echo json_encode($longleLog);
  2168. }
  2169. }
  2170. function ajaxGetLongle(){
  2171. Doo::loadModel ( 'longle_log' );
  2172. Doo::loadModel ( 'longle' );
  2173. $longle = new longle ();
  2174. $longle_log = new longle_log ();
  2175. $lid=isset($_POST['lid'])?$_POST['lid']:0;
  2176. if($lid==0){
  2177. echo json_encode(array("success"=>false));die;
  2178. }
  2179. $t=$longle_log->getLongleByLid($lid);
  2180. if(isset($t[0]))
  2181. $tk=$t[0];
  2182. else
  2183. $tk=array();
  2184. $longleLog=$tk;
  2185. $longleLog['klid']=$lid;
  2186. $ky=$longle->getLongleByLid($lid);
  2187. $longleLog['longle']=$ky[0];
  2188. $longleLog['longleLogHtml']=$this->_getLongleLogHtml($t);
  2189. echo json_encode($longleLog);
  2190. }
  2191. function ajaxGetStaffInfo(){
  2192. $username=isset($_POST['username'])?$_POST['username']:"";
  2193. if($username==""){
  2194. echo json_encode(array("success"=>false));die;
  2195. }
  2196. Doo::loadModel ( 'staff' );
  2197. $staff = new staff ();
  2198. $staffInfo=$staff->getOne(array('where'=>' username like "'.$username.'"', 'asArray' => TRUE ));
  2199. if(empty($staffInfo)){
  2200. echo json_encode(array("success"=>false,'html'=>''));die;
  2201. }
  2202. $staffHtml=array('html'=>'<div class="contactPanel"><h1>'.$staffInfo['username'].'</h1>
  2203. <table><tbody><tr><th>性别</th><td>'.$staffInfo['gender'].'</td><th>办事处</th><td>'.$staffInfo['category'].'</td></tr>
  2204. <tr><th>手机</th><td>'.$staffInfo['telephone'].'</td><th>电话</th><td>'.$staffInfo['phone'].'</td></tr>
  2205. <tr><th>QQ</th><td>'.$staffInfo['qq'].'</td><th>邮箱</th><td>'.$staffInfo['email'].'</td></tr>
  2206. </tbody></table>
  2207. </div>');
  2208. echo json_encode($staffHtml);
  2209. }
  2210. function ajaxGetCompanyByAdd(){
  2211. $cid=isset($_POST['cid'])?$_POST['cid']:"";
  2212. if(!empty($cid)){
  2213. Doo::loadModel ( 'company' );
  2214. $company = new company();
  2215. Doo::loadModel ( 'client' );
  2216. Doo::loadModel('district');
  2217. $district=new district();
  2218. $client = new client();
  2219. $districtInfo=$district->get_lv(1);
  2220. $companyInfo=$client->getClientByCompanyId($cid);
  2221. $companyInfo=$companyInfo[0];
  2222. $cInfo=$company->getOne(array('where'=>"cid = ".$cid,'asArray' => TRUE));
  2223. $companyInfo['ride']=$cInfo['ride'];
  2224. $companyInfo['landmarks']=$cInfo['landmarks'];
  2225. $companyInfo['stay']=$cInfo['stay'];
  2226. $artld=explode(',', $cInfo['local']);
  2227. $districtid=explode(',', $cInfo['district']);
  2228. $html="";
  2229. $html.='<select name="lv21" id="lv31" onchange="dislv(\'lv31\',\'32\');"><option value="'.$districtid[0].'">'.$artld[0].'</option>';
  2230. // foreach ($districtInfo as $key=>$value){
  2231. //
  2232. // $html.='<option selected value="'.$value['id'].'">'.$value['name'].'</option>';
  2233. // }
  2234. $html.='</select>&nbsp;';
  2235. $html.='<span id="mlv32">
  2236. <select id="lv32" name="lv22">
  2237. <option selected value="'.$districtid[1].'" >'.$artld[1].'</option>
  2238. </select>
  2239. </span>';
  2240. $html.='<span id="mlv33">
  2241. <select id="lv33" name="lv23">
  2242. <option selected value="'.$districtid[2].'" >'.$artld[2].'</option>
  2243. </select>&nbsp;
  2244. </span>';
  2245. $companyInfo['dishtml']=$html;
  2246. $companyInfo['natureAr']=$this->nature;
  2247. $companyInfo['natureArlenght']=12;
  2248. echo json_encode(array("success"=>true,'data'=>$companyInfo));die;
  2249. }else
  2250. echo json_encode(array("success"=>false,'data'=>''));die;
  2251. }
  2252. function doEditCompanyD(){
  2253. $cid=isset($_POST['cid'])?$_POST['cid']:0;
  2254. $companyname=isset($_POST['companyname'])?$_POST['companyname']:"";
  2255. $lv21=isset($_POST['lv21'])?$_POST['lv21']:0;
  2256. $lv22=isset($_POST['lv22'])?$_POST['lv22']:0;
  2257. $lv23=isset($_POST['lv23'])?$_POST['lv23']:0;
  2258. $nature=isset($_POST['nature'])?$_POST['nature']:"";
  2259. $fax=isset($_POST['fax'])?$_POST['fax']:"";
  2260. $webservice=isset($_POST['webservice'])?$_POST['webservice']:"";
  2261. $address=isset($_POST['address'])?$_POST['address']:"";
  2262. $ride=isset($_POST['ride'])?$_POST['ride']:"";
  2263. $stay=isset($_POST['stay'])?$_POST['stay']:"";
  2264. $landmarks=isset($_POST['landmarks'])?$_POST['landmarks']:"";
  2265. if(empty($cid)||empty($companyname)){
  2266. echo json_encode(array("success"=>false));die;
  2267. }
  2268. Doo::loadModel("company");
  2269. Doo::loadModel("client");
  2270. $client=new client();
  2271. $company=new company();
  2272. $company->cid=$cid;
  2273. if(!empty($lv21)&&!empty($lv22)&&!empty($lv23)){
  2274. Doo::loadModel ( 'district' );
  2275. $district = new district ();
  2276. //更新公司信息
  2277. $lv1=$district->getbyid($lv21);
  2278. $lv2=$district->getbyid($lv22);
  2279. $lv3=$district->getbyid($lv23);
  2280. $company->district=$lv21.",".$lv22.",".$lv23;
  2281. $company->local=$lv1[0]['name'].",".$lv2[0]['name'].",".$lv3[0]['name'];
  2282. }
  2283. if(!empty($nature)){
  2284. $nature=implode(",", $nature);
  2285. $company->nature=$nature;
  2286. }
  2287. if(!empty($companyname)){
  2288. $company->companyname=$companyname;
  2289. $client->companyname=$companyname;
  2290. }
  2291. if(!empty($fax))
  2292. $company->fax=$fax;
  2293. if(!empty($webservice))
  2294. $company->webservice=$webservice;
  2295. if(!empty($address))
  2296. $company->address=$address;
  2297. if(!empty($ride))
  2298. $company->ride=$ride;
  2299. if(!empty($stay))
  2300. $company->stay=$stay;
  2301. if(!empty($landmarks))
  2302. $company->landmarks=$landmarks;
  2303. $company->update();
  2304. $client->update(array('where'=>' companyid ='.$cid));
  2305. echo json_encode(array("success"=>true));die;
  2306. }
  2307. function ajaxEditCompany(){
  2308. $companyname=isset($_POST['companyId'])?$_POST['companyId']:0;
  2309. if(!empty($companyname)){
  2310. Doo::loadModel ( 'company' );
  2311. $company = new company();
  2312. $companyInfo=$company->getOne(array('where'=>"cid = '".$companyname."'",'asArray' => TRUE));
  2313. if(!empty($companyInfo)){
  2314. Doo::loadModel('district');
  2315. $district=new district();
  2316. $districtinfo=$district->get_lv(1);
  2317. $dinfo=$district->getbyidlist($companyInfo['district']);
  2318. $html='
  2319. <div class="contactInfo clearfix">
  2320. <div class="header">
  2321. <h1 class="companyName">'.$companyInfo['companyname'].'</h1>
  2322. </div>
  2323. </div>
  2324. <div class="lockRecord">
  2325. <div class="contactPanel">
  2326. <table>
  2327. <tbody><tr><th>单位全称</th><td colspan="3"><input type="text" name="companyname" id="companyname" value="'.$companyInfo['companyname'].'"></td></tr>
  2328. <tr><th>地区</th><td colspan="3">
  2329. <select name="lv21" id="lv21" onchange="dislv(\'lv21\',22);">
  2330. <option value="0">请选择</option>';
  2331. foreach ($districtinfo as $key=>$value){
  2332. if($value['id']==$dinfo[0]['id'])
  2333. $html.='<option selected value="'.$value['id'].'">'.$value['name'].'</option>';
  2334. else
  2335. $html.='<option value="'.$value['id'].'">'.$value['name'].'</option>';
  2336. }
  2337. $html.='</select>
  2338. <span id="mlv22">
  2339. <select id="lv22">
  2340. <option value="'.$dinfo[1]['id'].'">'.$dinfo[1]['name'].'</option>
  2341. </select>
  2342. </span>
  2343. <span id="mlv23">
  2344. <select id="lv23">
  2345. <option value="'.$dinfo[2]['id'].'">'.$dinfo[2]['name'].'</option>
  2346. </select>&nbsp;
  2347. </span>
  2348. </td></tr>
  2349. ';
  2350. $html.='<tr><th>性质</th><td colspan="3">';
  2351. $ntre=explode(",", $companyInfo['nature']);
  2352. foreach ($this->nature as $key=>$value){
  2353. $falg=true;
  2354. foreach ($ntre as $k=>$v){
  2355. if($value==$v){
  2356. $falg=false;
  2357. $html.='<label><input type="checkbox" checked name="nature[]" value="'.$value.'">'.$value.'</label>&nbsp;';
  2358. }
  2359. }
  2360. if($falg)
  2361. $html.='<label><input type="checkbox" name="nature[]" value="'.$value.'">'.$value.'</label>&nbsp;';
  2362. }
  2363. $html.=' </td></tr>
  2364. <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>
  2365. <tr><th>单位地址</th><td colspan="3"><input type="text" name="address" id="address" value="'.$companyInfo['address'].'"> </td></tr>
  2366. <tr><th>乘车路线</th><td colspan="3"><input type="text" name="ride" id="ride" value="'.$companyInfo['ride'].'"> </td></tr>
  2367. <tr><th>地标建筑</th><td colspan="3"><input type="text" name="landmarks" id="landmarks" value="'.$companyInfo['landmarks'].'"> </td></tr>
  2368. <tr><th>住宿参考</th><td colspan="3"><input type="text" name="stay" id="stay" value="'.$companyInfo['stay'].'"> </td></tr>
  2369. <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>
  2370. </tbody></table>
  2371. <div class="bsAlert bsInfo">单位全称将与该单位已存在的客户进行同步;其他单位信息不会进行同步;<br>单位信息随该单位第一位客户录入,并作为“在这添加客户”的基础数据</div>
  2372. </div>
  2373. </div>
  2374. ';
  2375. echo json_encode(array("success"=>true,'html'=>$html));die;
  2376. }
  2377. }else
  2378. echo json_encode(array("success"=>false,'html'=>''));die;
  2379. }
  2380. function ajaxGetCompany(){
  2381. $companyname=isset($_POST['companyId'])?$_POST['companyId']:0;
  2382. if(!empty($companyname)){
  2383. Doo::loadModel ( 'company' );
  2384. $company = new company();
  2385. $companyInfo=$company->getOne(array('where'=>"cid = '".$companyname."'",'asArray' => TRUE));
  2386. if(!empty($companyInfo)){
  2387. Doo::loadModel ( 'client' );
  2388. Doo::loadModel ( 'staff' );
  2389. Doo::loadModel ( 'client_staff' );
  2390. Doo::loadModel ( 'longle' );
  2391. $longle = new longle();
  2392. $client_staff = new client_staff();
  2393. $staff = new staff();
  2394. $client = new client();
  2395. $clientlist=$client->getClientByCompanyId($companyInfo['cid']);
  2396. $department=$client->getDepartment($companyInfo['cid']);
  2397. Doo::loadModel("tagCompanyNexus");
  2398. Doo::loadModel("tagCompany");
  2399. $tag=new tagCompany();
  2400. $tag_client=new tagCompanyNexus();
  2401. $tagId=$tag_client->getTagClientBySCid($companyInfo['cid'], $this->staff[0]['sid']);
  2402. $taginfo=$tag->getTagByTidL($tagId['tag']);
  2403. $taghtml="";
  2404. foreach ($taginfo as $key=>$value){
  2405. $taghtml.='<span class="contactsTag tagCol-0'.$value['colorid'].'">'.$value['name'].'</span>';
  2406. }
  2407. $html='<div class="header">
  2408. <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>
  2409. <div class="contactPanel">
  2410. <table>
  2411. <tbody>
  2412. <tr><th>单位地区</th><td><span>'.$companyInfo['local'].'</span></td><th>单位性质</th><td>'.$companyInfo['nature'].'</td></tr>
  2413. <tr><th>单位地址</th><td colspan="3">'.$companyInfo['address'].'</td></tr>
  2414. <tr><th>单位乘车</th><td colspan="3">'.$companyInfo['ride'].'</td></tr>
  2415. <tr><th>单位地标</th><td colspan="3">'.$companyInfo['landmarks'].'</td></tr>
  2416. <tr><th>单位住宿</th><td colspan="3">'.$companyInfo['stay'].'</td></tr>
  2417. <tr><td colspan="4">
  2418. '.$taghtml.'
  2419. </td></tr>
  2420. </tbody></table></div>
  2421. <h2 class="cate">';
  2422. $html.='<a href="javascript:void(0)" onclick="departmentC()" class="now">不限</a>';
  2423. foreach ($department as $key=>$value){
  2424. if ($value!="")
  2425. $html.='<a href="javascript:void(0)" onclick="departmentC(\''.$value['department'].'\')">'.$value['department'].'</a>';
  2426. }
  2427. $html.='</h2></div><script>$(".header .cate a").click(function(){
  2428. $(this).addClass("now").siblings("a").removeClass("now");
  2429. });
  2430. </script>';
  2431. $html.='<div class="lockRecord autoHeightR2" >';
  2432. foreach ($clientlist as $key=>$value){
  2433. $scinfo=$client_staff->getClientByCid($value['cid']);
  2434. $staffinfo=$staff->getUserById($scinfo['sid']);
  2435. $html.='<div class="contactPanel" id="PART_'.$value['department'].'">
  2436. <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>
  2437. <tbody><tr><th>性别</th><td>'.$value['gender'].'</td><th>昵称</th><td>'.$value['nicename'].'</td></tr>
  2438. <tr><th>部门</th><td>'.$value['department'].'</td><th>办公室</th><td>'.$value['office'].'</td></tr>
  2439. <tr><th>手机</th><td>'.$value['telephone'].'</td><th>电话</th><td>'.$value['phone'].'</td></tr>
  2440. <tr><th>QQ</th><td>'.$value['qq'].'</td><th>邮箱</th><td>'.$value['email'].'</td></tr>
  2441. <tr><th>备注</th><td colspan="3">'.$value['mark'].'</td></tr>';
  2442. //$longleinfo=$longle->getLongleBykeynum($value['keynum']);
  2443. $longleinfo=$longle->getLongleByClientid($value['cid']);
  2444. if(empty($longleinfo)){
  2445. $longleinfo=array(0=>array('lid'=>'','key_num'=>'','product'=>'','statusT'=>''));
  2446. }
  2447. $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>';
  2448. $html.='</tbody></table></div>';
  2449. }
  2450. $html.="</div><script type='text/javascript'>autoFlashHeight();</script>";
  2451. echo json_encode(array("success"=>true,'html'=>$html));die;
  2452. }
  2453. }else
  2454. echo json_encode(array("success"=>false,'html'=>''));die;
  2455. }
  2456. function checkclicomname(){//地区区分
  2457. $companyname=isset($_POST['companyname'])?$_POST['companyname']:"";
  2458. $clientname=isset($_POST['clientname'])?$_POST['clientname']:"";
  2459. $district1=isset($_POST['district1'])?$_POST['district1']:0;
  2460. $district2=isset($_POST['district2'])?$_POST['district2']:0;
  2461. $district3=isset($_POST['district3'])?$_POST['district3']:0;
  2462. Doo::loadModel ( 'client' );
  2463. $client = new client ();
  2464. $local=$district1.",".$district2.",".$district3;
  2465. $companyname=trim($companyname);
  2466. $clientname=trim($clientname);
  2467. $clientinfo=$client->getClientToName($clientname,$companyname,$local);
  2468. if(!empty($clientinfo)){
  2469. echo json_encode(array('success'=>false));
  2470. }else{
  2471. echo json_encode(array('success'=>true));
  2472. }
  2473. }
  2474. function ajaxGetClientInfoN(){
  2475. $clientname=isset($_POST['client'])?$_POST['client']:"";
  2476. if($clientname==""){
  2477. echo json_encode(array("success"=>false));die;
  2478. }
  2479. Doo::loadModel ( 'client' );
  2480. Doo::loadModel ( 'client_staff' );
  2481. Doo::loadModel ( 'longle' );
  2482. Doo::loadModel ( 'company' );
  2483. Doo::loadModel ( 'service_log' );
  2484. $service_log = new service_log();
  2485. $company = new company();
  2486. $longle = new longle();
  2487. $client = new client ();
  2488. $client_staff = new client_staff ();
  2489. $clientInfo=$client->getOne(array("where"=>' cid like "'.$clientname.'"', 'asArray' => TRUE));
  2490. if(empty($clientInfo)){
  2491. echo json_encode(array("success"=>false,'html'=>''));die;
  2492. }
  2493. //获取锁
  2494. $longleInfo=$longle->getLongleByClient($clientname);
  2495. $k="";
  2496. foreach ($longleInfo as $key=>$value){
  2497. if($value['status']==6||$value['status']==7)
  2498. $k.='<a href="javascript:void(0)" class="disenable" onclick="getLock('.$value['lid'].')" >'.$value['key_num'].'/'.$value['product'].'/'.$value['statusT'].'</a>&nbsp; ';
  2499. else
  2500. $k.='<a href="javascript:void(0)" onclick="getLock('.$value['lid'].')" >'.$value['key_num'].'/'.$value['product'].'/'.$value['statusT'].'</a>&nbsp; ';
  2501. }
  2502. //获取办事人
  2503. $staffInfo=$client_staff->getClientByCid($clientInfo['cid']);
  2504. //获取公司信息
  2505. $companyInfo=$company->getCompanyByCid($clientInfo['companyid']);
  2506. $serviceLog=$service_log->getServiceByClientid($clientInfo['cid']);
  2507. $u="";
  2508. $order = array("\r\n", "\n", "\r");
  2509. $replace = '</br>';
  2510. foreach ($serviceLog as $key=>$value){
  2511. $datetime=explode("-", $value['date']);
  2512. $u.='<div class="infoFlowList">
  2513. <div class="dateTitle">
  2514. <em class="month"><span class="num">'.$datetime['1'].'</span><span class="text">-'.$datetime['2'].'</span></em>
  2515. <span class="year">'.$datetime['0'].'</span>
  2516. </div>
  2517. <ul class="flowList">';
  2518. if($value['status']==1)
  2519. $u.='<li class="item iconService">上门服务</li>';
  2520. elseif ($value['status']==2)
  2521. $u.='<li class="item iconPhone">电话拜访</li>';
  2522. elseif ($value['status']==3)
  2523. $u.='<li class="item iconOther">其他</li>';
  2524. $u.='
  2525. <li class="item">'.$value['category'].'<a href="javascript:void(0)" onclick="getStaffInfo(\''.$value['staffname'].'\')" >'.$value['staffname'].'</a></li>
  2526. <li class="item">
  2527. '.str_replace($order, $replace, $value['mark']).'
  2528. </li>
  2529. </ul>
  2530. </div>';
  2531. }
  2532. Doo::loadModel("tag_client");
  2533. Doo::loadModel("tag");
  2534. $tag=new tag();
  2535. $tag_client=new tag_client();
  2536. $tagId=$tag_client->getTagClientBySCid($clientInfo['cid'], $this->staff[0]['sid']);
  2537. $taginfo=$tag->getTagByTidL($tagId['tag']);
  2538. // $taghtml="";
  2539. //
  2540. // foreach ($taginfo as $key=>$value){
  2541. // $taghtml.='<span class="contactsTag tagCol-0'.$value['colorid'].'">'.$value['name'].'</span>';
  2542. // }
  2543. $mhtml="";$dhtml="";
  2544. for ($month=1;$month<=12;$month++){
  2545. if(date("m")==$month)
  2546. $mhtml.='<option selected value="'.$month.'">'.$month.'月</option>';
  2547. else
  2548. $mhtml.='<option value="'.$month.'">'.$month.'月</option>';
  2549. }
  2550. for ($day=1;$day<=31;$day++){
  2551. if(date("d")==$day)
  2552. $dhtml.='<option selected value="'.$day.'">'.$day.'日</option>';
  2553. else
  2554. $dhtml.='<option value="'.$day.'">'.$day.'日</option>';
  2555. }
  2556. // $b="";
  2557. // if(!empty($staffInfo))
  2558. // $b='<p class="fR">'.$staffInfo['category'].'-<a href="javascript:void(0)" onclick="getStaffInfo(\''.$staffInfo['username'].'\')" >'.$staffInfo['username'].'</a></p>'.$clientInfo['clientname'].' ';
  2559. //
  2560. $m="";
  2561. if(!empty($companyInfo)){
  2562. $m='
  2563. <table width="100%">
  2564. <tbody>
  2565. <tr><th>单位全称</th><td colspan="3"><a href="javascript:void(0)" >'.$companyInfo[0]['companyname'].'</a></td></tr>
  2566. <tr><th>地区</th><td>'.$companyInfo[0]['local'].'</td><th>部门/职位</th><td>'.$clientInfo['department'].'/'.$clientInfo['position'].'</td></tr>
  2567. <tr><th>传真</th><td>'.$companyInfo[0]['fax'].'</td><th>办公室</th><td>'.$companyInfo[0]['office'].'</td></tr>
  2568. <tr><th>单位地址</th><td colspan="3">'.$companyInfo[0]['address'].'</td></tr>
  2569. <tr><th>乘车路线</th><td colspan="3">'.$companyInfo[0]['ride'].'</td></tr>
  2570. <tr><th>地标建筑</th><td colspan="3">'.$companyInfo[0]['landmarks'].'</td></tr>
  2571. <tr><th>参考住宿</th><td colspan="3">'.$clientInfo['stay'].'</td></tr>
  2572. <tr><th>单位主页</th><td colspan="3">'.$clientInfo['webservice'].'</td></tr>
  2573. </tbody></table>
  2574. ';
  2575. }
  2576. $clientHtml=array('html'=>'<div class="modal-header">
  2577. <h3><span class="fR"><a>'.$staffInfo['category'].' '.$staffInfo['username'].'</a></span>'.$clientInfo['clientname'].'</h3>
  2578. </div>
  2579. <div class="modal-body">
  2580. <div class="modalClientTable">
  2581. <table width="100%">
  2582. <tbody><tr><th>性别</th><td>'.$clientInfo['gender'].'</td><th>昵称</th><td>'.$clientInfo['nicename'].'</td></tr>
  2583. <tr><th>手机</th><td>'.$clientInfo['telephone'].'</td><th>QQ</th><td>'.$clientInfo['qq'].'</td></tr>
  2584. <tr><th>电话</th><td>'.$clientInfo['phone'].'</td><th>邮箱</th><td>'.$clientInfo['email'].'</td></tr>
  2585. <tr><th>软件锁</th><td colspan="3">'.$k.'</td></tr>
  2586. <tr><td colspan="4">
  2587. </td></tr>
  2588. </tbody>
  2589. </table>
  2590. '.$m.'
  2591. <div class="clearfix">
  2592. '.$u.'
  2593. </div>
  2594. </div>
  2595. </div>
  2596. <div class="modal-footer">
  2597. <a href="javascript:void(0)" onclick="closeClick()" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a>
  2598. </div>
  2599. ');
  2600. echo json_encode($clientHtml);
  2601. }
  2602. function ajaxGetClientInfo(){
  2603. $clientname=isset($_POST['client'])?$_POST['client']:"";
  2604. if($clientname==""){
  2605. echo json_encode(array("success"=>false));die;
  2606. }
  2607. Doo::loadModel ( 'client' );
  2608. Doo::loadModel ( 'client_staff' );
  2609. Doo::loadModel ( 'longle' );
  2610. Doo::loadModel ( 'company' );
  2611. Doo::loadModel ( 'service_log' );
  2612. Doo::loadModel("district");
  2613. $district=new district();
  2614. $service_log = new service_log();
  2615. $company = new company();
  2616. $longle = new longle();
  2617. $client = new client ();
  2618. $client_staff = new client_staff ();
  2619. $nameStr=explode(",", $clientname);
  2620. //$clientname=$nameStr[1];
  2621. if(!empty($nameStr[0])){
  2622. $clientInfo=$client->getOne(array("where"=>' cid = "'.$nameStr[0].'"', 'asArray' => TRUE));
  2623. }elseif (!empty($nameStr[1]))
  2624. $clientInfo=$client->getOne(array("where"=>' clientname = "'.$nameStr[1].'"', 'asArray' => TRUE));
  2625. else
  2626. $clientInfo=array();
  2627. if(empty($clientInfo)){
  2628. echo json_encode(array("success"=>false,'html'=>''));die;
  2629. }
  2630. //获取锁
  2631. $longleInfo=$longle->getLongleByClientid($clientInfo['cid']);
  2632. $k="";
  2633. foreach ($longleInfo as $key=>$value){
  2634. if($value['status']==6||$value['status']==7)
  2635. $k.='<a href="javascript:void(0)" class="disenable" onclick="getLock('.$value['lid'].')" >'.$value['key_num'].'/'.$value['product'].'/'.$value['statusT'].'</a>&nbsp; ';
  2636. else
  2637. $k.='<a href="javascript:void(0)" onclick="getLock('.$value['lid'].')" >'.$value['key_num'].'/'.$value['product'].'/'.$value['statusT'].'</a>&nbsp; ';
  2638. }
  2639. //获取办事人
  2640. $staffInfo=$client_staff->getClientByCid($clientInfo['cid']);
  2641. $b="";
  2642. if(!empty($staffInfo))
  2643. $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>';
  2644. //获取公司信息
  2645. $companyInfo=$company->getCompanyByCid($clientInfo['companyid']);
  2646. $serviceLog=$service_log->getServiceByClientid($clientInfo['cid']);
  2647. $local=$district->getbyidlist($clientInfo['district']);
  2648. if(!isset($local[1]))
  2649. $local[1]['name']="";
  2650. if(!isset($local[2]))
  2651. $local[2]['name']="";
  2652. $m="";
  2653. if(!empty($companyInfo)){
  2654. $m='<div class="contactPanel">
  2655. <table>
  2656. <tbody>
  2657. <tr><th>单位全称</th><td colspan="3"><a href="javascript:void(0)" onclick="getCompany(\''.$companyInfo[0]['cid'].'\')">'.$companyInfo[0]['companyname'].'</a></td></tr>
  2658. <tr><th>单位主页</th><td colspan="3">'.$clientInfo['webservice'].'</td></tr>
  2659. <tr><th>客户地区</th><td>'.$local[0]['name'].','.$local[1]['name'].','.$local[2]['name'].'</td><th>部门/职位</th><td>'.$clientInfo['department'].'/'.$clientInfo['position'].'</td></tr>
  2660. <tr><th>客户传真</th><td>'.$clientInfo['fax'].'</td><th>办公室</th><td>'.$clientInfo['office'].'</td></tr>
  2661. <tr><th>客户地址</th><td colspan="3">'.$clientInfo['address'].'</td></tr>
  2662. <tr><th>客户乘车</th><td colspan="3">'.$clientInfo['ride'].'</td></tr>
  2663. <tr><th>客户地标</th><td colspan="3">'.$clientInfo['landmarks'].'</td></tr>
  2664. <tr><th>客户住宿</th><td colspan="3">'.$clientInfo['stay'].'</td></tr>
  2665. </tbody></table>
  2666. </div>';
  2667. }
  2668. $u="";
  2669. $order = array("\r\n", "\n", "\r");
  2670. $replace = '</br>';
  2671. foreach ($serviceLog as $key=>$value){
  2672. $datetime=explode("-", $value['date']);
  2673. $u.='<div class="infoFlowList">
  2674. <div class="dateTitle">
  2675. <em class="month"><span class="num">'.$datetime['1'].'</span><span class="text">-'.$datetime['2'].'</span></em>
  2676. <span class="year">'.$datetime['0'].'</span>
  2677. </div>
  2678. <ul class="flowList">';
  2679. if($value['status']==1)
  2680. $u.='<li class="item iconService">上门服务<';
  2681. elseif ($value['status']==2)
  2682. $u.='<li class="item iconPhone">电话拜访<';
  2683. elseif ($value['status']==3)
  2684. $u.='<li class="item iconOther">其他<';
  2685. $u.=$value['category'].'<a href="javascript:void(0)" onclick="getStaffInfo(\''.$value['staffname'].'\')" >'.$value['staffname'].'</a></li>
  2686. <li class="item">
  2687. '.str_replace($order, $replace, $value['mark']).'
  2688. </li>
  2689. </ul>
  2690. </div>';
  2691. }
  2692. Doo::loadModel("tag_client");
  2693. Doo::loadModel("tag");
  2694. $tag=new tag();
  2695. $tag_client=new tag_client();
  2696. $tagId=$tag_client->getTagClientBySCid($clientInfo['cid'], $this->staff[0]['sid']);
  2697. $taginfo=$tag->getTagByTidL($tagId['tag']);
  2698. $taghtml="";
  2699. foreach ($taginfo as $key=>$value){
  2700. $taghtml.='<span class="contactsTag tagCol-0'.$value['colorid'].'">'.$value['name'].'</span>';
  2701. }
  2702. $mhtml="";$dhtml="";$yhtml="";
  2703. for ($year=2020;$year>=2004;$year--){
  2704. if(date("Y")==$year)
  2705. $yhtml.='<option selected value="'.$year.'">'.$year.'年</option>';
  2706. else
  2707. $yhtml.='<option value="'.$year.'">'.$year.'年</option>';
  2708. }
  2709. for ($month=1;$month<=12;$month++){
  2710. if(date("m")==$month)
  2711. $mhtml.='<option selected value="'.$month.'">'.$month.'月</option>';
  2712. else
  2713. $mhtml.='<option value="'.$month.'">'.$month.'月</option>';
  2714. }
  2715. for ($day=1;$day<=31;$day++){
  2716. if(date("d")==$day)
  2717. $dhtml.='<option selected value="'.$day.'">'.$day.'日</option>';
  2718. else
  2719. $dhtml.='<option value="'.$day.'">'.$day.'日</option>';
  2720. }
  2721. $clientHtml=array('html'=>'<div class="contactInfo clearfix">
  2722. <div class="contactPanel">
  2723. <h1>'.$b.'<a data-original-title="编辑客户" data-toggle="ctooltip" data-placement="right" href="javascript:clientEdit('.$clientInfo['cid'].')" class="icon- edit">I</a></h1>
  2724. <table>
  2725. <tbody><tr><th>性别</th><td>'.$clientInfo['gender'].'</td><th>昵称</th><td>'.$clientInfo['nicename'].'</td></tr>
  2726. <tr><th>手机</th><td>'.$clientInfo['telephone'].'</td><th>QQ</th><td>'.$clientInfo['qq'].'</td></tr>
  2727. <tr><th>电话</th><td>'.$clientInfo['phone'].'</td><th>邮箱</th><td>'.$clientInfo['email'].'</td></tr>
  2728. <tr><th>软件锁</th><td colspan="3">'.$k.'</td></tr>
  2729. <tr><th>备注</th><td colspan="3">'.$clientInfo['mark'].'</td></tr>
  2730. <tr><td colspan="4">
  2731. '.$taghtml.'
  2732. </td></tr>
  2733. </tbody></table>
  2734. </div>
  2735. '.$m.'
  2736. </div>
  2737. <div class="lockRecord autoHeightR1" >
  2738. <!--添加记录按钮-->
  2739. <div class="addRecord addRecordButton clearfix" >
  2740. <a href="#" onclick="slideupInfo(this)">+ 打开添加服务记录</a>
  2741. </div>
  2742. <!--添加记录-->
  2743. <div class="addRecord addRecordForm clearfix hide">
  2744. <a onclick="slidedownInfo(this)" class="fR slidedownInfo">- 关闭添加记录</a>
  2745. <form name="lk" action="/addServiceLog" method="post" >
  2746. <div class="control-group">
  2747. <div class="controls">
  2748. <label class="radio inline">
  2749. <input type="radio" name="logstatus" id="status" checked value="2">电话拜访
  2750. </label>
  2751. <label class="radio inline">
  2752. <input type="radio" name="logstatus" id="status" value="1" >上门服务
  2753. </label>
  2754. <label class="radio inline">
  2755. <input type="radio" name="logstatus" id="status" value="3">其他
  2756. </label>
  2757. </div>
  2758. </div>
  2759. <div class="control-group">
  2760. <div class="controls">时间:
  2761. <select name="y" id="y">
  2762. '.$yhtml.'
  2763. </select>
  2764. <select name="m" id="m">
  2765. '.$mhtml.'
  2766. </select>
  2767. <select name="d" id="d">
  2768. '.$dhtml.'
  2769. </select>
  2770. </div>
  2771. </div>
  2772. <link href="'.WEB_SITE_GLOBAL.'css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
  2773. <!--添加记录-备注-->
  2774. <!--<div class="control-group">
  2775. <div class="controls">
  2776. <select name="date" id="date">
  2777. <option value="2013">2013</option>
  2778. </select>
  2779. </div>
  2780. </div>-->
  2781. <div class="control-group">
  2782. <div class="controls" onclick="slideupInfo()">
  2783. <textarea name="mark" id="mark" style="width:95%" rows="5"></textarea>
  2784. <div class="bsAlert bsWarning"><b>含泪告知:</b>客户记录暂时无法修改!删除!,添加时请谨慎。点击确定添加成功后,信息会立即出现在下方!注意咯,别猛戳‘确定添加’导致重复添加了哦~</div>
  2785. </div>
  2786. </div>
  2787. <div class="control-group">
  2788. <div class="controls">
  2789. <div style="display:inline-block;margin-right:10px"><label><input name="Remind" onclick="reFK()" type="checkbox" value="1"> 添加提醒</label></div>
  2790. <span id="reHL" class="hide">
  2791. <div>
  2792. 限期:<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">
  2793. <input type="hidden" name="time" id="dtp_input2" value="" class="hide"/>
  2794. </div>
  2795. <div>
  2796. 备注:<input id="remark" name="remark" type="text"></span>
  2797. </div>
  2798. </div>
  2799. <div class="control-group">
  2800. <div class="controls clearfix">
  2801. <input type="button" value="确定添加" id="conSer" onclick="aServiceLog(\''.$this->staff[0]['category'].'\',\''.$this->staff[0]['username'].'\','.$clientInfo['cid'].')" class="button"></input>
  2802. <div id="load"></div>
  2803. </div>
  2804. </div>
  2805. </div>
  2806. </form>
  2807. </div>
  2808. <!--添加记录按钮-->
  2809. <!--记录列表-->
  2810. <div id="kl"></div>
  2811. '.$u.'
  2812. <script type="text/javascript" src="'.WEB_SITE_GLOBAL.'js/bootstrap.min.js"></script>
  2813. <script type="text/javascript" src="'.WEB_SITE_GLOBAL.'js/bootstrap-datetimepicker.js" charset="UTF-8"></script>
  2814. <script type="text/javascript" src="'.WEB_SITE_GLOBAL.'js/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
  2815. <script type="text/javascript">
  2816. $(".form_date").datetimepicker({
  2817. language: "zh-CN",
  2818. weekStart: 1,
  2819. todayBtn: 1,
  2820. autoclose: 1,
  2821. todayHighlight: 1,
  2822. startView: 2,
  2823. minView: 2,
  2824. forceParse: 0,
  2825. startDate: "'.date('Y-m-d').'"
  2826. });
  2827. </script>
  2828. <script type="text/javascript">autoFlashHeight();</script> </div>');
  2829. echo json_encode($clientHtml);
  2830. }
  2831. function ajaxGetCompanyInfo(){
  2832. }
  2833. function checkClient(){
  2834. $searchDbInforItem=isset($_POST['name'])?$_POST['name']:"";
  2835. $searchDbInforItem=explode('-', $searchDbInforItem);
  2836. if(!empty($searchDbInforItem)){
  2837. Doo::loadModel ( 'client' );
  2838. $client = new client();
  2839. $clientInfo=$client->getClientByName2($searchDbInforItem[0],$searchDbInforItem[1]);
  2840. if(!empty($clientInfo))
  2841. echo json_encode(array("success"=>true));
  2842. else
  2843. echo json_encode(array("success"=>false));
  2844. }else{
  2845. echo json_encode(array("success"=>false));
  2846. }
  2847. }
  2848. function searchClient(){
  2849. $searchDbInforItem=isset($_GET['searchDbInforItem'])?$_GET['searchDbInforItem']:"";
  2850. if(!empty($searchDbInforItem)){
  2851. Doo::loadModel ( 'client' );
  2852. $client = new client();
  2853. $clientInfo=$client->getClientByName($searchDbInforItem);
  2854. echo json_encode($clientInfo);
  2855. }else{
  2856. echo json_encode(array(0=>array('clientname'=>'')));
  2857. }
  2858. }
  2859. function searchCompany(){
  2860. $searchDbInforItem=isset($_GET['searchDbInforItem'])?$_GET['searchDbInforItem']:"";
  2861. if(!empty($searchDbInforItem)){
  2862. Doo::loadModel ( 'company' );
  2863. $company = new company();
  2864. $clientInfo=$company->searchCompany($searchDbInforItem);
  2865. echo json_encode($clientInfo);
  2866. }else{
  2867. echo json_encode(array(0=>array('companyname'=>'','local'=>'')));
  2868. }
  2869. }
  2870. function checkCompany(){
  2871. $searchDbInforItem=isset($_POST['name'])?$_POST['name']:"";
  2872. $searchDbInforItem=explode('-', $searchDbInforItem);
  2873. $this->nature['naturelenght']=15;
  2874. Doo::loadModel ( 'district' );
  2875. $district = new district ();
  2876. $d=$district->get_lv(1);
  2877. $html='<option vlaue="0">请选择</option>';
  2878. foreach ($d as $key=>$value){
  2879. $html.='<option value="'.$value['id'].'">'.$value['name'].'</option>';
  2880. }
  2881. $this->nature['district']=$html;
  2882. if(!empty($searchDbInforItem)){
  2883. Doo::loadModel ( 'company' );
  2884. $company = new company();
  2885. if(!isset($searchDbInforItem[1])){
  2886. echo json_encode(array("success"=>false,'nature'=>$this->nature));die;
  2887. }
  2888. $clientInfo=$company->getCompanyByName($searchDbInforItem[0],$searchDbInforItem[1]);
  2889. if(!empty($clientInfo))
  2890. echo json_encode(array("success"=>true,'data'=>$clientInfo));
  2891. else
  2892. echo json_encode(array("success"=>false,'nature'=>$this->nature));
  2893. }else{
  2894. echo json_encode(array("success"=>false,'nature'=>$this->nature));
  2895. }
  2896. }
  2897. function checkLongle(){
  2898. $searchDbInforItem=isset($_POST['name'])?$_POST['name']:"";
  2899. $searchDbInforItem=explode(' ', $searchDbInforItem);
  2900. if(!empty($searchDbInforItem)){
  2901. Doo::loadModel ( 'longle' );
  2902. $longle = new longle();
  2903. $clientInfo=$longle->getLongleBykeynum($searchDbInforItem[0]);
  2904. if(!empty($clientInfo))
  2905. echo json_encode(array("success"=>true));
  2906. else
  2907. echo json_encode(array("success"=>false));
  2908. }else{
  2909. echo json_encode(array("success"=>false));
  2910. }
  2911. }
  2912. function searchLongle(){
  2913. $searchDbInforItem=isset($_GET['searchDbInforItem'])?$_GET['searchDbInforItem']:"";
  2914. if(!empty($searchDbInforItem)){
  2915. Doo::loadModel ( 'longle' );
  2916. $longle = new longle();
  2917. $longleInfo=$longle->getLongleBykeynum2($searchDbInforItem);
  2918. echo json_encode($longleInfo);
  2919. }else{
  2920. echo json_encode(array(0=>array('clientname'=>'')));
  2921. }
  2922. }
  2923. function updateChangeCompany(){
  2924. $cid=isset($_POST['cid'])?$_POST['cid']:0;
  2925. $clientID=isset($_POST['clientID'])?$_POST['clientID']:0;
  2926. $companyname=isset($_POST['companyname'])?$_POST['companyname']:"";
  2927. Doo::loadModel ( 'company' );
  2928. Doo::loadModel ( 'client' );
  2929. $client = new client();
  2930. $company = new company();
  2931. $companyname=explode("-", $companyname);
  2932. if(isset($companyname[1]))
  2933. $k=$company->getCompanyByName($companyname[0], $companyname[1]);
  2934. else
  2935. $k=array();
  2936. if(!empty($cid)&&!empty($k)&&!empty($clientID)){
  2937. $client->cid=$clientID;
  2938. $client->companyid=$cid;
  2939. $client->companyname=$companyname[0];
  2940. $client->update();
  2941. }else{
  2942. $local1=isset($_POST['lv21'])?$_POST['lv21']:0;
  2943. $local2=isset($_POST['lv22'])?$_POST['lv22']:0;
  2944. $local3=isset($_POST['lv23'])?$_POST['lv23']:0;
  2945. Doo::loadModel ( 'district' );
  2946. $district = new district ();
  2947. //更新公司信息
  2948. $lv1=$district->getbyid($local1);
  2949. $lv2=$district->getbyid($local2);
  2950. $lv3=$district->getbyid($local3);
  2951. if(empty($local1)||empty($local2))
  2952. return "/";
  2953. if(!empty($local1)&&!empty($local2))
  2954. $company->local=$lv1[0]['name'].",".$lv2[0]['name'].",".$lv3[0]['name'];
  2955. if(!empty($local1)&&!empty($local2))
  2956. $company->district=$local1.",".$local2.",".$local3;
  2957. $nature=isset($_POST['nature'])?$_POST['nature']:"";
  2958. $fax=isset($_POST['fax'])?$_POST['fax']:"";
  2959. $webservice=isset($_POST['webservice'])?$_POST['webservice']:"";
  2960. $address=isset($_POST['address'])?$_POST['address']:"";
  2961. $landmarks=isset($_POST['landmarks'])?$_POST['landmarks']:"";
  2962. $stay=isset($_POST['stay'])?$_POST['stay']:"";
  2963. $ride=isset($_POST['ride'])?$_POST['ride']:"";
  2964. $nature=implode(",", $nature);
  2965. $company->companyname=$companyname[0];
  2966. $company->ride=$ride;
  2967. $company->fax=$fax;
  2968. $company->webservice=$webservice;
  2969. $company->address=$address;
  2970. $company->landmarks=$landmarks;
  2971. $company->stay=$stay;
  2972. $company->nature=$nature;
  2973. $cid=$company->insert();
  2974. $client->cid=$clientID;
  2975. $client->companyid=$cid;
  2976. $client->companyname=$companyname[0];
  2977. $client->update();
  2978. }
  2979. return "/";
  2980. }
  2981. function AddClientInfo(){//不编辑公司
  2982. $cid=isset($_POST['cid'])?$_POST['cid']:0;
  2983. $clientname=isset($_POST['clientname'])?$_POST['clientname']:"";
  2984. $gender=isset($_POST['gender'])?$_POST['gender']:"";
  2985. $nicename=isset($_POST['nicename'])?$_POST['nicename']:"";
  2986. $telephone=isset($_POST['telephone'])?$_POST['telephone']:"";
  2987. $phone=isset($_POST['phone'])?$_POST['phone']:"";
  2988. $email=isset($_POST['email'])?$_POST['email']:"";
  2989. $unit=isset($_POST['unit'])?$_POST['unit']:"";
  2990. $fax=isset($_POST['fax'])?$_POST['fax']:"";
  2991. $webservice=isset($_POST['webservice'])?$_POST['webservice']:"";
  2992. $department=isset($_POST['department'])?$_POST['department']:"";
  2993. $position=isset($_POST['position'])?$_POST['position']:"";
  2994. $office=isset($_POST['office'])?$_POST['office']:"";
  2995. $address=isset($_POST['address'])?$_POST['address']:"";
  2996. $ride=isset($_POST['ride'])?$_POST['ride']:"";
  2997. $landmarks=isset($_POST['landmarks'])?$_POST['landmarks']:"";
  2998. $qq=isset($_POST['qq'])?$_POST['qq']:"";
  2999. $priority=isset($_POST['priority'])?$_POST['priority']:5;
  3000. $stay=isset($_POST['stay'])?$_POST['stay']:"";
  3001. $mark=isset($_POST['mark'])?$_POST['mark']:"";
  3002. $lv21=isset($_POST['lv21'])?$_POST['lv21']:0;
  3003. $lv22=isset($_POST['lv22'])?$_POST['lv22']:0;
  3004. $lv23=isset($_POST['lv23'])?$_POST['lv23']:0;
  3005. if(!empty($cid)&&!empty($clientname)){
  3006. Doo::loadModel ( 'client' );
  3007. Doo::loadModel('district');
  3008. $district=new district();
  3009. $client = new client();
  3010. $client->cid=$cid;
  3011. $client->clientname=$clientname;
  3012. $client->gender=$gender;
  3013. $client->nicename=$nicename;
  3014. $client->telephone=$telephone;
  3015. $client->phone=$phone;
  3016. $client->email=$email;
  3017. // if(!empty($unit)){
  3018. // $client->unit=$unit;
  3019. // $client->companyname=$unit;
  3020. // }
  3021. if(!empty($lv21)&&!empty($lv22)&&!empty($lv23)){
  3022. $client->district=$lv21.",".$lv22.",".$lv23;
  3023. }
  3024. if(!empty($client->district)){
  3025. $districtList=$district->find(array('where'=>'id in('.$client->district.')','asArray'=>true));
  3026. $jsonString=array();
  3027. foreach ($districtList as $value){
  3028. array_push($jsonString, $value['name']);
  3029. }
  3030. $jsonString=implode(",", $jsonString);
  3031. if (!empty($jsonString))
  3032. $client->local=$jsonString;
  3033. }
  3034. $client->fax=$fax;
  3035. $client->webservice=$webservice;
  3036. $client->department=$department;
  3037. $client->position=$position;
  3038. $client->office=$office;
  3039. $client->address=$address;
  3040. $client->ride=$ride;
  3041. $client->landmarks=$landmarks;
  3042. $client->qq=$qq;
  3043. $client->stay=$stay;
  3044. $client->priority=$priority;
  3045. $client->mark=$mark;
  3046. $client->updatetime=time();
  3047. $client->update();
  3048. // Doo::loadModel ( 'company' );
  3049. // $company = new company();
  3050. // $companyid=$client->getOne(array('where'=>' cid='.$cid,'asArray'=>true));
  3051. // $company->office=$office;
  3052. // $company->fax=$fax;
  3053. // $company->address=$address;
  3054. // $company->ride=$ride;
  3055. // $company->landmarks=$landmarks;
  3056. // $company->cid=$companyid['companyid'];
  3057. // if(!empty($unit)){
  3058. // $company->companyname=$unit;
  3059. // }
  3060. // $company->update();
  3061. $clientInfo=$client->getOne(array('where'=>' cid='.$cid,'asArray'=>true));
  3062. //日常行为
  3063. Doo::loadModel("action_log");
  3064. $action_log=new action_log();
  3065. $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'].')';
  3066. $action_log->sid=$this->staff[0]['sid'];
  3067. $action_log->cid=$this->staff[0]['cid'];
  3068. $action_log->updatetime=date("Y-m-d");
  3069. $action_log->time=date("H:i");
  3070. $action_log->class=$action_log->iconContacts;
  3071. $action_log->status=2;
  3072. $action_log->districtid=$clientInfo['district'];
  3073. $local=$district->getbyidlist($clientInfo['district']);
  3074. $action_log->city=$local[0]['name'];
  3075. $action_log->province=$local[1]['name'];
  3076. $action_log->company=$clientInfo['companyname'];
  3077. Doo::loadModel('company');
  3078. $company=new company();
  3079. $companyInfo=$company->getOne(array('where'=>' companyname="'.$clientInfo['companyname'].'"','asArray'=>true));
  3080. $nature=explode(',', $companyInfo['nature']);
  3081. $action_log->nature=$nature[0];
  3082. $action_log->insert();
  3083. echo json_encode(array("success"=>true));die;
  3084. }else
  3085. echo json_encode(array("success"=>false));die;
  3086. }
  3087. function ajaxClientInfo(){
  3088. $cid=isset($_POST['cid'])?$_POST['cid']:0;
  3089. if(!empty($cid)){
  3090. Doo::loadModel ( 'client' );
  3091. Doo::loadModel('company');
  3092. Doo::loadModel('district');
  3093. $district = new district();
  3094. $company = new company();
  3095. $client = new client();
  3096. $info=$client->getOne(array('where'=>' cid='.$cid,'asArray'=>true));
  3097. $cinfo=$company->getOne(array('where'=>' cid='.$info['companyid'],'asArray'=>true));
  3098. $districtLv1=$district->get_lv(1);
  3099. $info['districtList']=$district->getbyidlist($info['district']);
  3100. $optionHtml='<option vlaue="0">请选择</option>';
  3101. foreach ($districtLv1 as $key=>$value){
  3102. if($value['name']==$info['districtList'][0]['name'])
  3103. $optionHtml.='<option selected value="'.$value['id'].'">'.$value['name'].'</option>';
  3104. else
  3105. $optionHtml.='<option value="'.$value['id'].'">'.$value['name'].'</option>';
  3106. }
  3107. $info['districtLv1']=$optionHtml;
  3108. $info['companyInfo']=$cinfo;
  3109. echo json_encode(array("success"=>true,'html'=>$info));die;
  3110. }else
  3111. echo json_encode(array("success"=>false,'html'=>''));die;
  3112. }
  3113. function ajaxAddServiceLog(){
  3114. $status=isset($_POST['status'])?$_POST['status']:"";
  3115. $clientid=isset($_POST['cid'])?$_POST['cid']:"";
  3116. $mark=isset($_POST['mark'])?$_POST['mark']:"";
  3117. $m=isset($_POST['m'])?$_POST['m']:"";
  3118. $d=isset($_POST['d'])?$_POST['d']:"";
  3119. $y=isset($_POST['y'])?$_POST['y']:date("Y");
  3120. $Remind=isset($_POST['Remind'])?$_POST['Remind']:0;
  3121. $time=isset($_POST['time'])?$_POST['time']:0;
  3122. $remark=isset($_POST['remark'])?$_POST['remark']:"";
  3123. if(!empty($status)&&!empty($clientid)){
  3124. Doo::loadModel ( 'service_log' );
  3125. Doo::loadModel ( 'client_staff' );
  3126. Doo::loadModel ( 'client' );
  3127. Doo::loadModel('district');
  3128. $district=new district();
  3129. $client = new client();
  3130. $clientStaff=new client_staff();
  3131. $service_log = new service_log();
  3132. $service_log->status=$status;
  3133. $service_log->clientid=$clientid;
  3134. $service_log->mark=htmlspecialchars($mark);
  3135. $service_log->date=$y."-".$m."-".$d;
  3136. $service_log->category=$this->staff[0]['category'];
  3137. $service_log->staffname=$this->staff[0]['username'];
  3138. $service_log->staffid=$this->staff[0]['sid'];
  3139. $service_log->insert();
  3140. //日常行为
  3141. Doo::loadModel("action_log");
  3142. Doo::loadModel("client");
  3143. $client=new client();
  3144. //记录服务时间
  3145. $client->cid=$clientid;
  3146. $client->servicetime=time();
  3147. $client->update();
  3148. $action_log=new action_log();
  3149. $clientInfo=$client->getOne(array('where'=>' cid='.$clientid,'asArray' => TRUE));
  3150. $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'].')添加新客户记录。';
  3151. $action_log->sid=$this->staff[0]['sid'];
  3152. $action_log->cid=$this->staff[0]['cid'];
  3153. $action_log->updatetime=date("Y-m-d");
  3154. $action_log->time=date("H:i");
  3155. $action_log->status=3;
  3156. $action_log->districtid=$clientInfo['district'];
  3157. $local=$district->getbyidlist($clientInfo['district']);
  3158. $action_log->city=$local[0]['name'];
  3159. $action_log->province=$local[1]['name'];
  3160. $action_log->company=$clientInfo['companyname'];
  3161. Doo::loadModel('company');
  3162. $company=new company();
  3163. $companyInfo=$company->getOne(array('where'=>' companyname="'.$clientInfo['companyname'].'"','asArray'=>true));
  3164. $nature=explode(',', $companyInfo['nature']);
  3165. $action_log->nature=$nature[0];
  3166. $action_log->class=$action_log->iconContacts;
  3167. $action_log->insert();
  3168. if (!empty($Remind)){
  3169. Doo::loadModel('remind');
  3170. $remindObj=new remind();
  3171. $datetime1 = new DateTime(date('Y-m-d'));
  3172. $datetime2 = new DateTime($time);
  3173. $interval = $datetime1->diff($datetime2);
  3174. $remindObj->day=$interval->format('%a');
  3175. $remindObj->remark=$remark;
  3176. $remindObj->time=date("Y-m-d");
  3177. $remindObj->clientName=$clientInfo['clientname'];
  3178. $remindObj->clientID=$clientid;
  3179. $remindObj->companyName=$clientInfo['companyname'];
  3180. $remindObj->companyID=$companyInfo['cid'];
  3181. $remindObj->staffID=$this->staff[0]['sid'];
  3182. if ($status==1)
  3183. $remindObj->class="iconService";
  3184. if ($status==2)
  3185. $remindObj->class="iconPhone";
  3186. if ($status==3)
  3187. $remindObj->class="iconOther";
  3188. $remindObj->insert();
  3189. }
  3190. echo json_encode(array("success"=>true,'html'=>''));die;
  3191. }else
  3192. echo json_encode(array("success"=>false,'html'=>''));die;
  3193. }
  3194. function _getLongleLogHtml($longleLog=array()){
  3195. $html="";
  3196. foreach ($longleLog as $key=>$value){
  3197. $dateline=explode("-", $value['dateline']);
  3198. $html.='<div class="infoFlowList">
  3199. <div class="dateTitle">
  3200. <em class="month"><span class="num">'.$dateline[1].'</span><span class="text">-'.$dateline[2].'</span></em>
  3201. <span class="year">'.$dateline[0].'</span>
  3202. </div>
  3203. ';
  3204. //备注
  3205. if($value['status']==8){
  3206. $html.='
  3207. <ul class="flowList">
  3208. <li class="item iconLock">备注<'.$value['category'].'<a href="javascript:void(0);" onclick="getStaffInfo(\''.$value['operator'].'\')" >'.$value['operator'].'</a></li>
  3209. <li class="item">'.$value['mark'].'</li>
  3210. </ul>';
  3211. //生成
  3212. }elseif($value['status']==1){
  3213. $html.='<ul class="flowList">
  3214. <li class="item iconGenerate">生成<'.$value['category'].'<a href="javascript:void(0);" onclick="getStaffInfo(\''.$value['operator'].'\')" >'.$value['operator'].'</a></li>
  3215. </ul>';
  3216. //接收
  3217. }elseif($value['status']==2){
  3218. $html.='<ul class="flowList">
  3219. <li class="item iconReceive">接收<'.$value['category'].'<a href="javascript:void(0);" onclick="getStaffInfo(\''.$value['operator'].'\')" >'.$value['operator'].'</a></li>
  3220. </ul>';
  3221. //借出
  3222. }elseif($value['status']==3){
  3223. $html.='<ul class="flowList">
  3224. <li class="item iconBorrow">借出<'.$value['category'].'<a href="javascript:void(0);" onclick="getStaffInfo(\''.$value['operator'].'\')" >'.$value['operator'].'</a></li>
  3225. <li class="item">'.$value['product'].'</li>
  3226. <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\''.$value['clientid'].",".$value['client'].'\')" >'.$value['client'].'</a></li>
  3227. </ul>';
  3228. //销售
  3229. }elseif($value['status']==4){
  3230. $html.='<ul class="flowList">
  3231. <li class="item iconSell">销售<'.$value['category'].'<a href="javascript:void(0);" onclick="getStaffInfo(\''.$value['operator'].'\')" >'.$value['operator'].'</a></li>
  3232. <li class="item">'.$value['product'].'</li>
  3233. <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\''.$value['clientid'].",".$value['client'].'\')" >'.$value['client'].'</a></li>
  3234. </ul>';
  3235. //升级
  3236. }elseif($value['status']==5){
  3237. $html.='<ul class="flowList">
  3238. <li class="item iconUpdate">升级<'.$value['category'].'<a href="javascript:void(0);" onclick="getStaffInfo(\''.$value['operator'].'\')" >'.$value['operator'].'</a></li>
  3239. <li class="item">'.$value['product'].'</li>
  3240. <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\''.$value['clientid'].",".$value['client'].'\')" >'.$value['client'].'</a></li>
  3241. </ul>';
  3242. //更换
  3243. }elseif($value['status']==6){
  3244. $html.='<ul class="flowList">
  3245. <li class="item iconReplace">更换<'.$value['category'].'<a href="javascript:void(0);" onclick="getStaffInfo(\''.$value['operator'].'\')">'.$value['operator'].'</a></li>
  3246. <li class="item"><a href="javascript:void(0);" onclick="getLockByName(\''.$value['new_key_num'].'\')">'.$value['new_key_num'].'</a>
  3247. <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\''.$value['clientid'].",".$value['client'].'\')" >'.$value['client'].'</a></li>
  3248. </ul>';
  3249. //回收
  3250. }elseif($value['status']==7){
  3251. Doo::loadModel ( 'staff' );
  3252. $staff = new staff ();
  3253. $staffinfo=$staff->getOne(array('where'=>' username like "'.$value['responsible'].'"','asArray'=>true));
  3254. if (empty($staffinfo))
  3255. $staffinfo['category']="";
  3256. $html.='<ul class="flowList">
  3257. <li class="item iconRecycle">收回<'.$value['category'].'<a href="javascript:void(0);" onclick="getStaffInfo(\''.$value['operator'].'\')">'.$value['operator'].'</a></li>
  3258. <li class="item">'.$staffinfo['category'].'<a href="javascript:void(0);" id="ajaxStaff" data="'.$value['responsible'].'">'.$value['responsible'].'</a></li>
  3259. </ul>';
  3260. }elseif($value['status']==9){
  3261. $html.='<ul class="flowList">
  3262. <li class="item iconGif">赠送 &lt; '.$value['category'].'<a href="javascript:void(0);" onclick="getStaffInfo(\''.$value['operator'].'\')">'.$value['operator'].'</a></li>
  3263. <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\''.$value['clientid'].",".$value['client'].'\')" >'.$value['client'].'</a></li>
  3264. </ul>';
  3265. }
  3266. $html.='</div>';
  3267. }
  3268. return $html;
  3269. }
  3270. function adminLock(){
  3271. $emsg=isset($this->params['emsg'])?$this->params['emsg']:"";
  3272. $data['emsg']="";
  3273. if($emsg!="")
  3274. $data['emsg']="请填写完整的数据";
  3275. $data['memu']="keyonline";
  3276. $data['staff']=$this->staff;
  3277. if($this->staff[0]['isadmin']!=1)
  3278. return "/adminmyinfo";
  3279. Doo::loadModel ( 'L_category' );
  3280. $L_category = new L_category ();
  3281. $data['category']=$L_category->getCategory();
  3282. $data['time']=time();
  3283. $this->render ( "/admin/admin_addlock", $data );
  3284. }
  3285. function adminAddLock(){
  3286. $cid=isset($_POST['cid'])?$_POST['cid']:0;
  3287. $path=isset($_POST['path'])?$_POST['path']:"";
  3288. if($cid!=0&&$path!=""){
  3289. Doo::loadModel ( 'longle' );
  3290. Doo::loadModel ( 'L_category' );
  3291. $L_category = new L_category ();
  3292. Doo::loadModel ( 'longle_log' );
  3293. $exlArray=$this->_format_excel_to_array(DOO::conf()->SITE_PATH."upload/".iconv("UTF-8", "GB2312", $path));
  3294. //print_r($exlArray);die;
  3295. //echo json_encode($exlArray);die;
  3296. $category=$L_category->getCategoryById($cid);
  3297. foreach ($exlArray as $key=>$value){
  3298. //锁记录
  3299. $longle = new longle ();
  3300. $longle->key_num=str_replace("'","",$value['key_num']);
  3301. $longle->product=str_replace("'","",$value['product']);
  3302. $longle->make_day=$value['make_day'];
  3303. $longle->alloted_time=$value['alloted_time'];
  3304. $longle->status=1;
  3305. $longle->statusT="生成";
  3306. $longle->cid=$cid;
  3307. $longle->category=$category[0]['title'];
  3308. $longle->SerialNumber=$value['SerialNumber'];
  3309. $longle->version=$value['version'];
  3310. $lid=$longle->insert();
  3311. //锁日志记录
  3312. $longle_log=new longle_log();
  3313. $longle_log->lid=$lid;
  3314. $longle_log->status=1;
  3315. $longle_log->statusT="生成";
  3316. $longle_log->operator=$this->staff[0]['username'];
  3317. $longle_log->product=$longle->product;
  3318. $longle_log->category=$this->staff[0]['category'];
  3319. $longle_log->dateline=date("Y-m-d");
  3320. $id=$longle_log->insert();
  3321. }
  3322. //记录日常行为
  3323. Doo::loadModel("action_log");
  3324. $action_log=new action_log();
  3325. $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>个锁';
  3326. $action_log->sid=$this->staff[0]['sid'];
  3327. $action_log->cid=$this->staff[0]['cid'];
  3328. $action_log->class=$action_log->iconGenerate;
  3329. $action_log->updatetime=date("Y-m-d");
  3330. $action_log->time=date("H:i");
  3331. $action_log->status=11;
  3332. $action_log->insert();
  3333. return "/keyonline";
  3334. }else
  3335. return "/adminlock/error";
  3336. }
  3337. function avatarCM(){
  3338. $vid=isset($this->params['vid'])?$this->params['vid']:0;
  3339. if(!empty($vid)){
  3340. Doo::loadModel("verify");
  3341. $verify=new verify();
  3342. Doo::loadModel('staff');
  3343. $staff=new staff();
  3344. $list=$verify->getOne(array('where'=>'vid='.$vid,'asArray'=>true));
  3345. if (empty($list))
  3346. return "/adminverify";
  3347. $avatar=json_decode($list['staff']);
  3348. foreach ($avatar as $key=>$value){
  3349. $uinfo=$staff->getOne(array('where'=>'sid='.$value[0],'asArray'=>true));
  3350. $avatar[$key]['2']=$uinfo['avatar'];
  3351. }
  3352. $verify->staff=json_encode($avatar);
  3353. $verify->update(array('where'=>'vid='.$vid));
  3354. }
  3355. return "/adminverify";
  3356. }
  3357. function adminmyinfo(){
  3358. $data['memu']="adminmyinfo";
  3359. $data['staff']=$this->staff;
  3360. $birArray=explode('-', $this->staff[0]['birthday']);
  3361. $data['year']=$birArray[0];
  3362. $year=date('Y');$yearHtml="";
  3363. for (;$year>=1900;$year--){
  3364. $yearHtml.='<option ';
  3365. if ($data['year']==$year)
  3366. $yearHtml.='selected';
  3367. $yearHtml.=' value="'.$year.'">'.$year.'</option>';
  3368. }
  3369. $data['yearHtml']=$yearHtml;
  3370. $data['month']=01;
  3371. $data['day']=01;
  3372. if(isset($birArray[1])){
  3373. $data['month']=$birArray[1];
  3374. $data['day']=$birArray[2];
  3375. }
  3376. $data['msg']=urldecode($this->params['msg']);
  3377. $this->render ( "/admin/admin_myinfo", $data );
  3378. }
  3379. function updateMyinfo(){
  3380. $telephone=$this->get_args('telephone')?$_POST['telephone']:0;
  3381. $phone=$this->get_args('phone')?$_POST['phone']:0;
  3382. $email=isset($_POST['email'])?$_POST['email']:"";
  3383. $qq=is_numeric($this->get_args('qq'))?$_POST['qq']:0;
  3384. $year=$this->get_args('year')?$_POST['year']:date("Y");
  3385. $month=$this->get_args('month')?$_POST['month']:"";
  3386. $day=$this->get_args('day')?$_POST['day']:"";
  3387. $position=$this->get_args('position')?$_POST['position']:"";
  3388. $gender=$this->get_args('gender')?$_POST['gender']:"男";
  3389. $oldpassword=isset($_POST['oldpassword'])?$_POST['oldpassword']:"";
  3390. $newpassword=isset($_POST['newpassword'])?$_POST['newpassword']:"";
  3391. $rnewpassword=isset($_POST['rnewpassword'])?$_POST['rnewpassword']:"";
  3392. Doo::loadModel ( 'staff' );
  3393. $staff = new staff ();
  3394. Doo::loadModel ( 'staffDynamic' );
  3395. $staffDynamic=new staffDynamic();
  3396. $staff->sid=$this->staff[0]['sid'];
  3397. $content="";$ext="更新了他的";
  3398. if($telephone!=0&&$this->staff[0]['telephone']!=$telephone){
  3399. $staff->telephone=$telephone;
  3400. $content.="<b>手机</b>&nbsp;";
  3401. }
  3402. if($phone!=0&&$this->staff[0]['phone']!=$phone){
  3403. $staff->phone=$phone;
  3404. $content.="<b>电话</b>&nbsp;";
  3405. }
  3406. if($qq!=0&&$this->staff[0]['qq']!=$qq){
  3407. $staff->qq=$qq;
  3408. $content.="<b>QQ</b>&nbsp;";
  3409. }
  3410. if($year!=2014){
  3411. $staff->birthday=$year."-".$month."-".$day;
  3412. $content.="<b>生日</b>&nbsp;";
  3413. }
  3414. if($email!=""&&filter_var($email, FILTER_VALIDATE_EMAIL)&&$this->staff[0]['email']!=$email){
  3415. $staff->email=$email;
  3416. $content.="<b>邮箱</b>&nbsp;";
  3417. }
  3418. if (!empty($position)){
  3419. $staff->position=$position;
  3420. $content.="<b>职位</b>&nbsp;";
  3421. }
  3422. $staff->gender=$gender;
  3423. $msg="更新成功";
  3424. if($this->staff[0]['passwork']==md5($oldpassword)){
  3425. if($newpassword==$rnewpassword&&(!empty($newpassword)))
  3426. $staff->passwork=md5($newpassword);
  3427. else
  3428. $msg="密码不一致";
  3429. }else{
  3430. if($oldpassword!="")
  3431. $msg="密码错误";
  3432. }
  3433. if (!empty($content)){
  3434. $staffDynamic->content=$ext.$content;
  3435. $staffDynamic->cid=$this->staff[0]['cid'];
  3436. $staffDynamic->category=$this->staff[0]['category'];
  3437. $staffDynamic->time=time();
  3438. $staffDynamic->sid=$this->staff[0]['sid'];
  3439. $staffDynamic->staff=$this->staff[0]['username'];
  3440. $staffDynamic->insert();
  3441. }
  3442. $staff->update(array('where'=>' sid='.$this->staff[0]['sid']));
  3443. return "/adminmyinfo/".$msg;
  3444. }
  3445. function admincontacts(){
  3446. $data['memu']="admincontacts";
  3447. $data['staff']=$this->staff;
  3448. Doo::loadModel ( 'L_category' );
  3449. Doo::loadModel ( 'staff' );
  3450. $staff = new staff ();
  3451. $L_category = new L_category ();
  3452. $this->render ( "/admin/admin_addContacts", $data );
  3453. }
  3454. function eMailTask(){
  3455. Doo::loadModel('tag');
  3456. $tag=new tag();
  3457. Doo::loadModel('district');
  3458. $district= new district();
  3459. $tagList=$tag->getAllBySid($this->staff[0]['sid']);
  3460. $districtList=$district->get_lv(1);
  3461. $data['tagList']=$tagList;
  3462. $data['districtList']=$districtList;
  3463. $data['memu']="eMailTask";
  3464. $data['staff']=$this->staff;
  3465. $data['mailMemu']='eMailTask';
  3466. $data['nature']=$this->nature;
  3467. $this->render ( "/mail_create", $data );
  3468. }
  3469. function eMialCenter(){
  3470. $year=$this->get_args('year')?$this->get_args('year'):date("Y");
  3471. $month=$this->get_args('month')?$this->get_args('month'):0;
  3472. Doo::loadModel('eMailList');
  3473. $eMailList=new eMailList();
  3474. Doo::loadModel('tag');
  3475. $tag=new tag();
  3476. Doo::loadModel ( 'staff' );
  3477. $staff = new staff ();
  3478. $dateCondition="status!=2 and Year(date) =".$year;
  3479. if(!empty($month))
  3480. $dateCondition="Year(date) =".$year." and Month(date) = ".$month;
  3481. $mailList=$eMailList->find(array('where'=>$dateCondition,'asc'=>'status','desc'=>'elid','asArray'=>true));
  3482. foreach ($mailList as $key=>$value){
  3483. $mailList[$key]['clientName2']=$mailList[$key]['clientName3']=array();
  3484. $mailList[$key]['clientName']=json_decode(gzuncompress(base64_decode($value['clientName'])),true);
  3485. if(!empty($value['clientName2']))
  3486. $mailList[$key]['clientName2']=json_decode(gzuncompress(base64_decode($value['clientName2'])),true);
  3487. if(!empty($value['clientName3']))
  3488. $mailList[$key]['clientName3']=json_decode(gzuncompress(base64_decode($value['clientName3'])),true);
  3489. $mailList[$key]['illegalEmail']=json_decode($value['illegalEmail'],true);
  3490. $mailList[$key]['sendEmail']=json_decode($value['sendEmail'],true);
  3491. $mailList[$key]['clientCount']=count($mailList[$key]['clientName'])+count($mailList[$key]['clientName2'])+count($mailList[$key]['clientName3']);
  3492. $mailList[$key]['tag']=array();
  3493. $kks=$staff->getOne(array('where'=>'username like "'.$value['staffName'].'"','asArray'=>true));
  3494. $mailList[$key]['category']=$kks['category'];
  3495. if (!empty($value['tag']))
  3496. $mailList[$key]['tag']=$tag->find(array('where'=>'tid in ( '.$value['tag'].') ','asArray'=>true));
  3497. }
  3498. $dateHtml="";$now=date("Y");
  3499. for ($YEARD=2014;$YEARD<=2050;$YEARD++){
  3500. if ($YEARD<=$now){
  3501. $dateHtml.='<option ';
  3502. if ($year==$YEARD )
  3503. $dateHtml.=' selected ';
  3504. $dateHtml.=' value="'.$YEARD.'">'.$YEARD.'</option>';
  3505. }
  3506. }
  3507. $monthHtml='<option value="0">所有月份</option>';
  3508. for ($i=1;$i<=12;$i++){
  3509. $monthHtml.='<option ';
  3510. if ($i==$month )
  3511. $monthHtml.=' selected ';
  3512. $monthHtml.=' value="'.$i.'">'.$i.'</option>';
  3513. }
  3514. $data['monthHtml']=$monthHtml;
  3515. $data['dateHtml']=$dateHtml;
  3516. $data['mailList']=$mailList;
  3517. $data['memu']="eMailTask";
  3518. $data['staff']=$this->staff;
  3519. $data['mailMemu']='eMialCenter';
  3520. $data['nature']=$this->nature;
  3521. $this->render ( "/mailCenter", $data );
  3522. }
  3523. function authMail(){
  3524. $elid=isset($this->params['elid'])?$this->params['elid']:0;
  3525. if (!empty($elid)){
  3526. Doo::loadModel('eMailList');
  3527. $eMailList=new eMailList();
  3528. $eMailList->examine=2;
  3529. $eMailList->mark=$this->staff[0]['username']."已同意";
  3530. $eMailList->update(array('where'=>'elid='.$elid,'asArray'=>true));
  3531. }
  3532. return '/eMialCenter';
  3533. }
  3534. function editMailView(){
  3535. $elid=isset($this->params['elid'])?$this->params['elid']:0;
  3536. Doo::loadModel('tag');
  3537. $tag=new tag();
  3538. Doo::loadModel('district');
  3539. $district= new district();
  3540. Doo::loadModel('eMailList');
  3541. $eMList=new eMailList();
  3542. $mail=$eMList->getOne(array('where'=>'elid ='.$elid.'','asArray'=>true));
  3543. if(empty($mail))
  3544. return "/eMailList";
  3545. $mail['tagList']=explode(",", $mail['tag']);
  3546. $tagList=$tag->getAllBySid($this->staff[0]['sid']);
  3547. $districtList=$district->get_lv(1);
  3548. $tagHtml='';
  3549. foreach ($tagList as $key=>$value){
  3550. $tagHtml.='<label><span data-original-title="'.$value['name'].'" data-toggle="ctooltip" data-placement="right" class="contactsTag tagCol-0'.$value['colorid'].'">
  3551. <input type="checkbox" name="tagId[]"';
  3552. foreach ($mail['tagList'] as $k=>$v){
  3553. if ($value['tid']==$v){
  3554. $tagHtml.=' checked ';break;
  3555. }
  3556. }
  3557. $tagHtml.=' value="'.$value['tid'].'"></span></label>';
  3558. }
  3559. $districtHtml='';
  3560. foreach ($districtList as $key=>$value){
  3561. $districtHtml.='<option value="'.$value['id'].'"';
  3562. if($value['id']==$mail['districtId'])
  3563. $districtHtml.='selected';
  3564. $districtHtml.='>'.$value['name'].'</option>';
  3565. }
  3566. $natureHtml='';
  3567. $natList=explode(",", $mail['nature']);
  3568. foreach ($this->nature as $key=>$value){
  3569. $natureHtml.='<label><input type="checkbox" name="nature[]" ';
  3570. foreach ($natList as $k=>$v){
  3571. if ($value==$v){
  3572. $natureHtml.=' checked ';break;
  3573. }
  3574. }
  3575. $natureHtml.='value="'.$value.'">'.$value.'</label>';
  3576. }
  3577. $data['natureHtml']=$natureHtml;
  3578. $data['districtHtml']=$districtHtml;
  3579. $data['tagHtml']=$tagHtml;
  3580. $data['mail']=$mail;
  3581. $data['tagList']=$tagList;
  3582. $data['districtList']=$districtList;
  3583. $data['memu']="eMailTask";
  3584. $data['staff']=$this->staff;
  3585. $data['mailMemu']='eMailList';
  3586. $data['nature']=$this->nature;
  3587. $this->render ( "/mailEdit", $data );
  3588. }
  3589. function editEmail(){
  3590. $title=$this->get_args('title')?$this->get_args('title'):"";
  3591. $skin=$this->get_args('skin')?$this->get_args('skin'):"";
  3592. $content=isset($_POST['content'])?$_POST['content']:"";
  3593. $tagId=$this->get_args('tagId')?$this->get_args('tagId'):array();
  3594. $nature=$this->get_args('nature')?$this->get_args('nature'):array();
  3595. $natureNULL=$this->get_args('natureNULL')?$this->get_args('natureNULL'):"";
  3596. $did=$this->get_args('did')?$this->get_args('did'):"";
  3597. $stype=$this->get_args('stype')?$this->get_args('stype'):"";
  3598. $elid=$this->get_args('elid')?$this->get_args('elid'):"";
  3599. if (!empty($title)&&!empty($elid)&&(!empty($tagId)||!empty($did))){
  3600. Doo::loadModel('eMailList');
  3601. $eMailList=new eMailList();
  3602. $etid=$eMailList->getOne(array('select'=>'etid,annexName,annex','where'=>'elid='.$elid,'asArray'=>true));
  3603. Doo::loadModel('eMailTemplate');
  3604. $eMailTemplate=new eMailTemplate();
  3605. Doo::loadModel('eMailJournal');
  3606. $eMailJournal=new eMailJournal();
  3607. if ($natureNULL!='NULL'){
  3608. if (empty($tagId)&&!empty($did)&&empty($nature))
  3609. die('请选择性质');
  3610. }
  3611. //annex
  3612. $annexPath="";$annexEXT=$this->_GetFileEXT($_FILES["annex"]["name"]);$annexName="";
  3613. if ( isset($_FILES['annex']['name']) ){
  3614. if ((($annexEXT == "doc")|| ($annexEXT == "xls")|| ($annexEXT == "pdf")|| ($annexEXT == "ppt")|| ($annexEXT == "txt")|| ($annexEXT == "smr")
  3615. || ($annexEXT == "spu")|| ($annexEXT == "zip")|| ($annexEXT == "rar")|| ($annexEXT == "jpg")|| ($annexEXT == "png")
  3616. )&& ($_FILES["annex"]["size"] < 10485760)){
  3617. $path=DOO::conf()->SITE_PATH."upload/emailAnnex/";
  3618. if (!file_exists( $path. $_FILES["annex"]["name"])){
  3619. $fileName=time().".".$annexEXT;
  3620. $annexName=$_FILES['annex']['name'];
  3621. $annexPath=$path.$fileName ;
  3622. move_uploaded_file($_FILES["annex"]["tmp_name"],$annexPath);
  3623. $annexPath=$this->webPath.$fileName;
  3624. }
  3625. }
  3626. }
  3627. if (!empty($annexPath)){
  3628. $annexHtml='<table style="width:100%;margin:10px 0">
  3629. <thead>
  3630. <tr>
  3631. <th align="left" colspan="2" style="background-color:ff6501;color:#fff;font-size:16px;padding:5px">下载附件:</th>
  3632. </tr>
  3633. </thead>
  3634. <tbody>
  3635. <tr>
  3636. <td style="padding:5px"><a href="'.$annexPath.'" target="_blank" style="font-size:16px">'.$annexName.'</a></td>
  3637. <td>&nbsp;</td>
  3638. </tr>
  3639. </tbody>
  3640. </table>';
  3641. }elseif (!empty($etid['annexName'])&&empty($annexPath))
  3642. $annexHtml=$etid['annex'];
  3643. $smartcostMail='smartcost_mail_1';
  3644. $info="";
  3645. //html template
  3646. if($skin==1){
  3647. $html='<div><table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  3648. <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">
  3649. <tbody><tr>
  3650. <td style="background-color:#ff6501;padding:20px 0 25px;" align="center">
  3651. <span style="vertical-align:bottom;font-size:20px;color:#fff;">'.$title.'</span>
  3652. </td></tr><tr><td>
  3653. <table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;border-top:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  3654. <tbody><tr><td style="padding: 0 40px;" align="left">
  3655. <p style="margin-top:40px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
  3656. </td></tr><tr><td style="padding: 0 40px;" align="left">
  3657. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>'.$this->staff[0]['username'].'</b>:</p>
  3658. <p style="margin-top:0px;margin-bottom:20px;color:#383838;font-size:16px;line-height:32px;">
  3659. '.$content.'</p>
  3660. </td></tr>
  3661. <tr><td align="left" style="padding: 0 40px;background:#fff">
  3662. '.$annexHtml.'
  3663. </td></tr>
  3664. <tr> <td style="padding: 20px 40px;border-top:1px dashed #ddd" align="left">
  3665. <p style="margin-bottom:10px;color:#383838;font-size:16px;line-height:22px;border-left:2px solid #FF6501;padding-left:5px">
  3666. 纵横公路造价软件'.$this->staff[0]['category'].'办事处</p>
  3667. <table>
  3668. <tr><th align="right">电话:</th><td>'.$this->staff[0]['phone'].'</td></tr>
  3669. <tr><th align="right">联系人:</th><td>'.$this->staff[0]['username'].'</td></tr>
  3670. <tr><th align="right">手机:</th><td>'.$this->staff[0]['telephone'].'</td></tr>
  3671. <tr><th align="right">QQ:</th><td>'.$this->staff[0]['qq'].'</td></tr>
  3672. <tr><th align="right">邮箱:</th><td>'.$this->staff[0]['email'].'</td></tr>
  3673. </table></td></tr></tbody></table></td></tr><tr>
  3674. <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>
  3675. </tr></tbody></table></td></tr></tbody></table></div>';
  3676. $info='<table><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></table>';
  3681. }elseif ($skin==2){
  3682. $smartcostMail='smartcost_mail_2';
  3683. $html='<table cellspacing="0" cellpadding="0" style="background-color:#e4e4e4; width:100%;"><tbody><tr><td>
  3684. <table align="center" cellspacing="0" cellpadding="0" style="background-color:#f8f8f8; width:640px;margin-bottom:20px">
  3685. <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;">
  3686. <b><span name="titleHtml">'.$title.'</span></b></p></td>
  3687. </tr><tr><td><table align="center" cellspacing="0" cellpadding="0" style="border:1px solid #ddd;"><tbody><tr>
  3688. <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>
  3689. </tr><tr><td align="center" style="background-color:#fff;"><img width="640" height="191" src="http://zonghengvideo.qiniudn.com/hero.jpg"></td>
  3690. </tr><tr><td align="left" style="background-color:#fff;padding:40px;border-bottom:1px solid #ddd;">
  3691. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
  3692. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>'.$this->staff[0]['username'].'</b>:</p>
  3693. <p name="contentHtml" style="margin-top:0px;margin-bottom:15px;color:#383838;font-size:16px;line-height:32px;">'.$content.'</p></td>
  3694. </tr>
  3695. <tr><td align="left" style="padding: 0 40px;background:#fff">
  3696. '.$annexHtml.'
  3697. </td></tr>
  3698. <tr><td style="padding: 10px 0;background:#EEF2F5"><table><tbody><tr>
  3699. <td style="font-size:14pxl;color:#333;padding:0 20px"><b>纵横公路造价软件'.$this->staff[0]['category'].'办事处</b><br>'.$this->staff[0]['username'].'</td>
  3700. <td><table><tbody><tr style="font-size:12px;color:#666">
  3701. <th align="right">电话:</th><td style="padding:0 20px 0 0">'.$this->staff[0]['phone'].'</td>
  3702. <th align="right">手机:</th><td>'.$this->staff[0]['telephone'].'</td></tr><tr style="font-size:12px;color:#666">
  3703. <th align="right">QQ:</th><td>'.$this->staff[0]['qq'].'</td>
  3704. <th align="right">邮箱: </th><td>'.$this->staff[0]['email'].'</td>
  3705. </tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr>
  3706. <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>
  3707. </tr></tbody></table></td></tr></tbody> </table>';
  3708. $info='<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>';
  3714. }else{
  3715. $smartcostMail='smartcost_mail_3';
  3716. $html='<table cellspacing="0" cellpadding="0" style="background-color:#ECF0E1; width:100%">
  3717. <tbody>
  3718. <tr>
  3719. <td>
  3720. <table align="center" cellspacing="0" cellpadding="0" style="width:698px;margin-bottom:30px;margin-top:30px;">
  3721. <tbody>
  3722. <tr>
  3723. <td>
  3724. <table align="center" cellspacing="0" cellpadding="0" style="border:1px solid #ccc;width:100%;border-top:none">
  3725. <tbody>
  3726. <tr>
  3727. <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;">
  3728. <div style="position:relative;text-align:right">
  3729. <b style="font-size:24px;color:#8A9F98;z-index:999"><span name="titleHtml">'.$title.'</span></b>
  3730. <div style="width:80px;height:80px;position:absolute;top:0;left:0"><img src="http://zonghengvideo.qiniudn.com/zonghenglogo.png"></div>
  3731. </div>
  3732. </td>
  3733. </tr>
  3734. <tr>
  3735. <td align="left" style="background-color:#fff;padding:40px;border-bottom:1px solid #ddd;">
  3736. <p style="margin-top:0px;margin-bottom:10px;color:#666;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
  3737. <p style="margin-top:0px;margin-bottom:10px;color:#666;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>'.$this->staff[0]['username'].'</b>:</p>
  3738. <p name="contentHtml" style="margin-top:0px;margin-bottom:15px;color:#666;font-size:16px;line-height:32px;">'.$content.'</p></td>
  3739. </tr>
  3740. <tr><td align="left" style="padding: 0 40px;background:#fff">
  3741. '.$annexHtml.'
  3742. </td></tr>
  3743. <tr>
  3744. <td style="padding: 10px 0 0;background:#F6F6F6;">
  3745. <table>
  3746. <tbody><tr>
  3747. <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>
  3748. <td>
  3749. <table style="width:100%">
  3750. <tbody><tr style="font-size:12px;color:#496781">
  3751. <th align="right">电话:</th><td>'.$this->staff[0]['phone'].'</td>
  3752. <th align="right">手机:</th><td>'.$this->staff[0]['telephone'].'</td>
  3753. </tr>
  3754. <tr style="font-size:12px;color:#496781">
  3755. <th align="right">QQ:</th><td>'.$this->staff[0]['qq'].'</td>
  3756. <th align="right">邮箱: </th><td>'.$this->staff[0]['email'].'</td>
  3757. </tr>
  3758. </tbody></table>
  3759. </td>
  3760. </tr>
  3761. </tbody></table>
  3762. </td>
  3763. </tr>
  3764. <tr>
  3765. <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>
  3766. </tr>
  3767. </tbody>
  3768. </table></td>
  3769. </tr>
  3770. </tbody>
  3771. </table></td>
  3772. </tr>
  3773. </tbody>
  3774. </table>';
  3775. $info='<table><tr style="font-size:12px;color:#496781"><th align="right">电话:</th><td>'.$this->staff[0]['phone'].'</td>
  3776. <th align="right">手机:</th><td>'.$this->staff[0]['telephone'].'</td></tr><tr style="font-size:12px;color:#496781">
  3777. <th align="right">QQ:</th><td>'.$this->staff[0]['qq'].'</td>
  3778. <th align="right">邮箱: </th><td>'.$this->staff[0]['email'].'</td></tr></table>
  3779. ';
  3780. }
  3781. Doo::loadModel('tag_client');
  3782. $tagClient=new tag_client();
  3783. Doo::loadModel('client');
  3784. $client=new client();
  3785. Doo::loadModel('company');
  3786. $company=new company();
  3787. $eMailTemplate->title=$title;
  3788. $eMailTemplate->skin=$skin;
  3789. $eMailTemplate->content=$content;
  3790. if (!empty($tagId))
  3791. $eMailTemplate->tag=implode(",", $tagId);
  3792. $eMailTemplate->staffId=$this->staff[0]['sid'];
  3793. $eMailTemplate->staffName=$this->staff[0]['username'];
  3794. $eMailTemplate->status=0;
  3795. $eMailTemplate->html=$html;
  3796. if (!empty($annexPath)){
  3797. $eMailTemplate->annex=$annexPath;
  3798. $eMailTemplate->annexName=$annexName;
  3799. }
  3800. $etid=$eMailTemplate->update(array('where'=>'etid='.$etid['etid']));
  3801. //create email list
  3802. $tagCondition="";$tagArray=array();
  3803. foreach ($tagId as $value){
  3804. array_push($tagArray, " tag like '%".$value."%' ");
  3805. }
  3806. if(!empty($tagArray))
  3807. $tagCondition=' and ('.implode(" or ", $tagArray).')';
  3808. $clientList=$tagClient->find(array('select'=>'client','where'=>'sid='.$this->staff[0]['sid'].$tagCondition,'asArray'=>true));
  3809. $clientArray=array();
  3810. foreach ($clientList as $value){
  3811. array_push($clientArray, $value['client']);
  3812. }
  3813. $clientEmailList=array();
  3814. if (!empty($clientArray))
  3815. $clientEmailList=$client->find(array('select'=>'email,cid,nicename as clientname,companyname','where'=>'cid in ('.implode(",", $clientArray).')','asArray'=>true));
  3816. //
  3817. if ($stype==2){
  3818. //获取性质相关数据
  3819. $cidList='';
  3820. if ($natureNULL==''){
  3821. $nD=array();
  3822. foreach ($nature as $key=>$value){
  3823. array_push($nD, ' nature like "'.$value.'"');
  3824. //$nD=' nature like "'.$value.'"';
  3825. }
  3826. $nD=implode(' or ', $nD);
  3827. $companycid=$company->find(array('select'=>'cid','where'=>$nD,'asArray'=>true));
  3828. $cidList=array();
  3829. foreach ($companycid as $key=>$value){
  3830. array_push($cidList, $value['cid']);
  3831. }
  3832. $cidList=implode(',', $cidList);
  3833. if (!empty($cidList))
  3834. $cidList=' and companyid in ('.$cidList.')';
  3835. else
  3836. $cidList='';
  3837. }
  3838. //'select'=>'email,cid,nicename as clientname,companyname,district'
  3839. $clientEmailList=$client->find(array('select'=>'email,cid,nicename as clientname,companyname,district','where'=>'district like "'.$did.',%" '.$cidList,'asArray'=>true));
  3840. }
  3841. //;datediff(curdate(), 'date')>=10
  3842. $eMailJournal->delete(array('where'=>"datediff(curdate(), date)>=7"));
  3843. $eMailJournal->delete(array('where'=>'DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(date)'));
  3844. $checkMail=$eMailJournal->find(array('where'=>'DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(date)',' groupby'=>'email','asArray'=>true));
  3845. $emailNameList=$emailArray=$illegalEmail=$sendEmail=array();
  3846. Doo::db()->beginTransaction();
  3847. foreach ($clientEmailList as $value){
  3848. if(filter_var($value['email'], FILTER_VALIDATE_EMAIL)){
  3849. if(!empty($checkMail)){
  3850. $falg=true;
  3851. foreach ($checkMail as $v){
  3852. if($v['email']==$value['email']){
  3853. $Bdate=strtotime($v['date'])+7*24*3600;
  3854. if($Bdate<=time()){
  3855. array_push($emailArray, $value['email']);
  3856. array_push($emailNameList, $value);
  3857. $eMailJournal->date=date("Y-m-d");
  3858. $eMailJournal->update(array('where'=>'ejid='.$v['ejid']));
  3859. }else{
  3860. array_push($sendEmail, $value);
  3861. }
  3862. $falg=false;
  3863. break;
  3864. }
  3865. }
  3866. if ($falg){
  3867. array_push($emailArray, $value['email']);
  3868. array_push($emailNameList, $value);
  3869. $eMailJournal->clientId=$value['cid'];
  3870. $eMailJournal->status=1;
  3871. $eMailJournal->email=$value['email'];
  3872. $eMailJournal->date=date("Y-m-d");
  3873. $eMailJournal->insert();
  3874. }
  3875. }else{
  3876. array_push($emailArray, $value['email']);
  3877. array_push($emailNameList, $value);
  3878. $eMailJournal->clientId=$value['cid'];
  3879. $eMailJournal->status=1;
  3880. $eMailJournal->email=$value['email'];
  3881. $eMailJournal->date=date("Y-m-d");
  3882. $eMailJournal->insert();
  3883. }
  3884. }else{
  3885. array_push($illegalEmail, $value);
  3886. }
  3887. }
  3888. Doo::db()->commit();
  3889. //echo json_encode($illegalEmail);
  3890. //json_encode(array_slice($illegalEmail,0,100))
  3891. // $kk=gzcompress();
  3892. // $ll=gzuncompress($kk);
  3893. //."</br>".strlen($kk)."</br>".strlen($ll);die;
  3894. $size=floor(count($emailArray)/3);
  3895. if (!empty($emailArray)){
  3896. if(count($emailArray)<3){
  3897. $list=array(0=>$emailArray,1=>array(),2=>array());
  3898. }else
  3899. $list=array_chunk($emailArray,$size);
  3900. }else
  3901. $list=array(0=>array(),1=>array(),2=>array());
  3902. $emailJson=array();
  3903. foreach ($list as $value){
  3904. $em=array();
  3905. foreach ($value as $v){
  3906. array_push($em, $v);
  3907. }
  3908. array_push($emailJson, $em);
  3909. }
  3910. $size=floor(count($emailNameList)/3);
  3911. if (!empty($emailNameList)){
  3912. if(count($emailNameList)<3){
  3913. $list=array(0=>$emailNameList,1=>array(),2=>array());
  3914. }else
  3915. $list=array_chunk($emailNameList,$size);
  3916. }else
  3917. $list=array(0=>array(),1=>array(),2=>array());
  3918. $emailNameJson=array();
  3919. foreach ($list as $value){
  3920. $em=array();
  3921. foreach ($value as $v){
  3922. array_push($em, $v);
  3923. }
  3924. array_push($emailNameJson, $em);
  3925. }
  3926. //
  3927. $eMailList->date=date("Y-m-d");
  3928. $eMailList->clientEmail=base64_encode(gzcompress(json_encode($emailJson[0])));
  3929. $eMailList->clientEmail2=base64_encode(gzcompress(json_encode($emailJson[1])));
  3930. $eMailList->clientEmail3=base64_encode(gzcompress(json_encode($emailJson[2])));
  3931. $eMailList->clientName=base64_encode(gzcompress(json_encode($emailNameJson[0])));
  3932. $eMailList->clientName2=base64_encode(gzcompress(json_encode($emailNameJson[1])));
  3933. $eMailList->clientName3=base64_encode(gzcompress(json_encode($emailNameJson[2])));
  3934. $eMailList->illegalEmail=json_encode(array_slice($illegalEmail,0,100));//json_encode($illegalEmail);
  3935. $eMailList->sendEmail=json_encode($sendEmail);
  3936. $eMailList->templateName=$smartcostMail;
  3937. $eMailList->eTitle=$title;
  3938. $eMailList->html=$html;
  3939. $eMailList->content=$content;
  3940. $eMailList->info=$info;
  3941. if (!empty($annexName)){
  3942. $eMailList->annex=$annexHtml;
  3943. $eMailList->annexName=$annexName;
  3944. }
  3945. if ($stype==1){
  3946. $eMailList->tag=implode(",", $tagId);
  3947. $eMailList->districtId="";
  3948. $eMailList->nature="";
  3949. }
  3950. if ($stype==2){
  3951. $eMailList->districtId=$did;
  3952. $eMailList->nature=implode(",", $nature);
  3953. $eMailList->tag="";
  3954. }
  3955. $eMailList->update(array('where'=>'elid='.$elid));
  3956. return "/eMailList";
  3957. }
  3958. return "/eMailTask";
  3959. }
  3960. function createEmail(){
  3961. //include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  3962. $title=$this->get_args('title')?$this->get_args('title'):"";
  3963. $skin=$this->get_args('skin')?$this->get_args('skin'):"";
  3964. $content=isset($_POST['content'])?$_POST['content']:"";
  3965. $tagId=$this->get_args('tagId')?$this->get_args('tagId'):array();
  3966. $nature=$this->get_args('nature')?$this->get_args('nature'):array();
  3967. $natureNULL=$this->get_args('natureNULL')?$this->get_args('natureNULL'):"";
  3968. $did=$this->get_args('did')?$this->get_args('did'):"";
  3969. $stype=$this->get_args('stype')?$this->get_args('stype'):"";
  3970. if (!empty($title)&&(!empty($tagId)||!empty($did))){
  3971. Doo::loadModel('eMailTemplate');
  3972. $eMailTemplate=new eMailTemplate();
  3973. Doo::loadModel('eMailJournal');
  3974. $eMailJournal=new eMailJournal();
  3975. if ($natureNULL!='NULL'){
  3976. if (empty($tagId)&&!empty($did)&&empty($nature)){
  3977. header ( 'Content-Type:text/html;charset=utf-8' );
  3978. die('请选择性质');
  3979. }
  3980. }
  3981. //annex
  3982. $annexPath="";$annexEXT=$this->_GetFileEXT($_FILES["annex"]["name"]);$annexName="";
  3983. if ( isset($_FILES['annex']['name']) ){
  3984. if ((($annexEXT == "doc")|| ($annexEXT == "xls")|| ($annexEXT == "pdf")|| ($annexEXT == "ppt")|| ($annexEXT == "txt")|| ($annexEXT == "smr")
  3985. || ($annexEXT == "spu")|| ($annexEXT == "zip")|| ($annexEXT == "rar")|| ($annexEXT == "jpg")|| ($annexEXT == "png")
  3986. )&& ($_FILES["annex"]["size"] < 10485760)){
  3987. $path=DOO::conf()->SITE_PATH."upload/emailAnnex/";
  3988. if (!file_exists( $path. $_FILES["annex"]["name"])){
  3989. $fileName=time().".".$annexEXT;
  3990. $annexName=$_FILES['annex']['name'];
  3991. $annexPath=$path.$fileName ;
  3992. move_uploaded_file($_FILES["annex"]["tmp_name"],$annexPath);
  3993. $annexPath=$this->webPath.$fileName;
  3994. }
  3995. }
  3996. }
  3997. $annexHtml='<table style="width:100%;margin:10px 0">
  3998. <thead>
  3999. <tr>
  4000. <th align="left" colspan="2">下载附件:</th>
  4001. </tr>
  4002. </thead>
  4003. <tbody>
  4004. <tr>
  4005. <td><a href="'.$annexPath.'" target="_blank">'.$annexName.'</a></td>
  4006. <td>&nbsp;</td>
  4007. </tr>
  4008. </tbody>
  4009. </table>';
  4010. $smartcostMail='smartcost_mail_1';
  4011. $info="";
  4012. //html template
  4013. if($skin==1){
  4014. $html='<div><table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  4015. <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">
  4016. <tbody><tr>
  4017. <td style="background-color:#ff6501;padding:20px 0 25px;" align="center">
  4018. <span style="vertical-align:bottom;font-size:20px;color:#fff;">'.$title.'</span>
  4019. </td></tr><tr><td>
  4020. <table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;border-top:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  4021. <tbody><tr><td style="padding: 0 40px;" align="left">
  4022. <p style="margin-top:40px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
  4023. </td></tr><tr><td style="padding: 0 40px;" align="left">
  4024. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>'.$this->staff[0]['username'].'</b>:</p>
  4025. <p style="margin-top:0px;margin-bottom:20px;color:#383838;font-size:16px;line-height:32px;">
  4026. '.$content.'</p>
  4027. </td></tr>
  4028. <tr><td align="left" style="padding: 0 40px;background:#fff">
  4029. '.$annexHtml.'
  4030. </td></tr>
  4031. <tr> <td style="padding: 20px 40px;border-top:1px dashed #ddd" align="left">
  4032. <p style="margin-bottom:10px;color:#383838;font-size:16px;line-height:22px;border-left:2px solid #FF6501;padding-left:5px">
  4033. 纵横公路造价软件'.$this->staff[0]['category'].'办事处</p>
  4034. <table>
  4035. <tr><th align="right">电话:</th><td>'.$this->staff[0]['phone'].'</td></tr>
  4036. <tr><th align="right">联系人:</th><td>'.$this->staff[0]['username'].'</td></tr>
  4037. <tr><th align="right">手机:</th><td>'.$this->staff[0]['telephone'].'</td></tr>
  4038. <tr><th align="right">QQ:</th><td>'.$this->staff[0]['qq'].'</td></tr>
  4039. <tr><th align="right">邮箱:</th><td>'.$this->staff[0]['email'].'</td></tr>
  4040. </table></td></tr></tbody></table></td></tr><tr>
  4041. <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>
  4042. </tr></tbody></table></td></tr></tbody></table></div>';
  4043. $info='<table><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></table>';
  4048. }elseif ($skin==2){
  4049. $smartcostMail='smartcost_mail_2';
  4050. $html='<table cellspacing="0" cellpadding="0" style="background-color:#e4e4e4; width:100%;"><tbody><tr><td>
  4051. <table align="center" cellspacing="0" cellpadding="0" style="background-color:#f8f8f8; width:640px;margin-bottom:20px">
  4052. <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;">
  4053. <b><span name="titleHtml">'.$title.'</span></b></p></td>
  4054. </tr><tr><td><table align="center" cellspacing="0" cellpadding="0" style="border:1px solid #ddd;"><tbody><tr>
  4055. <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>
  4056. </tr><tr><td align="center" style="background-color:#fff;"><img width="640" height="191" src="http://zonghengvideo.qiniudn.com/hero.jpg"></td>
  4057. </tr><tr><td align="left" style="background-color:#fff;padding:40px;border-bottom:1px solid #ddd;">
  4058. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
  4059. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>'.$this->staff[0]['username'].'</b>:</p>
  4060. <p name="contentHtml" style="margin-top:0px;margin-bottom:15px;color:#383838;font-size:16px;line-height:32px;">'.$content.'</p></td>
  4061. </tr>
  4062. <tr><td align="left" style="padding: 0 40px;background:#fff">
  4063. '.$annexHtml.'
  4064. </td></tr>
  4065. <tr><td style="padding: 10px 0;background:#EEF2F5"><table><tbody><tr>
  4066. <td style="font-size:14pxl;color:#333;padding:0 20px"><b>纵横公路造价软件'.$this->staff[0]['category'].'办事处</b><br>'.$this->staff[0]['username'].'</td>
  4067. <td><table><tbody><tr style="font-size:12px;color:#666">
  4068. <th align="right">电话:</th><td style="padding:0 20px 0 0">'.$this->staff[0]['phone'].'</td>
  4069. <th align="right">手机:</th><td>'.$this->staff[0]['telephone'].'</td></tr><tr style="font-size:12px;color:#666">
  4070. <th align="right">QQ:</th><td>'.$this->staff[0]['qq'].'</td>
  4071. <th align="right">邮箱: </th><td>'.$this->staff[0]['email'].'</td>
  4072. </tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr>
  4073. <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>
  4074. </tr></tbody></table></td></tr></tbody> </table>';
  4075. $info='<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>';
  4081. }else{
  4082. $smartcostMail='smartcost_mail_3';
  4083. $html='<table cellspacing="0" cellpadding="0" style="background-color:#ECF0E1; width:100%">
  4084. <tbody>
  4085. <tr>
  4086. <td>
  4087. <table align="center" cellspacing="0" cellpadding="0" style="width:698px;margin-bottom:30px;margin-top:30px;">
  4088. <tbody>
  4089. <tr>
  4090. <td>
  4091. <table align="center" cellspacing="0" cellpadding="0" style="border:1px solid #ccc;width:100%;border-top:none">
  4092. <tbody>
  4093. <tr>
  4094. <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;">
  4095. <div style="position:relative;text-align:right">
  4096. <b style="font-size:24px;color:#8A9F98;z-index:999"><span name="titleHtml">'.$title.'</span></b>
  4097. <div style="width:80px;height:80px;position:absolute;top:0;left:0"><img src="http://zonghengvideo.qiniudn.com/zonghenglogo.png"></div>
  4098. </div>
  4099. </td>
  4100. </tr>
  4101. <tr>
  4102. <td align="left" style="background-color:#fff;padding:40px;border-bottom:1px solid #ddd;">
  4103. <p style="margin-top:0px;margin-bottom:10px;color:#666;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
  4104. <p style="margin-top:0px;margin-bottom:10px;color:#666;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>'.$this->staff[0]['username'].'</b>:</p>
  4105. <p name="contentHtml" style="margin-top:0px;margin-bottom:15px;color:#666;font-size:16px;line-height:32px;">'.$content.'</p></td>
  4106. </tr>
  4107. <tr><td align="left" style="padding: 0 40px;background:#fff">
  4108. '.$annexHtml.'
  4109. </td></tr>
  4110. <tr>
  4111. <td style="padding: 10px 0 0;background:#F6F6F6;">
  4112. <table>
  4113. <tbody><tr>
  4114. <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>
  4115. <td>
  4116. <table style="width:100%">
  4117. <tbody><tr style="font-size:12px;color:#496781">
  4118. <th align="right">电话:</th><td>'.$this->staff[0]['phone'].'</td>
  4119. <th align="right">手机:</th><td>'.$this->staff[0]['telephone'].'</td>
  4120. </tr>
  4121. <tr style="font-size:12px;color:#496781">
  4122. <th align="right">QQ:</th><td>'.$this->staff[0]['qq'].'</td>
  4123. <th align="right">邮箱: </th><td>'.$this->staff[0]['email'].'</td>
  4124. </tr>
  4125. </tbody></table>
  4126. </td>
  4127. </tr>
  4128. </tbody></table>
  4129. </td>
  4130. </tr>
  4131. <tr>
  4132. <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>
  4133. </tr>
  4134. </tbody>
  4135. </table></td>
  4136. </tr>
  4137. </tbody>
  4138. </table></td>
  4139. </tr>
  4140. </tbody>
  4141. </table>';
  4142. $info='<table><tr style="font-size:12px;color:#496781"><th align="right">电话:</th><td>'.$this->staff[0]['phone'].'</td>
  4143. <th align="right">手机:</th><td>'.$this->staff[0]['telephone'].'</td></tr><tr style="font-size:12px;color:#496781">
  4144. <th align="right">QQ:</th><td>'.$this->staff[0]['qq'].'</td>
  4145. <th align="right">邮箱: </th><td>'.$this->staff[0]['email'].'</td></tr></table>
  4146. ';
  4147. }
  4148. $eMailTemplate->title=$title;
  4149. $eMailTemplate->skin=$skin;
  4150. $eMailTemplate->content=$content;
  4151. if (!empty($tagId))
  4152. $eMailTemplate->tag=implode(",", $tagId);
  4153. $eMailTemplate->staffId=$this->staff[0]['sid'];
  4154. $eMailTemplate->staffName=$this->staff[0]['username'];
  4155. $eMailTemplate->status=0;
  4156. $eMailTemplate->html=$html;
  4157. $eMailTemplate->annex=$annexPath;
  4158. $eMailTemplate->annexName=$annexName;
  4159. $etid=$eMailTemplate->insert();
  4160. //create email list
  4161. Doo::loadModel('tag_client');
  4162. $tagClient=new tag_client();
  4163. Doo::loadModel('client');
  4164. $client=new client();
  4165. Doo::loadModel('eMailList');
  4166. $eMailList=new eMailList();
  4167. Doo::loadModel('company');
  4168. $company=new company();
  4169. $tagCondition="";$tagArray=array();
  4170. foreach ($tagId as $value){
  4171. array_push($tagArray, " tag like '%".$value."%' ");
  4172. }
  4173. if(!empty($tagArray))
  4174. $tagCondition=' and ('.implode(" or ", $tagArray).')';
  4175. $clientList=$tagClient->find(array('select'=>'client','where'=>'sid='.$this->staff[0]['sid'].$tagCondition,'asArray'=>true));
  4176. $clientArray=array();
  4177. foreach ($clientList as $value){
  4178. array_push($clientArray, $value['client']);
  4179. }
  4180. $clientEmailList=array();
  4181. if (!empty($clientArray))
  4182. $clientEmailList=$client->find(array('select'=>'email,cid,nicename as clientname,companyname','where'=>'cid in ('.implode(",", $clientArray).')','asArray'=>true));
  4183. //
  4184. if ($stype==2){
  4185. //获取性质相关数据
  4186. $cidList='';
  4187. if ($natureNULL==''){
  4188. $nD=array();
  4189. foreach ($nature as $key=>$value){
  4190. array_push($nD, ' nature like "'.$value.'"');
  4191. //$nD=' nature like "'.$value.'"';
  4192. }
  4193. $nD=implode(' or ', $nD);
  4194. $companycid=$company->find(array('select'=>'cid','where'=>$nD,'asArray'=>true));
  4195. $cidList=array();
  4196. foreach ($companycid as $key=>$value){
  4197. array_push($cidList, $value['cid']);
  4198. }
  4199. $cidList=implode(',', $cidList);
  4200. if (!empty($cidList))
  4201. $cidList=' and companyid in ('.$cidList.')';
  4202. else
  4203. $cidList='';
  4204. }
  4205. //'select'=>'email,cid,nicename as clientname,companyname,district'
  4206. $clientEmailList=$client->find(array('select'=>'email,cid,nicename as clientname,companyname,district','where'=>'district like "'.$did.',%" '.$cidList,'asArray'=>true));
  4207. }
  4208. //;datediff(curdate(), 'date')>=10
  4209. $eMailJournal->delete(array('where'=>"datediff(curdate(), date)>=7"));
  4210. $checkMail=$eMailJournal->find(array('where'=>'DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(date)',' groupby'=>'email','asArray'=>true));
  4211. $emailNameList=$emailArray=$illegalEmail=$sendEmail=array();
  4212. Doo::db()->beginTransaction();
  4213. foreach ($clientEmailList as $value){
  4214. if(filter_var($value['email'], FILTER_VALIDATE_EMAIL)){
  4215. if(!empty($checkMail)){
  4216. $falg=true;
  4217. foreach ($checkMail as $v){
  4218. if($v['email']==$value['email']){
  4219. $Bdate=strtotime($v['date'])+7*24*3600;
  4220. if($Bdate<=time()){
  4221. array_push($emailArray, $value['email']);
  4222. array_push($emailNameList, $value);
  4223. $eMailJournal->date=date("Y-m-d");
  4224. $eMailJournal->update(array('where'=>'ejid='.$v['ejid']));
  4225. }else{
  4226. array_push($sendEmail, $value);
  4227. }
  4228. $falg=false;
  4229. break;
  4230. }
  4231. }
  4232. if ($falg){
  4233. array_push($emailArray, $value['email']);
  4234. array_push($emailNameList, $value);
  4235. $eMailJournal->clientId=$value['cid'];
  4236. $eMailJournal->status=1;
  4237. $eMailJournal->email=$value['email'];
  4238. $eMailJournal->date=date("Y-m-d");
  4239. //$eMailJournal->insert();
  4240. }
  4241. }else{
  4242. array_push($emailArray, $value['email']);
  4243. array_push($emailNameList, $value);
  4244. $eMailJournal->clientId=$value['cid'];
  4245. $eMailJournal->status=1;
  4246. $eMailJournal->email=$value['email'];
  4247. $eMailJournal->date=date("Y-m-d");
  4248. //$eMailJournal->insert();
  4249. }
  4250. }else{
  4251. array_push($illegalEmail, $value);
  4252. }
  4253. }
  4254. Doo::db()->commit();
  4255. //echo json_encode($illegalEmail);
  4256. //json_encode(array_slice($illegalEmail,0,100))
  4257. // $kk=gzcompress();
  4258. // $ll=gzuncompress($kk);
  4259. //."</br>".strlen($kk)."</br>".strlen($ll);die;
  4260. $size=floor(count($emailArray)/3);
  4261. if (!empty($emailArray)){
  4262. if(count($emailArray)<3){
  4263. $list=array(0=>$emailArray,1=>array(),2=>array());
  4264. }else
  4265. $list=array_chunk($emailArray,$size);
  4266. }else
  4267. $list=array(0=>array(),1=>array(),2=>array());
  4268. $emailJson=array();
  4269. foreach ($list as $value){
  4270. $em=array();
  4271. foreach ($value as $v){
  4272. array_push($em, $v);
  4273. }
  4274. array_push($emailJson, $em);
  4275. }
  4276. $size=floor(count($emailNameList)/3);
  4277. if (!empty($emailNameList)){
  4278. if(count($emailNameList)<3){
  4279. $list=array(0=>$emailNameList,1=>array(),2=>array());
  4280. }else
  4281. $list=array_chunk($emailNameList,$size);
  4282. }else
  4283. $list=array(0=>array(),1=>array(),2=>array());
  4284. $emailNameJson=array();
  4285. foreach ($list as $value){
  4286. $em=array();
  4287. foreach ($value as $v){
  4288. array_push($em, $v);
  4289. }
  4290. array_push($emailNameJson, $em);
  4291. }
  4292. //
  4293. $eMailList->date=date("Y-m-d");
  4294. $eMailList->clientEmail=base64_encode(gzcompress(json_encode($emailJson[0])));
  4295. $eMailList->clientEmail2=base64_encode(gzcompress(json_encode($emailJson[1])));
  4296. $eMailList->clientEmail3=base64_encode(gzcompress(json_encode($emailJson[2])));
  4297. $eMailList->clientName=base64_encode(gzcompress(json_encode($emailNameJson[0])));
  4298. $eMailList->clientName2=base64_encode(gzcompress(json_encode($emailNameJson[1])));
  4299. $eMailList->clientName3=base64_encode(gzcompress(json_encode($emailNameJson[2])));
  4300. $eMailList->illegalEmail=json_encode(array_slice($illegalEmail,0,100));//json_encode($illegalEmail);
  4301. $eMailList->sendEmail=json_encode($sendEmail);
  4302. $eMailList->etid=$etid;
  4303. $eMailList->templateName=$smartcostMail;
  4304. $eMailList->eTitle=$title;
  4305. $eMailList->html=$html;
  4306. $eMailList->content=$content;
  4307. $eMailList->info=$info;
  4308. if (!empty($annexName))
  4309. $eMailList->annex=$annexHtml;
  4310. $eMailList->annexName=$annexName;
  4311. $eMailList->staffId=$this->staff[0]['sid'];
  4312. $eMailList->staffName=$this->staff[0]['username'];
  4313. if ($stype==1)
  4314. $eMailList->tag=implode(",", $tagId);
  4315. if ($stype==2){
  4316. $eMailList->districtId=$did;
  4317. $eMailList->nature=implode(",", $nature);
  4318. }
  4319. $eMailList->insert();
  4320. return "/eMailList";
  4321. }
  4322. return "/eMailTask";
  4323. }
  4324. function eMailList(){
  4325. Doo::loadModel('eMailList');
  4326. $eMailList=new eMailList();
  4327. Doo::loadModel('tag');
  4328. $tag=new tag();
  4329. $mailList=$eMailList->find(array('where'=>'staffId='.$this->staff[0]['sid'],'desc'=>'elid','asArray'=>true));
  4330. foreach ($mailList as $key=>$value){
  4331. $mailList[$key]['clientName2']=$mailList[$key]['clientName3']=array();
  4332. $mailList[$key]['clientName']=json_decode(gzuncompress(base64_decode($value['clientName'])),true);
  4333. if(!empty($value['clientName2']))
  4334. $mailList[$key]['clientName2']=json_decode(gzuncompress(base64_decode($value['clientName2'])),true);
  4335. if(!empty($value['clientName3']))
  4336. $mailList[$key]['clientName3']=json_decode(gzuncompress(base64_decode($value['clientName3'])),true);
  4337. $mailList[$key]['illegalEmail']=json_decode($value['illegalEmail'],true);
  4338. $mailList[$key]['sendEmail']=json_decode($value['sendEmail'],true);
  4339. $mailList[$key]['clientCount']=count($mailList[$key]['clientName'])+count($mailList[$key]['clientName2'])+count($mailList[$key]['clientName3']);
  4340. $mailList[$key]['tag']=array();
  4341. if (!empty($value['tag']))
  4342. $mailList[$key]['tag']=$tag->find(array('where'=>'tid in ( '.$value['tag'].') ','asArray'=>true));
  4343. }
  4344. $data['mailList']=$mailList;
  4345. $data['memu']="eMailTask";
  4346. $data['staff']=$this->staff;
  4347. $data['mailMemu']='eMailList';
  4348. $this->render ( "/mail_list", $data );
  4349. }
  4350. function showEmailContent(){
  4351. $elid=isset($this->params['elid'])?$this->params['elid']:0;
  4352. Doo::loadModel('eMailList');
  4353. $eMList=new eMailList();
  4354. $isSend=$eMList->getOne(array('where'=>'elid ='.$elid.'','asArray'=>true));
  4355. echo htmlspecialchars($isSend['content']);
  4356. }
  4357. function postEmail(){
  4358. //include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  4359. $elid=isset($this->params['elid'])?$this->params['elid']:0;
  4360. $send=isset($this->params['send'])?$this->params['send']:0;
  4361. Doo::loadModel('eMailList');
  4362. $eMList=new eMailList();
  4363. if (!empty($elid)){
  4364. $isSend=$eMList->getOne(array('select'=>'send'.$send,'where'=>'elid ='.$elid.' and status=0 and send'.$send.'=1','asArray'=>true));
  4365. if (!empty($isSend))
  4366. die('这批邮件已经发送');
  4367. if ($send==1)
  4368. $send='';
  4369. $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));
  4370. $toFormatMail=array();$sub=array();
  4371. $toMail=json_decode(gzuncompress(base64_decode($eMailList['clientEmail'])),true);
  4372. //$toMailCount=count($toMail);
  4373. $subMail=json_decode(gzuncompress(base64_decode($eMailList['clientName'])),true);
  4374. $chunkMail=array_chunk($toMail,80);
  4375. $chunkSubMail=array_chunk($subMail,80);
  4376. $vii=0;
  4377. foreach ($chunkMail as $key=>$value){
  4378. $l=$s=$c=$i=$cate=$con=$annex=array();
  4379. $toFormatMail['to']=$value;
  4380. $cn=$chunkSubMail[$key];
  4381. foreach ($cn as $v ){
  4382. array_push($l, $eMailList['eTitle']);
  4383. array_push($s, $eMailList['staffName']);
  4384. array_push($c, $v['clientname']);
  4385. array_push($annex, $eMailList['annex']);
  4386. array_push($i, $eMailList['info']);
  4387. //array_push($con, $eMailList['content']);
  4388. array_push($cate, $this->staff[0]['category']);
  4389. }
  4390. $sub['%eTitle%']=$l;
  4391. $sub['%staffName%']=$s;
  4392. $sub['%clientName%']=$c;
  4393. $sub['%category%']=$cate;
  4394. $sub['%info%']=$i;
  4395. //$sub['%content%']=$con;
  4396. $sub['%annex%']=$annex;
  4397. $toFormatMail['sub']=$sub;
  4398. $url = 'http://sendcloud.sohu.com/webapi/mail.send_template.xml';
  4399. $param = array('api_user' => 'cldmail',
  4400. 'api_key' => 'cDO1GjtY1seH',
  4401. 'template_invoke_name'=>$eMailList['templateName'],
  4402. 'from' =>$this->staff[0]['email'],
  4403. 'fromname' => '纵横'.$eMailList['staffName'],
  4404. 'subject' => $eMailList['eTitle'],
  4405. 'substitution_vars' => json_encode($toFormatMail));
  4406. $post_data = http_build_query($param);
  4407. $ch = curl_init();
  4408. curl_setopt($ch, CURLOPT_POST, 1);
  4409. curl_setopt($ch, CURLOPT_URL,$url);
  4410. curl_setopt($ch, CURLOPT_HEADER, false); //设定是否输出页面内容
  4411. curl_setopt($ch, CURLOPT_NOBODY, false);
  4412. curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
  4413. $result =curl_exec($ch);
  4414. curl_close($ch);
  4415. /*
  4416. if($result=='success'){
  4417. $eM=new eMailList();
  4418. $eM->status='2';
  4419. $eM->update(array('where'=>'elid=?','param'=>array($elid)));
  4420. }
  4421. */
  4422. }
  4423. if ($send=="")
  4424. $send=1;
  4425. $sql = "update `CLD_eMailList` set send".$send."='1' where elid = '" . $elid."'";
  4426. Doo::db ()->query ( $sql );
  4427. $isSend=$eMList->getOne(array('where'=>'elid ='.$elid.' and status=0 and send1=1 and send2=1 and send3=1','asArray'=>true));
  4428. if (!empty($isSend)){
  4429. $sql = "update `CLD_eMailList` set status='2' where elid = '" . $elid."'";
  4430. Doo::db ()->query ( $sql );
  4431. }
  4432. //die;
  4433. return '/eMailList';
  4434. }
  4435. }
  4436. function a(){
  4437. $substitution_vars=$this->get_args('substitution_vars');
  4438. file_put_contents(DOO::conf()->SITE_PATH .'upload/'."_".time()."_".rand(100,999).".log",$substitution_vars);
  4439. }
  4440. function deleteEmail(){
  4441. $elid=isset($this->params['elid'])?$this->params['elid']:0;
  4442. if (!empty($elid)){
  4443. $sql = "DELETE FROM `CLD_eMailList` where elid = '" . $elid."'";
  4444. Doo::db ()->query ( $sql );
  4445. return '/eMailList';
  4446. }
  4447. }
  4448. /**
  4449. * 发送post请求
  4450. * @param string $url 请求地址
  4451. * @param array $post_data post键值对数据
  4452. * @return string
  4453. */
  4454. function sendPost($url, $post_data) {
  4455. $postdata = http_build_query($post_data);
  4456. //X-Amzn-Authorization: AWS3 AWSAccessKeyId=AKIAIDSE5VYNX5ERJHXQ,Signature=lBP67vCvGlDMBQ=dofZxg8E8SUEXAMPLE,Algorithm=HmacSHA256,SignedHeaders=qG1BdSh9QyYPlWLnjqvjDXjyPdFjl7fUSkfs0Hk2
  4457. $options = array(
  4458. 'http' => array(
  4459. 'method' => 'POST',
  4460. 'header' => '
  4461. Content-Type: application/x-www-form-urlencoded
  4462. ',
  4463. 'content' => $postdata,
  4464. 'timeout' => 15 * 60 // 超时时间(单位:s)
  4465. )
  4466. );
  4467. $context = stream_context_create($options);
  4468. $result = file_get_contents($url, false, $context);
  4469. return $result;
  4470. }
  4471. function avatar(){
  4472. $result = array();
  4473. $result['success'] = false;
  4474. $successNum = 0;
  4475. //定义一个变量用以储存当前头像的序号
  4476. $avatarNumber = 1;
  4477. $i = 0;
  4478. $msg = '';
  4479. //上传目录
  4480. $dir = DOO::conf()->SITE_PATH."global/avatar";
  4481. //遍历所有文件域
  4482. while (list($key, $val) = each($_FILES)){
  4483. if ( $_FILES[$key]['error'] > 0)
  4484. $msg .= $_FILES[$key]['error'];
  4485. else{
  4486. $fileName = 'avatar_'.$this->staff[0]['sid'];
  4487. //原始图片(file 域的名称:__source,如果客户端定义可以上传的话,可在此处理)。
  4488. if ($key == '__source'){//当前头像基于原图的初始化参数,用于修改头像时保证界面的视图跟保存头像时一致。帮助提升用户体验度。修改头像时设置默认加载的原图的url为此图片的url+该参数即可。
  4489. $initParams = $_POST["__initParams"];
  4490. $virtualPath = $dir."/".$fileName."_".$avatarNumber.".jpg";
  4491. $result['sourceUrl'] = '/' . $virtualPath.$initParams;
  4492. move_uploaded_file($_FILES[$key]["tmp_name"], $virtualPath);
  4493. $successNum++;
  4494. }else if (strpos($key, '__avatar') === 0){//头像图片(file 域的名称:__avatar1,2,3...)。
  4495. $virtualPath = $dir."/".$fileName."_".$avatarNumber.".jpg";
  4496. $result['avatarUrls'][$i] = '/' . $virtualPath;
  4497. move_uploaded_file($_FILES[$key]["tmp_name"], $virtualPath);
  4498. $avatarNumber++;
  4499. $successNum++;
  4500. $i++;
  4501. }
  4502. }
  4503. }
  4504. $result['msg'] = $msg;
  4505. if ($successNum > 0)
  4506. $result['success'] = true;
  4507. //返回图片的保存结果(返回内容为json字符串)
  4508. Doo::loadModel('staff');
  4509. $staff=new staff();
  4510. $staff->sid=$this->staff[0]['sid'];
  4511. $staff->avatar="/global/avatar/".$fileName;
  4512. $staff->update();
  4513. echo json_encode($result);
  4514. }
  4515. function lockUpload(){
  4516. //move_uploaded_file($_FILES['Filedata']['tmp_name'], "/upload/".$_FILES['Filedata']['name']);
  4517. if ( isset($_FILES['Filedata']['name']) ){
  4518. $file = $_FILES['Filedata']['tmp_name'];
  4519. $error = false;
  4520. if (!is_uploaded_file($file) ){
  4521. $error = '400 Bad Request';
  4522. }
  4523. if ($error) {
  4524. header('HTTP/1.0 ' . $error);
  4525. die('Error ' . $error);
  4526. }else{
  4527. include (DOO::conf()->SITE_PATH . 'protected/plugin/io.han.php');
  4528. $this->IoHandler = new IoHandler();
  4529. $pics = explode ( '.', $_FILES['Filedata']['name'] );
  4530. //$filedir=$_POST['time'];
  4531. //调用定义物理路径
  4532. $t=DOO::conf()->SITE_PATH."upload/";
  4533. $this->IoHandler->MakeDir($t);
  4534. $filename=$this->_GetFileEXT($_FILES['Filedata']['name']);
  4535. if($filename!='xlsx')
  4536. return "";
  4537. //$upload_dir = $t."/".time().rand(10,100).".".$filename;
  4538. $upload_file = iconv("UTF-8", "GB2312", $_FILES["Filedata"]["name"]);
  4539. $upload_dir = $t."/".$upload_file;
  4540. $k=move_uploaded_file($file, $upload_dir);
  4541. if($k){
  4542. //"series/".$filedir."/".
  4543. $m=round($_FILES['Filedata']['size']/1024/1024, 2);
  4544. echo $pics[0].".".$filename."#".$m."#".$_FILES['Filedata']['size'];
  4545. }
  4546. }
  4547. }
  4548. }
  4549. function getAuthentication(){
  4550. }
  4551. function loadCVS(){
  4552. Doo::loadModel('longle');
  4553. $longle=new longle();
  4554. $list=$longle->find(array('select'=>'key_num','asArray' => TRUE));
  4555. $file = fopen(DOO::conf()->SITE_PATH."upload/key2.csv",'r');
  4556. while ($data = fgetcsv($file)) {
  4557. $goods_list[$data[0]] = $data[1] ;
  4558. }
  4559. fclose($file);
  4560. $sqlArray=array();
  4561. $sql='UPDATE CLD_longle SET SerialNumber = CASE key_num ';
  4562. foreach($list as $key=>$value){
  4563. if(array_key_exists($value['key_num'],$goods_list)){
  4564. //echo $value['key_num'].'-'.$goods_list[$value['key_num']].'<br/>';
  4565. //$longle->SerialNumber=$goods_list[$value['key_num']];
  4566. //$longle->update(array('where'=>'key_num="'.$value['key_num'].'"'));
  4567. $sql.=' WHEN "'.$value['key_num'].'" THEN "'.$goods_list[$value['key_num']].'" ';
  4568. array_push($sqlArray, '"'.$value['key_num'].'"');
  4569. unset($goods_list[$value['key_num']]);
  4570. }
  4571. }
  4572. $sql.='END WHERE key_num IN ('.implode(',', $sqlArray).')';
  4573. echo $sql.'<br/>--------------------------------<br/>';
  4574. foreach ($goods_list as $key=>$value){
  4575. echo $key.','.$value.'<br/>';
  4576. }
  4577. }
  4578. private function getRandChar($length){
  4579. $str = null;
  4580. $strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
  4581. $max = strlen($strPol)-1;
  4582. for($i=0;$i<$length;$i++){
  4583. $str.=$strPol[rand(0,$max)];//rand($min,$max)生成介于min和max两个数之间的一个随机整数
  4584. }
  4585. return $str;
  4586. }
  4587. private function getReceiptCount(){
  4588. $status=2;
  4589. $year=date('Y');
  4590. Doo::loadModel('receipt');
  4591. $receipt=new receipt();
  4592. $dateCondition=" and Year(date) =".$year;
  4593. $approvalCondition=' and nowStaff like "%'.$this->staff[0]['sid'].'%" ';
  4594. $receiptList=$receipt->find(array('where'=>' status='.$status.$dateCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  4595. return count($receiptList);
  4596. }
  4597. private function getExeCount(){
  4598. Doo::loadModel('receipt');
  4599. $receipt=new receipt();
  4600. $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));
  4601. return count($receiptList);
  4602. }
  4603. /**
  4604. * 格式化excel文件为数组
  4605. * @param unknown_type $file_url
  4606. * @param unknown_type $mcid
  4607. */
  4608. function _format_excel_to_array($file_url = "") {
  4609. if (! file_exists ( $file_url ))
  4610. return array ();
  4611. Doo::loadClass ( 'PHPExcel' );
  4612. $PHPExcel = new PHPExcel ();
  4613. $PHPReader = new PHPExcel_Reader_Excel2007 ();
  4614. if (! $PHPReader->canRead ( $file_url )) {
  4615. $PHPReader = new PHPExcel_Reader_Excel5 ();
  4616. if (! $PHPReader->canRead ( $file_url )) {
  4617. echo 'no Excel';
  4618. return;
  4619. }
  4620. }
  4621. $PHPExcel = $PHPReader->load ( $file_url );
  4622. /**读取excel文件中的第一个工作表*/
  4623. $currentSheet = $PHPExcel->getSheet ( 0 );
  4624. /**取得最大的列号*/
  4625. $allColumn = $currentSheet->getHighestColumn ();
  4626. /**取得一共有多少行*/
  4627. $allRow = $currentSheet->getHighestRow ();
  4628. $excel_array = array ();
  4629. for($currentRow = 2; $currentRow <= $allRow; $currentRow ++) {
  4630. $excel_column = array ();
  4631. //后期改进
  4632. if($allColumn=='AM')
  4633. $allColumn='Z';
  4634. /**从第A列开始输出*/
  4635. for($currentColumn = 'A'; $currentColumn <= $allColumn; $currentColumn ++) {
  4636. $val = $currentSheet->getCellByColumnAndRow ( ord ( $currentColumn ) - 65, $currentRow )->getValue ();
  4637. /**ord()将字符转为十进制数 iconv ( 'utf-8', 'gb2312',*/
  4638. $val = "'" . addslashes ( $val ) . "'";
  4639. if ($currentColumn == 'A')
  4640. $excel_column ['key_num'] = $val;
  4641. elseif ($currentColumn == 'C')
  4642. $excel_column ['product'] = $val;
  4643. elseif ($currentColumn == 'D'){
  4644. $val=str_replace("'","",$val);
  4645. $excel_column ['make_day'] = $this->excelTime($val);
  4646. }elseif($currentColumn == 'E'){
  4647. $val=str_replace("'","",$val);
  4648. $excel_column ['alloted_time'] = $this->excelTime($val);
  4649. }elseif($currentColumn == 'F'){
  4650. $val=str_replace("'","",$val);
  4651. $excel_column ['version'] = $val;
  4652. }elseif ($currentColumn == 'B'){
  4653. $val=str_replace("'","",$val);
  4654. $excel_column ['SerialNumber'] = $val;
  4655. }
  4656. }
  4657. array_push ( $excel_array, $excel_column );
  4658. }
  4659. return $excel_array;
  4660. }
  4661. function excelTime($date, $time = false)
  4662. {
  4663. if (function_exists ( 'GregorianToJD' ))
  4664. {
  4665. if (is_numeric ( $date ))
  4666. {
  4667. $jd = GregorianToJD ( 1, 1, 1970 );
  4668. $gregorian = JDToGregorian ( $jd + intval ( $date ) - 25569 );
  4669. $date = explode ( '/', $gregorian );
  4670. $date_str = str_pad ( $date [2], 4, '0', STR_PAD_LEFT ) . "-" .
  4671. str_pad ( $date [0], 2, '0', STR_PAD_LEFT ) . "-" .
  4672. str_pad ( $date [1], 2, '0', STR_PAD_LEFT ) . ($time ? " 00:00:00" : '');
  4673. return $date_str;
  4674. }
  4675. } else
  4676. {
  4677. $date = $date > 25568 ? $date + 1 : 25569;
  4678. /* There was a bug if Converting date before 1-1-1970 (tstamp 0) */
  4679. $ofs = (70 * 365 + 17 + 2) * 86400;
  4680. $date = date ( "Y-m-d", ($date * 86400) - $ofs ) . ($time ? " 00:00:00" : '');
  4681. }
  4682. return $date;
  4683. }
  4684. function _GetFileEXT($filename) {
  4685. $pics = explode ( '.', $filename );
  4686. $num = count ( $pics );
  4687. return $pics [$num - 1];
  4688. }
  4689. /**
  4690. * 获取get或者POST值
  4691. * @param string $name 属性名称
  4692. * @return fixed 值
  4693. */
  4694. function get_args($name) {
  4695. if (isset ( $_GET [$name] )) {
  4696. if (is_array ( $_GET [$name] ))
  4697. return $_GET [$name];
  4698. else {
  4699. return addslashes ( $_GET [$name] );
  4700. //return $_GET [$name] ;
  4701. }
  4702. } elseif (isset ( $_POST [$name] )) {
  4703. if (is_array ( $_POST [$name] ))
  4704. return $_POST [$name];
  4705. else {
  4706. return addslashes ( $_POST [$name] );
  4707. //return $_POST [$name];
  4708. }
  4709. } else {
  4710. return false;
  4711. }
  4712. }
  4713. function get_previous($on_page = 1) {
  4714. return $on_page != 0 ? $on_page - 1 : $on_page;
  4715. }
  4716. /**
  4717. * 获得分页数据
  4718. * @param unknown_type $table
  4719. * @param unknown_type $condition
  4720. * @param unknown_type $on_page
  4721. * @param unknown_type $page_size
  4722. */
  4723. function get_Tpage($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "",$tagSQL) {
  4724. $page_c = "";
  4725. $page ['previous'] = $this->get_previous ( $on_page );
  4726. $page ['on_page'] = $on_page;
  4727. $total_count = $this->get_table_Tcount ( $table, $condition,$tagSQL );
  4728. $total = intval ( $total_count / $page_size );
  4729. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  4730. $page ['total_data'] = $total_count;
  4731. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  4732. $i = 1;
  4733. $page_max = 1;
  4734. if ($on_page > 10) {
  4735. $page_max = intval ( $on_page / 10 ) + 1;
  4736. $i = intval ( $on_page / 10 ) * 10 - 1;
  4737. }
  4738. $page ['page'] = $page_c;
  4739. $page ['lower'] = (-- $on_page) * $page_size;
  4740. return $page;
  4741. }
  4742. /**
  4743. * 获得分页数据
  4744. * @param unknown_type $table
  4745. * @param unknown_type $condition
  4746. * @param unknown_type $on_page
  4747. * @param unknown_type $page_size
  4748. */
  4749. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page",$staffid="",$search,$tooltip,$cateid,$tagSQL) {
  4750. $page_c = "";
  4751. $page ['previous'] = $this->get_previous ( $on_page );
  4752. $page ['on_page'] = $on_page;
  4753. $total_count = $this->get_table_count ( $table, $condition ,$staffid,$search,$tooltip,$cateid,$tagSQL);
  4754. $total = intval ( $total_count / $page_size );
  4755. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  4756. $page ['total_data'] = $total_count;
  4757. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  4758. $i = 1;
  4759. $page_max = 1;
  4760. if ($on_page > 10) {
  4761. $page_max = intval ( $on_page / 10 ) + 1;
  4762. $i = intval ( $on_page / 10 ) * 10 - 1;
  4763. }
  4764. for(; $i <= $page ['total_page']; $i ++) {
  4765. if ($i == $on_page) {
  4766. if ($other == "page")
  4767. $page_c .= '<a href="javascript:void(0);" class="current">' . $i . '</a>';
  4768. else
  4769. $page_c .= '&nbsp;<span class="current">' . $i . '</span>&nbsp;';
  4770. } else if ($other == "page")
  4771. $page_c .= '<a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a>';
  4772. else
  4773. $page_c .= '&nbsp;<a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a>&nbsp;';
  4774. if ($i == (10 * $page_max))
  4775. break;
  4776. }
  4777. $page ['page'] = $page_c;
  4778. $page ['lower'] = (-- $on_page) * $page_size;
  4779. return $page;
  4780. }
  4781. /**
  4782. * 获取总页数
  4783. * @param unknown_type $table
  4784. * @param unknown_type $condition
  4785. */
  4786. public function get_table_Tcount($table = "", $condition = "",$tagSQL) {
  4787. if ($tagSQL)
  4788. $sql = "select count(*) as count from CLD_tagCompanyNexus as a left join CLD_company as b on (a.company=b.cid ) where ".$condition ;
  4789. else
  4790. $sql = "select count(*) as count from CLD_company where " . $condition ;
  4791. $query = Doo::db ()->query ( $sql );
  4792. $result = $query->fetch ();
  4793. return $result ['count'];
  4794. }
  4795. /**
  4796. * 获取总页数
  4797. * @param unknown_type $table
  4798. * @param unknown_type $condition
  4799. */
  4800. public function get_table_count($table = "", $condition = "",$staffid="",$search,$tooltip,$cateid,$tagSQL) {
  4801. //$sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  4802. //echo $staffid;die;
  4803. //
  4804. if (!empty($staffid)){
  4805. //$staffid="and a.sid= '".$staffid."'"; " . $table . " as a left join on (a.cid=b.cid ".$staffid.")
  4806. $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 ;
  4807. }else{
  4808. if(strlen($condition)==1||empty($condition))
  4809. $sql = "select count(*) as count from CLD_client as a ".$condition;
  4810. else
  4811. $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;
  4812. }
  4813. if(!empty($search))
  4814. $sql = "select count(*) as count from CLD_client as a where 1 ".$condition ;
  4815. if(!empty($tooltip)){
  4816. $condition=str_replace("a.","c.",$condition);
  4817. if ($tagSQL)
  4818. $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 ;
  4819. else
  4820. $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 ;
  4821. }
  4822. //echo $sql;
  4823. $query = Doo::db ()->query ( $sql );
  4824. $result = $query->fetch ();
  4825. return $result ['count'];
  4826. }
  4827. }
  4828. ?>