12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197 |
- <?php
- /**
- * @author darkredz
- */
- class MainController extends DooController {
- public $staff;
-
-
- public $nature=array('1'=>'设计',
- '2'=>'造价管理',
- '3'=>'业主',
- '4'=>'交通局',
- '5'=>'公路局',
- '6'=>'审计',
- '7'=>'财政',
- '8'=>'审核',
- '9'=>'施工',
- '10'=>'咨询',
- '11'=>'招标代理',
- '12'=>'监理',
- '13'=>'学校',
- '14'=>'个人',
- '15'=>'合作伙伴',
- );
- public $tooltip=array('1'=>array('L','点击筛选标签'),
- '2'=>array('M','点击筛选标签'),
- '3'=>array('N','点击筛选标签'),
- '4'=>array('O','点击筛选标签'),
- '5'=>array('P','点击筛选标签'),
- '6'=>array('Q','点击筛选标签'),
- '7'=>array('R','点击筛选标签'),
- );
- public $webPath="http://cld.smartcost.com.cn/upload/emailAnnex/";
- function __construct() {
- //include './protected/config/common.conf.php';
- //include $config['BASE_PATH'].'diagnostic/debug.php';
- if(isset($_COOKIE["staff"])){
- if(!empty($_COOKIE["staff"])){
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- $this->staff=$staff->getUserByIdList($_COOKIE["staff"]);
-
- return "/";
- }
- }
- Doo::loadCore ( 'uri/DooUriRouter' );
- $router = new DooUriRouter ();
- $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
- if($routeRs['1']!="login"){
- header ( 'Content-Type:text/html;charset=utf-8' );
- @header ( "Location: /login" );
- }
- }
- function isMobile()
- {
- // 如果有HTTP_X_WAP_PROFILE则一定是移动设备
- if (isset ($_SERVER['HTTP_X_WAP_PROFILE']))
- {
- return true;
- }
- // 如果via信息含有wap则一定是移动设备,部分服务商会屏蔽该信息
- if (isset ($_SERVER['HTTP_VIA']))
- {
- // 找不到为flase,否则为true
- return stristr($_SERVER['HTTP_VIA'], "wap") ? true : false;
- }
- // 脑残法,判断手机发送的客户端标志,兼容性有待提高
- if (isset ($_SERVER['HTTP_USER_AGENT']))
- {
- $clientkeywords = array ('nokia',
- 'sony',
- 'ericsson',
- 'mot',
- 'samsung',
- 'htc',
- 'sgh',
- 'lg',
- 'sharp',
- 'sie-',
- 'philips',
- 'panasonic',
- 'alcatel',
- 'lenovo',
- 'iphone',
- 'ipod',
- 'blackberry',
- 'meizu',
- 'android',
- 'netfront',
- 'symbian',
- 'ucweb',
- 'windowsce',
- 'palm',
- 'operamini',
- 'operamobi',
- 'openwave',
- 'nexusone',
- 'cldc',
- 'midp',
- 'wap',
- 'mobile'
- );
- // 从HTTP_USER_AGENT中查找手机浏览器的关键字
- if (preg_match("/(" . implode('|', $clientkeywords) . ")/i", strtolower($_SERVER['HTTP_USER_AGENT'])))
- {
- return true;
- }
- }
- // 协议法,因为有可能不准确,放到最后判断
- if (isset ($_SERVER['HTTP_ACCEPT']))
- {
- // 如果只支持wml并且不支持html那一定是移动设备
- // 如果支持wml和html但是wml在html之前则是移动设备
- 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'))))
- {
- return true;
- }
- }
- return false;
- }
-
-
- function login(){
- $passwork = $this->get_args('passwork') ? $this->get_args('passwork') : 0;
- $uid = $this->get_args('user') ? $this->get_args('user') : 0;
-
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- if(!empty($passwork)){
- $userinfo=$staff->checkUser($uid,$passwork);
- if(!empty($userinfo)){
- setcookie("staff", $XDeode->encode ( $userinfo[0]['sid'] ), time()+36000,"/");
- return "/";
- }
- }
- $data ['staff'] = "";//$staff->getUser ();
- $data['login']="";
- if(!empty($passwork))
- $data['login']="inputErrow";
- $this->render ( "/login", $data );
- }
- function out(){
- setcookie("staff", "", time()-3600,"/");
- return "/";
- }
- function index2()
- {
- //include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
- $cid = $this->get_args('cid') ? $this->get_args('cid') : 0;
- $sid = $this->get_args('sid') ? $this->get_args('sid') : 0;
- $page = $this->get_args('page') ? $this->get_args('page') : 1;
- Doo::loadModel('action_log');
- $action_log = new action_log();
- Doo::loadModel('staff');
- $staff = new staff ();
- Doo::loadModel('client_staff');
- $client_staff = new client_staff();
- Doo::loadModel('longle');
- $longle = new longle();
- Doo::loadModel('L_category');
- $lcategory = new L_category ();
- $limit = 50;
- $p = $page;
- if ($page != 1)
- $page = $page * $limit - 1;
- else
- $page--;
- $condition = "";
- // if (!empty($cid) && $cid != 12) {
- // $condition = " and cid=" . $cid . " and sid=" . $sid;
- // }
- $staffCondition = "";
- $categorylist2 = array();
- if ($this->staff[0]['cid'] != 12) {
- $staffCondition = " and cid=" . $this->staff[0]['cid'];
- array_push($categorylist2, array('cid' => $this->staff[0]['cid'], 'title' => $this->staff[0]['category']));
- if (!empty($sid))
- $condition = " and cid=" . $this->staff[0]['cid'] . " and sid=" . $sid;
- else
- $condition = " and cid=" . $this->staff[0]['cid'];
- } else {
- $sql = 'SELECT `CLD_L_category`.cid,`CLD_L_category`.title,count(`CLD_staff`.sid) as count FROM `CLD_L_category` left join `CLD_staff` on `CLD_L_category`.cid=`CLD_staff`.cid group by `CLD_staff`.cid HAVING count(`CLD_staff`.sid)>0 order by count(`CLD_staff`.sid) desc';
- $query = Doo::db()->query($sql);
- $result = $query->fetchAll();
- $categorylist2 = $result;
- }
- if (!empty($cid)){
- $staffCondition = " and cid=" . $cid;
- if (!empty($sid))
- $condition = " and cid=" . $cid . " and sid=" . $sid;
- else
- $condition = " and cid=" . $cid;
- }
- /*
- $itemCategoryList=$action_log->find(array('select'=>'updatetime,COUNT(*)',
- 'where'=>" Year(updatetime)=2014",'groupby'=>'Month(updatetime)','asArray'=>true));
- print_r($itemCategoryList);die;
- */
- $staffList=$staff->find(array('where'=>' username!="admin" '.$staffCondition,'asArray'=>true));
- $actionLogList=$action_log->find(array('where'=>' 1 '.$condition,'limit'=>$page.','.$limit,'desc'=>'aid','asArray'=>true));
-
- //echo $condition;
-
- //抽取日期 ,'groupby'=>'updatetime'
- $dateLog=$action_log->find(array('select'=>'updatetime','where'=>' 1 '.$condition,'limit'=>$limit,'desc'=>'aid','asArray'=>true));
- $dl=array();
- foreach ($dateLog as $value){
- array_push($dl, $value['updatetime']);
- }
- $dateLog=array_unique($dl);
- $log=array();
- foreach ($dateLog as $key=>$value){
- $log[$value]=array();
- foreach ($actionLogList as $k=>$v){
- if($value==$v['updatetime']){
- array_push($log[$value], $v);
- unset($actionLogList[$k]);
- }
- }
- }
- $max=array();
- foreach($staffList as $key=>$value){
- $staffList[$key]['count']=$client_staff->count(array('where'=>'sid='.$value['sid'],'asArray'=>true));
- array_push($max, $staffList[$key]['count'].':'.$value['username']);
- }
- rsort($max,SORT_NUMERIC);$sum=0;
- foreach ($max as $key=>$value){
- $max[$key]=explode(":", $value);
- $sum+=$max[$key][0];
- }
- $max2=$max;
- array_shift($max2);array_shift($max2);array_shift($max2);
- $lcategoryList=$lcategory->find(array('asArray'=>true));$useL=array();$Rsum=$Ssum=0;
- foreach ($lcategoryList as $key=>$value){
- $longleR=$longle->count(array('where'=>'cid='.$value['cid'],'asArray'=>true));
- $longleS=$longle->count(array('where'=>'cid='.$value['cid'].' and status!=1 and status!=2','asArray'=>true));
- $Rsum+=$longleR;$Ssum+=$longleS;
- if(!empty($longleS))
- array_push($useL, round(($longleS/$longleR)*100).'% :'.$value['title'] );
- else
- array_push($useL, '0% :'.$value['title'] );
- }
- rsort($useL,SORT_NUMERIC);//$sum=0;
- foreach ($useL as $key=>$value){
- $useL[$key]=explode(":", $value);
- //$sum+=$max[$key][0];
- }
- $useL2=$useL;
- array_shift($useL2);array_shift($useL2);array_shift($useL2);
- $data['Ssum']=round(($Ssum/$Rsum)*100).'%';
- $data['Rsum']=$Rsum;
- $data['useL2']=$useL2;
- $data['useL']=$useL;
- $data['sum']=$sum;
- $data['max']=$max;
- $data['max2']=$max2;
- $data['log']=$log;
- $data['page']=$p;
- $data['staffList']=$staffList;
- $data['categorylist2']=$categorylist2;
- $data['cid']=$cid;
- $data['sid']=$sid;
- $data['memu']="index";
- $data['staff']=$this->staff;
- $this->render ( "index2", $data );
- }
- function indexPage(){
- $sid=$this->get_args('sid')?$this->get_args('sid'):0;
- $cid=$this->get_args('cid')?$this->get_args('cid'):0;
- $page=$this->get_args('page')?$this->get_args('page'):1;
- Doo::loadModel('action_log');
- $action_log=new action_log();
- $limit=50;$p=$page;
- // if ($page!=1)
- // $page=$page*$limit-1;
- // else
- // $page--;
-
- $page = (-- $p) * $limit;
-
- /*
- $condition="";
- if (!empty($cid)&&$cid!=12){
- $condition=" and cid=".$cid;
- }
- $staffCondition="";
- if($this->staff[0]['cid']!=12){
- $staffCondition=" and cid=".$this->staff[0]['cid'];
- $condition=" and cid=".$this->staff[0]['cid'];
- }
- */
- $condition="";
- if (!empty($cid)&&$cid!=12){
- $condition=" and cid=".$cid." and sid=".$sid;
- }
- $staffCondition="";
- if($this->staff[0]['cid']!=12){
- $staffCondition=" and cid=".$this->staff[0]['cid'];
- if(!empty($sid))
- $condition=" and cid=".$this->staff[0]['cid']." and sid=".$sid;
- else
- $condition=" and cid=".$this->staff[0]['cid'];
- }
- $actionLogList=$action_log->find(array('where'=>' 1 '.$condition,'limit'=>$page.','.$limit,'desc'=>'aid','asArray'=>true));
- //抽取日期 ,'groupby'=>'updatetime'
- $dateLog=$action_log->find(array('select'=>'updatetime','where'=>' 1 '.$condition,'limit'=>$page.','.$limit,'desc'=>'aid','asArray'=>true));
- $dl=array();
- foreach ($dateLog as $value){
- array_push($dl, $value['updatetime']);
- }
- $dateLog=array_unique($dl);
- $log=array();
- foreach ($dateLog as $key=>$value){
- $log[$value]=array();
- foreach ($actionLogList as $k=>$v){
- if($value==$v['updatetime']){
- array_push($log[$value], $v);
- unset($actionLogList[$k]);
- }
- }
- }
- $html='';
- foreach ($log as $key=>$value){
- $html.='<div class="item">
- <div class="date">'.$key.'</div>
- <dl class="recordList clearfix">';
- foreach ($value as $k=>$v){
- $html.='<dd class="'.$v['class'].'"><span class="fR">'.$v['time'].'</span>'.$v['action'].'</dd>';
- }
- $html.='</dl></div>';
- }
- echo $html;
- }
- function logStatistics(){
- $sid=$this->get_args('sid')?$this->get_args('sid'):0;
- $cid=$this->get_args('cid')?$this->get_args('cid'):0;
- Doo::loadModel('action_log');
- $action_log=new action_log();
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadModel('client_staff');
- $client_staff=new client_staff();
- Doo::loadModel('longle');
- $longle=new longle();
- Doo::loadModel('L_category');
- $lcategory = new L_category ();
- $staffCondition="";
- $categorylist2=array();
- if($this->staff[0]['cid']!=12){
- $staffCondition=" and cid=".$this->staff[0]['cid'];
- array_push($categorylist2,array('cid'=>$this->staff[0]['cid'],'title'=>$this->staff[0]['category']));
- }else{
- $sql = 'SELECT `CLD_L_category`.cid,`CLD_L_category`.title,count(`CLD_staff`.sid) as count FROM `CLD_L_category` left join `CLD_staff` on `CLD_L_category`.cid=`CLD_staff`.cid group by `CLD_staff`.cid HAVING count(`CLD_staff`.sid)>0 order by count(`CLD_staff`.sid) desc';
- $query = Doo::db ()->query ( $sql );
- $result = $query->fetchAll ();
- $categorylist2 = $result;
- }
- if(!empty($cid))
- $staffCondition=" and cid=".$cid;
- //Doo::db()->beginTransaction();
- $staffList=$staff->find(array('where'=>' username !="admin"'.$staffCondition,'asArray'=>true));
- $max=array();$kkk=array();
-
- foreach($staffList as $key=>$value){
- $staffList[$key]['count']=$client_staff->count(array('where'=>'sid='.$value['sid'],'asArray'=>true));
-
- array_push($max, $staffList[$key]['count'].':'.$value['username']);
- if ($this->staff[0]['cid']==12)
- array_push($kkk, $staffList[$key]['count']);
- if ($this->staff[0]['cid']==$value['cid']&&$this->staff[0]['cid']!=12){
- array_push($kkk, $staffList[$key]['count']);
- }
- }
- $sum=0;
- foreach ($kkk as $key=>$value){
- $sum+=$value;
- }
-
- rsort($max,SORT_NUMERIC);
- foreach ($max as $key=>$value){
- $max[$key]=explode(":", $value);
- //$sum+=$max[$key][0];
- }
- $max2=$max;
- array_shift($max2);array_shift($max2);array_shift($max2);
- $lcategoryList=$lcategory->find(array('asArray'=>true));$useL=array();$Rsum=$Ssum=0;
- foreach ($lcategoryList as $key=>$value){
- $longleR=$longle->count(array('where'=>'cid='.$value['cid'],'asArray'=>true));
- $longleS=$longle->count(array('where'=>'cid='.$value['cid'].' and status!=1 and status!=2','asArray'=>true));
- $Rsum+=$longleR;$Ssum+=$longleS;
- if(!empty($longleS))
- array_push($useL, round(($longleS/$longleR)*100).'% :'.$value['title'] );
- else
- array_push($useL, '0% :'.$value['title'] );
- }
-
- //Doo::db()->commit();
- rsort($useL,SORT_NUMERIC);//$sum=0;
- foreach ($useL as $key=>$value){
- $useL[$key]=explode(":", $value);
- //$sum+=$max[$key][0];
- }
- $useL2=$useL;
- array_shift($useL2);array_shift($useL2);array_shift($useL2);
- //statistics
- $categoryCondition=" and cid=".$this->staff[0]['cid'];
- $sidCondition="";
- if (!empty($cid))
- $categoryCondition=" and cid=".$cid;
- if(!empty($sid))
- $sidCondition=" and sid=".$sid;
- if($this->staff[0]['cid']==12&&empty($cid)){
- $categoryCondition="";
- }
- // Year(updatetime)=".date('Y')." and Month(updatetime)=".date('m')." date_format(updatetime,"%m-%d")
-
- $actionLogClient=$action_log->find(array('select'=>'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
- 'where'=>" date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=1".$categoryCondition.$sidCondition,'groupby'=>'date_format(updatetime,"%m-%d")','asArray'=>true));
- $actionLogLongle=$action_log->find(array('select'=>'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
- 'where'=>" date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=3".$categoryCondition.$sidCondition,'groupby'=>'date_format(updatetime,"%m-%d")','asArray'=>true));
-
- //$actionLogClient=array();
- //$actionLogLongle=array();
-
- $statisticsDay=array();
- $statisticsClient=$statisticsLongle=array();
- for ($d=0;$d<=29;$d++){
- $MD=date("m-d",strtotime("-".$d." day"));$falgClient=$falgLongle=true;
- array_push($statisticsDay, $MD);
- foreach ($actionLogClient as $value){
- if($value['updatetime']==$MD){
- array_push($statisticsClient, $value['count']);$falgClient=false;break;
- }
- }
- if ($falgClient)
- array_push($statisticsClient,0);
- foreach ($actionLogLongle as $value){
- if($value['updatetime']==$MD){
- array_push($statisticsLongle, $value['count']);$falgLongle=false;break;
- }
- }
- if ($falgLongle)
- array_push($statisticsLongle,0);
- }
- //print_r($actionLogLongle);
- $statisticsClient=array_reverse($statisticsClient);
- $statisticsLongle=array_reverse($statisticsLongle);
- $statisticsDay=array_reverse($statisticsDay);
-
- /// Year(updatetime)=".date('Y')." and Month(updatetime)=".date('m')." and
- $categoryList=$lcategory->find(array('asArray'=>true));
- $CategoryClient=$action_log->find(array('select'=>'cid,COUNT(*) as count,city',
- 'where'=>" date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=1".$categoryCondition.$sidCondition,'groupby'=>'cid','asArray'=>true));
- //or status=2
- $CategoryCompany=$action_log->find(array('select'=>'cid, COUNT(*) as count,company,districtid',
- 'where'=>" date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and (status=1 )".$categoryCondition.$sidCondition,'groupby'=>'cid,districtid,company','asArray'=>true));
-
- $natureList=$action_log->find(array('select'=>'cid, COUNT(*) as count,nature',
- 'where'=>" date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=1 and nature !=''".$categoryCondition.$sidCondition,'groupby'=>'nature','asArray'=>true));
- $statisticsCategory=array();$statisticsCompany=array();
- foreach ($categoryList as $value){
- $falgClient=$falgLongle=true;
- foreach ($CategoryClient as $v){
- if($value['cid']==$v['cid']&&$v['cid']!=12){
- array_push($statisticsCategory, array('value'=>$v['count'],'name'=>str_replace("办","省",$value['title'])));$falgClient=false;break;
- }
- }
- if ($falgClient){
- array_push($statisticsCategory, array('value'=>0,'name'=>str_replace("办","省",$value['title'])));
- }
- //company statistics
- $i=0;
- foreach ($CategoryCompany as $v){
- if($value['cid']==$v['cid']&&$v['cid']!=12){
- $i++;
- }
- }
- array_push($statisticsCompany, array('value'=>$i,'name'=>str_replace("办","省",$value['title'])));
- }
- //print_r($CategoryClient);
- $statisticsNature=array();
- foreach ($this->nature as $value){
- $flagNature=true;
- foreach ($natureList as $v){
- if ($value==$v['nature']){
- array_push($statisticsNature, array('value'=>$v['count'],'name'=>$value));$flagNature=false;break;
- }
- }
- if ($flagNature)
- array_push($statisticsNature, array('value'=>0,'name'=>$value));
- }
- //print_r($max2);//die;
- $data['statisticsNature']=json_encode($statisticsNature);
- $data['statisticsCompany']=json_encode($statisticsCompany);
- $data['statisticsCategory']=json_encode($statisticsCategory);
- $data['statisticsDay']=json_encode($statisticsDay);
- $data['statisticsClient']=json_encode($statisticsClient);
- $data['statisticsLongle']=json_encode($statisticsLongle);
- $data['categorylist2']=$categorylist2;
- $data['Ssum']=round(($Ssum/$Rsum)*100).'%';
- $data['Rsum']=$Rsum;
- $data['useL2']=$useL2;
- $data['useL']=$useL;
- $data['sum']=$sum;
- $data['max']=$max;
- $data['max2']=$max2;
- $data['staffList']=$staffList;
- $data['cid']=$cid;
- $data['sid']=$sid;
- $data['memu']="index";
- $data['staff']=$this->staff;
- $this->render ( "/indexStat", $data );
- }
- function longleStatistics(){
- $sid=$this->get_args('sid')?$this->get_args('sid'):0;
- $cid=$this->get_args('cid')?$this->get_args('cid'):0;
- $status=$this->get_args('status')?$this->get_args('status'):4;
- $districtH=$this->get_args('district')?$this->get_args('district'):0;
- Doo::loadModel('action_log');
- $action_log=new action_log();
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadModel('client_staff');
- $client_staff=new client_staff();
- Doo::loadModel('longle');
- $longle=new longle();
- Doo::loadModel('L_category');
- $lcategory = new L_category ();
- Doo::loadModel('district');
- $district = new district ();
- $staffCondition="";
- $categorylist2=array();
- if($this->staff[0]['cid']!=12){
- $staffCondition=" and cid=".$this->staff[0]['cid'];
- array_push($categorylist2,array('cid'=>$this->staff[0]['cid'],'title'=>$this->staff[0]['category']));
- }else{
- $sql = 'SELECT `CLD_L_category`.cid,`CLD_L_category`.title,count(`CLD_staff`.sid) as count FROM `CLD_L_category` left join `CLD_staff` on `CLD_L_category`.cid=`CLD_staff`.cid group by `CLD_staff`.cid HAVING count(`CLD_staff`.sid)>0 order by count(`CLD_staff`.sid) desc';
- $query = Doo::db ()->query ( $sql );
- $result = $query->fetchAll ();
- $categorylist2 = $result;
- }
- if(!empty($cid))
- $staffCondition=" and cid=".$cid;
- $staffList=$staff->find(array('where'=>' username!="admin"'.$staffCondition,'asArray'=>true));
- $max=array();
- foreach($staffList as $key=>$value){
- $staffList[$key]['count']=$client_staff->count(array('where'=>'sid='.$value['sid'],'asArray'=>true));
- array_push($max, $staffList[$key]['count'].':'.$value['username']);
- }
- rsort($max,SORT_NUMERIC);$sum=0;
- foreach ($max as $key=>$value){
- $max[$key]=explode(":", $value);
- $sum+=$max[$key][0];
- }
- $max2=$max;
- array_shift($max2);array_shift($max2);array_shift($max2);
- $lcategoryList=$lcategory->find(array('asArray'=>true));$useL=array();$Rsum=$Ssum=0;
- foreach ($lcategoryList as $key=>$value){
- $longleR=$longle->count(array('where'=>'cid='.$value['cid'],'asArray'=>true));
- $longleS=$longle->count(array('where'=>'cid='.$value['cid'].' and status!=1 and status!=2','asArray'=>true));
- $Rsum+=$longleR;$Ssum+=$longleS;
- if(!empty($longleS))
- array_push($useL, round(($longleS/$longleR)*100).'% :'.$value['title'] );
- else
- array_push($useL, '0% :'.$value['title'] );
- }
- rsort($useL,SORT_NUMERIC);//$sum=0;
- foreach ($useL as $key=>$value){
- $useL[$key]=explode(":", $value);
- //$sum+=$max[$key][0];
- }
- $useL2=$useL;
- array_shift($useL2);array_shift($useL2);array_shift($useL2);
- //statistics
- $categoryCondition=" and cid=".$this->staff[0]['cid'];
- $sidCondition="";
- if (!empty($cid))
- $categoryCondition=" and cid=".$cid;
- if(!empty($sid))
- $sidCondition=" and sid=".$sid;
- if($this->staff[0]['cid']==12&&empty($cid)){
- $categoryCondition="";
- }
- // Year(updatetime)=".date('Y')." and Month(updatetime)=".date('m')." date_format(updatetime,"%m-%d") Day(updatetime)
- $actionLogClient=$action_log->find(array('select'=>'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
- 'where'=>" date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=4".$categoryCondition.$sidCondition,'groupby'=>'Day(updatetime)','asArray'=>true));
- $actionLogLongle=$action_log->find(array('select'=>'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
- 'where'=>" date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=5".$categoryCondition.$sidCondition,'groupby'=>'Day(updatetime)','asArray'=>true));
- $actionLogGet=$action_log->find(array('select'=>'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
- 'where'=>" date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=6".$categoryCondition.$sidCondition,'groupby'=>'Day(updatetime)','asArray'=>true));
- $statisticsDay=array();
- $statisticsClient=$statisticsLongle=$statisticsGet=array();
- /**
- for ($d=1;$d<=date("t");$d++){
- $MD=date('m')."-".$d;
- */
- for ($d=0;$d<=29;$d++){
- $MD=date("m-d",strtotime("-".$d." day"));$falgClient=$falgLongle=$falgGet=true;
- array_push($statisticsDay, $MD);
- foreach ($actionLogClient as $value){
- if($value['updatetime']==$MD){
- array_push($statisticsClient, $value['count']);$falgClient=false;break;
- }
- }
- if ($falgClient)
- array_push($statisticsClient,0);
- foreach ($actionLogLongle as $value){
- if($value['updatetime']==$MD){
- array_push($statisticsLongle, $value['count']);$falgLongle=false;break;
- }
- }
- if ($falgLongle)
- array_push($statisticsLongle,0);
- foreach ($actionLogGet as $value){
- if($value['updatetime']==$MD){
- array_push($statisticsGet, $value['count']);$falgGet=false;break;
- }
- }
- if ($falgGet)
- array_push($statisticsGet,0);
- }
- $statisticsClient=array_reverse($statisticsClient);
- $statisticsLongle=array_reverse($statisticsLongle);
- $statisticsGet=array_reverse($statisticsGet);
- $statisticsDay=array_reverse($statisticsDay);
- ///
- $districtCondition="";
- $topDistrict=$district->get_lvByid(0,0);
- if (!empty($sid)){
- $s=$staff->getOne(array('where'=>' sid='.$sid,'asArray'=>true));
- $l=$lcategory->find(array('where'=>' cid in('.$s['cid'].')','asArray'=>true));
- if(!empty($s['othercid']))
- $l=$lcategory->find(array('where'=>' cid in('.$s['cid'].','.$s['othercid'].')','asArray'=>true));
- if (!empty($districtH)){
- $districtCondition=" and districtid like '".$districtH.",%'";
- $sidCondition="";
- $topDistrict=$district->find(array('where'=>' upid='.$districtH,'asArray'=>true));
- }else{
- $districtCondition=" and districtid like '".$l[0]['districtid'].",%'";
- $sidCondition="";
- $topDistrict=$district->find(array('where'=>' upid='.$l[0]['districtid'],'asArray'=>true));
- }
- $str=array();
- foreach ($l as $value){
- array_push($str, $value['districtid']);
- }
- $str=implode(",", $str);
- $data['districtHtml']=$district->find(array('where'=>' id in ('.$str.')','asArray'=>true));
- $data['districtH']=$l[0]['districtid'];
- if (!empty($districtH))
- $data['districtH']=$districtH;
- }
- // Year(updatetime)=".date('Y')." and Month(updatetime)=".date('m')." and
- if (!empty($sid))
- $districtClient=$action_log->find(array('select'=>'city,province,COUNT(*) as count',
- 'where'=>" date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=".$status.$categoryCondition.$sidCondition.$districtCondition,'groupby'=>'province','asArray'=>true));
- else
- $districtClient=$action_log->find(array('select'=>'city,province,COUNT(*) as count',
- 'where'=>" date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=".$status.$categoryCondition.$sidCondition.$districtCondition,'groupby'=>'city','asArray'=>true));
- $statisticsLend=array();$statisticsCompany=array();
- if(!empty($sid)){
- foreach ($topDistrict as $value){
- $falgLend=$falgLongle=true;
- foreach ($districtClient as $v){
- if($value['name']==$v['province']){
- array_push($statisticsLend, array('value'=>$v['count'],'name'=>$value['name']));$falgLend=false;break;
- }
- }
- if ($falgLend)
- array_push($statisticsLend, array('value'=>0,'name'=>$value['name']));
- }
- }else{
- foreach ($topDistrict as $value){
- $falgLend=$falgLongle=true;
- foreach ($districtClient as $v){
- if($value['name']==$v['city']){
- array_push($statisticsLend, array('value'=>$v['count'],'name'=>$value['name']));$falgLend=false;break;
- }
- }
- if ($falgLend)
- array_push($statisticsLend, array('value'=>0,'name'=>$value['name']));
- }
- }
- //print_r($statisticsLend);die;
- $natureList=$action_log->find(array('select'=>'cid, COUNT(*) as count,nature',
- 'where'=>" date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=".$status." and nature !=''".$categoryCondition.$sidCondition.$districtCondition,'groupby'=>'nature','asArray'=>true));
- $statisticsNature=array();
- foreach ($this->nature as $value){
- $flagNature=true;
- foreach ($natureList as $v){
- if ($value==$v['nature']){
- array_push($statisticsNature, array('value'=>$v['count'],'name'=>$value));$flagNature=false;break;
- }
- }
- if ($flagNature)
- array_push($statisticsNature, array('value'=>0,'name'=>$value));
- }
- $data['statisticsNature']=json_encode($statisticsNature);
- //print_r($statisticsLend);die;
- $data['statisticsLend']=json_encode($statisticsLend);
- $data['status']=$status;
- $data['statisticsDay']=json_encode($statisticsDay);
- $data['statisticsClient']=json_encode($statisticsClient);
- $data['statisticsLongle']=json_encode($statisticsLongle);
- $data['statisticsGet']=json_encode($statisticsGet);
- $data['categorylist2']=$categorylist2;
- $data['Ssum']=round(($Ssum/$Rsum)*100).'%';
- $data['Rsum']=$Rsum;
- $data['useL2']=$useL2;
- $data['useL']=$useL;
- $data['sum']=$sum;
- $data['max']=$max;
- $data['max2']=$max2;
- $data['staffList']=$staffList;
- $data['cid']=$cid;
- $data['sid']=$sid;
- $data['memu']="index";
- $data['staff']=$this->staff;
- $this->render ( "/indexLongle", $data );
- }
- function index() {die('dd');
- $data['memu']="index";
- $data['staff']=$this->staff;
- Doo::loadModel('action_log');
- $action_log=new action_log();
- $data['today']=explode("-", date("Y-m-d"));
- $str="";
- if($this->staff[0]['isadmin']!=1){
- $str=" and (action like '%".$this->staff[0]['category']."%'";
- $khql=explode(",", $this->staff[0]['othercategory']);
- if(!empty($khql[0])){
- foreach ($khql as $key=>$value){
- $str.=" or action like '%".$value."%'";
- }
- $str.=")";
- }else
- $str.=")";
- }
- $data['actionListNow']=$action_log->find(array('where'=>' updatetime=\''.date("Y-m-d")."'".$str ,'desc'=>'aid','asArray' => TRUE));
- $d2 = mktime(0,0,0,date("m"),date("d")-1,date("Y"));
- $strdate=date("Y-m-d", $d2);
- $data['day2']=explode("-", $strdate);
- $data['actionListNow2']=$action_log->find(array('where'=>' updatetime=\''.$strdate."'".$str,'desc'=>'aid','asArray' => TRUE));
- $d3 = mktime(0,0,0,date("m"),date("d")-2,date("Y"));
- $strdate=date("Y-m-d", $d3);
- $data['day3']=explode("-", $strdate);
- $data['actionListNow3']=$action_log->find(array('where'=>' updatetime=\''.$strdate."'".$str,'desc'=>'aid','asArray' => TRUE));
- $d4 = mktime(0,0,0,date("m"),date("d")-3,date("Y"));
- $strdate=date("Y-m-d", $d4);
- $data['day4']=explode("-", $strdate);
- $data['actionListNow4']=$action_log->find(array('where'=>' updatetime=\''.$strdate."'".$str,'asArray' => TRUE));
- $d5 = mktime(0,0,0,date("m"),date("d")-4,date("Y"));
- $strdate=date("Y-m-d", $d5);
- $data['day5']=explode("-", $strdate);
- $data['actionListNow5']=$action_log->find(array('where'=>' updatetime=\''.$strdate."'".$str,'asArray' => TRUE));
- $d6 = mktime(0,0,0,date("m"),date("d")-5,date("Y"));
- $strdate=date("Y-m-d", $d6);
- $data['day6']=explode("-", $strdate);
- $data['actionListNow6']=$action_log->find(array('where'=>' updatetime=\''.$strdate."'".$str,'asArray' => TRUE));
- $d7 = mktime(0,0,0,date("m"),date("d")-6,date("Y"));
- $strdate=date("Y-m-d", $d7);
- $data['day7']=explode("-", $strdate);
- $data['actionListNow7']=$action_log->find(array('where'=>' updatetime=\''.$strdate."'".$str,'asArray' => TRUE));
- Doo::loadModel('staff');
- Doo::loadModel('client_staff');
- $client_staff=new client_staff();
- $staff=new staff();
- $st=$staff->find(array('where'=>'1','asArray'=>true));
- foreach($st as $key=>$value){
- $st[$key]['count']=$client_staff->count(array('where'=>'sid='.$value['sid'],'asArray'=>true));
- }
- $data['staffCount']=$st;
- $this->render ( "/index", $data );
- }
- function receive(){
- $data['memu']="keyonline";
- $data['staff']=$this->staff;
- Doo::loadModel ( 'longle' );
- $longle = new longle ();
- $data['arrayReceive']=$longle->getLongleReceive($this->staff[0]['cid'],1,$this->staff[0]['othercid']);
- $this->render ( "/look_receive", $data );
- }
- function doLongleReceive(){
- $arrLid=isset($_POST['lid'])?$_POST['lid']:array();
- Doo::loadModel ( 'longle_log' );
- Doo::loadModel ( 'longle' );
- foreach ($arrLid as $key=>$value){
- $ky=explode("-", $value);
- $longle = new longle ();
- $longle_log = new longle_log ();
- $longle->lid=$ky[0];
- $longle->status=2;
- $longle->statusT='接收';
- $longle->responsible=$this->staff[0]['username'];
- //记录锁状态
- $longle->statuslog="1,2";
- $longle->update();
- $longle_log->lid=$ky[0];
- $longle_log->status=2;
- $longle_log->statusT='接收';
- $longle_log->responsible=$this->staff[0]['username'];
- $longle_log->operator=$this->staff[0]['username'];
- $longle_log->category=$ky[1];
- $longle_log->dateline=date("Y-m-d");
- $longle_log->insert();
- }
- return "/receive";
- }
- function addClient(){
- $clientname=isset($_POST['clientname'])?$_POST['clientname']:"";
- $gender=isset($_POST['gender'])?$_POST['gender']:"";
- $nicename=isset($_POST['nicename'])?$_POST['nicename']:"";
- $telephone=isset($_POST['telephone'])?$_POST['telephone']:"";
- $phone=isset($_POST['phone'])?$_POST['phone']:"";
- $email=isset($_POST['email'])?$_POST['email']:"";
- $qq=isset($_POST['qq'])?$_POST['qq']:"";
- $tid=isset($_POST['tid'])?$_POST['tid']:"";
- $companyname=isset($_POST['companyname'])?$_POST['companyname']:"";
- $local1=isset($_POST['lv21'])?$_POST['lv21']:0;
- $local2=isset($_POST['lv22'])?$_POST['lv22']:0;
- $local3=isset($_POST['lv23'])?$_POST['lv23']:0;
- $nature=isset($_POST['nature'])?$_POST['nature']:"";
- $fax=isset($_POST['fax'])?$_POST['fax']:"";
- $webservice=isset($_POST['webservice'])?$_POST['webservice']:"";
- $department=isset($_POST['department'])?$_POST['department']:"";
- $position=isset($_POST['position'])?$_POST['position']:"";
- $office=isset($_POST['office'])?$_POST['office']:"";
- $address=isset($_POST['address'])?$_POST['address']:"";
- $ride=isset($_POST['ride'])?$_POST['ride']:"";
- $landmarks=isset($_POST['landmarks'])?$_POST['landmarks']:"";
- $priority=isset($_POST['priority'])?$_POST['priority']:5;
- $stay=isset($_POST['stay'])?$_POST['stay']:"";
- $mark=isset($_POST['mark'])?$_POST['mark']:"";
- $clientname=trim($clientname);
- $companyname=trim($companyname);
- if(empty($companyname))
- return "/contacts";
- if(empty($this->staff[0]['sid']))
- return "/contacts";
- if(!empty($clientname)){
- //相同的公司和客户
- Doo::loadModel ( 'company' );
- $company = new company ();
- Doo::loadModel ( 'client' );
- $client = new client ();
- $cinfo=$client->getClientByNameT($clientname);
- if(!empty($cinfo)){
- $ninfo=$company->getCompanyByCompanyname($companyname);
- if(!empty($ninfo)){
- foreach ($cinfo as $key=>$value){//问题
- if($value['companyid']==$ninfo[0]['cid'])
- return "/contacts";
- }
- }
- }
- Doo::loadModel ( 'district' );
- $district = new district ();
- $companyInfo=$company->getOne(array('where'=>"companyname = '".$companyname."'","asArray"=>true));
- //更新公司信息
- $lv1=$district->getbyid($local1);
- $lv2=$district->getbyid($local2);
- $lv3=$district->getbyid($local3);
- if(empty($lv1))
- $lv1[0]['name']="";
- if(empty($lv2))
- $lv2[0]['name']="";
- if(empty($lv3))
- $lv3[0]['name']="";
- if(!empty($local1)&&!empty($local2))
- $company->local=$lv1[0]['name'].",".$lv2[0]['name'].",".$lv3[0]['name'];
- if(!empty($nature))
- $company->nature=implode(',', $nature);
- if(!empty($fax))
- $company->fax=$fax;
- if(!empty($webservice))
- $company->webservice=$webservice;
- if(!empty($address))
- $company->address=$address;
- if(!empty($ride))
- $company->ride=$ride;
- if(!empty($landmarks))
- $company->landmarks=$landmarks;
- if(!empty($office))
- $company->office=$office;
- if(!empty($local1)&&!empty($local2))
- $company->district=$local1.",".$local2.",".$local3;
- if(!empty($stay))
- $company->stay=$stay;
- if(empty($companyInfo)){
- $company->companyname=$companyname;
- $company->staffid=$this->staff[0]['sid'];
- $cid=$company->insert();
- }else{//不编辑公司,地区判断,作为新公司
- // $cid=$companyInfo['cid'];
- //
- // $companyname=$companyInfo['companyname'];
- //
- // $company->cid=$cid;
- //
- // $company->update();
- $diqu=$local1.",".$local2.",".$local3;
- $cid=$companyInfo['cid'];
- $company2 = new company ();
- $companyList=$company2->find(array('where'=>" companyname like '".$companyname."'","asArray"=>true));
- $falg=false;
- //print_r($companyList);
- foreach ($companyList as $key=>$value){
- if($value['district']!=$diqu){
- $falg=true;
- }elseif($value['district']==$diqu){
- $falg=false;
- $cid=$value['cid'];
- break;
- }
- }
- //var_dump($falg) ;die;
- if($falg){
- $company->companyname=$companyname;
- $company->staffid=$this->staff[0]['sid'];
- $cid=$company->insert();
- }
- }
- Doo::loadModel ( 'client_staff' );
- $client_staff = new client_staff ();
- $client->clientname=$clientname;
- $client->gender=$gender;
- $client->priority=$priority;
- if(!empty($nicename))
- $client->nicename=$nicename;
- if(!empty($telephone))
- $client->telephone=$telephone;
- if(!empty($phone))
- $client->phone=$phone;
- if(!empty($email))
- $client->email=$email;
- if(!empty($qq)&&is_numeric($qq))
- $client->qq=$qq;
- $client->companyid=$cid;
- $client->companyname=$companyname;
- $client->district=$local1.",".$local2.",".$local3;
- //echo $client->district;
- // die;
- if(!empty($tid))
- $client->tag=implode(',', $tid);
- if(!empty($fax))
- $client->fax=$fax;
- if(!empty($webservice))
- $client->webservice=$webservice;
- if(!empty($department))
- $client->department=$department;
- if(!empty($position))
- $client->position=$position;
- if(!empty($office))
- $client->office=$office;
- if(!empty($address))
- $client->address=$address;
- if(!empty($ride))
- $client->ride=$ride;
- if(!empty($landmarks))
- $client->landmarks=$landmarks;
- if(!empty($stay))
- $client->stay=$stay;
- if(!empty($mark))
- $client->mark=$mark;
- $id=$client->insert();
- $client_staff->cid=$id;
- $client_staff->sid=$this->staff[0]['sid'];
- $client_staff->insert();
- //加入地区记录
- Doo::loadModel("district_staff");
- $district_staff=new district_staff();
- $district_staff->did=$lv1[0]['id'];
- $district_staff->sid=$this->staff[0]['sid'];
- $district_staff->insert();
- //日常行为
- Doo::loadModel("action_log");
- $action_log=new action_log();
- $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.')';
- $action_log->sid=$this->staff[0]['sid'];
- $action_log->cid=$this->staff[0]['cid'];
- $action_log->updatetime=date("Y-m-d");
- $action_log->time=date("H:i");
- $action_log->status=1;
- $action_log->districtid=$local1.",".$local2.",".$local3;
- $action_log->city=$lv1[0]['name'];
- $action_log->province=$lv2[0]['name'];
- if (isset($nature[0]))
- $action_log->nature=$nature[0];
- $action_log->company=$companyname;
- $action_log->class=$action_log->iconContacts;
- $action_log->insert();
- }
- return "/contacts";
- }
- function mycompany(){
- $search=$this->get_args('search')?$this->get_args('search'):"";
- $districtLv=$this->get_args('districtLv')?$this->get_args('districtLv'):0;
- $nature=$this->get_args('nature')?$this->get_args('nature'):"";
- $lv1=$this->get_args('lv1')?$this->get_args('lv1'):0;
- $lv2=$this->get_args('lv2')?$this->get_args('lv2'):0;
- $lv3=$this->get_args('lv3')?$this->get_args('lv3'):0;
- $tagList=$this->get_args('tag')?$this->get_args('tag'):array();
- if ($lv1==0){
- $lv1=isset($this->params ['lv1'])&&is_numeric ( $this->params ['lv1'] ) ? $this->params ['lv1'] : 0;
- if ($lv1!=0)
- $districtLv=1;
- }
- if ($lv2==0){
- $lv2=isset($this->params ['lv2'])&&is_numeric ( $this->params ['lv2'] ) ? $this->params ['lv2'] : 0;
- if ($lv2!=0)
- $districtLv=2;
- }
- if ($lv3==0){
- $lv3=isset($this->params ['lv3'])&&is_numeric ( $this->params ['lv3'] ) ? $this->params ['lv3'] : 0;
- if ($lv2!=0)
- $districtLv=3;
- }
- if(empty($search))
- $search=urldecode(isset($this->params ['search'])?$this->params ['search']:"");
- $page = isset($this->params ['page'])&&is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
- $data['memu']="contacts";
- $data['staff']=$this->staff;
- Doo::loadModel ( 'district' );
- Doo::loadModel('company');
- Doo::loadModel('client');
- Doo::loadModel('tag');
- Doo::loadModel('L_category');
-
- $lcategory = new L_category ();
- $tag = new tag ();
- $client = new client();
- $company = new company();
- $district = new district ();
- Doo::loadModel('tagCompany');
- $tagCompany = new tagCompany ();
- Doo::loadModel('tagCompanyNexus');
- $tagCompanyNexus = new tagCompanyNexus ();
-
- $data['district2']=$district->get_lv(1);
- $category=$lcategory->getCategoryById($this->staff[0]['cid'],$this->staff[0]['othercid']);
- $cateStr="";
- $list=array();
- foreach ($category as $key=>$value){
- array_push($list, " district like '".$value['districtid'].",%' ");
- }
- if($this->staff[0]['isadmin']!=1)
- $cateStr=implode(" or ", $list);
- else
- $cateStr=" 1";
- $size=300;
- if(!empty($nature))
- $cateStr=" 1";
- $data['htmllv2']=array();
- $data['htmllv3']=array();
- $condition="";
- if($districtLv==1){
- $condition="";
- if(!empty($lv1)){
- $condition=" district like '".$lv1.",%'";
- $data['htmllv2']=$district->get_lvByid(2, $lv1);
- }
- }
- if($districtLv==2){
- if(!empty($lv2))
- $condition=" district like '".$lv1.",".$lv2.",%'";
- else
- $condition=" district like '".$lv1.",%'";
- $data['htmllv2']=$district->get_lvByid(2, $lv1);
- $data['htmllv3']=$district->get_lvByid(2, $lv2);
- }
- if($districtLv==3){
- if(!empty($lv3))
- $condition=" district like '".$lv1.",".$lv2.",".$lv3."'";
- else
- $condition=" district like '".$lv1.",".$lv2.",%'";
- $data['htmllv2']=$district->get_lvByid(2, $lv1);
- $data['htmllv3']=$district->get_lvByid(2, $lv2);
- }
-
- $districtCount=$condition;
-
- if(!empty($condition))
- $cateStr=$condition;
- if(!empty($nature))
- $cateStr.=" and nature like '%".$nature."%'";
- //echo "<div style='display:none'>".$cateStr."</div><br/>";
- $tagSQL=false;
- if(!empty($tagList)){
- $tagSQL=true;
- foreach ($tagList as $value){
- $cateStr.=" and a.tag like '%".$value."%' ";
- }
- }
- if($this->staff[0]['isadmin']!=1){
- $pageinfo=$this->get_Tpage("CLD_company", $cateStr, $page, $size,"",$tagSQL);
- }else{
- if ($tagSQL)
- $pageinfo=$this->get_Tpage("CLD_company", $cateStr, $page, $size,"",$tagSQL);
- else{
- $total_page=$company->count(array());
- $total = intval ( $total_page / $size );
- $pageinfo ['total_page'] = ($total_page % $size) == 0 ? $total : $total + 1;
- }
- }
- $k="";
- for ($i=1;$i<=$pageinfo['total_page'];$i++){
- if($page==$i)
- $k.="<option value='".$search.":".$i.":".$lv1.":".$lv2.":".$lv3."' selected>第".$i."页</option>";
- else
- $k.="<option value='".$search.":".$i.":".$lv1.":".$lv2.":".$lv3."'>第".$i."页</option>";
- }
- $data['pageinfo']=$k;
-
- $data['company']=$company->getCompanyByDistrict($this->staff[0]['sid'],$cateStr,$this->staff[0]['isadmin'],$page,$size,$tagSQL);
- if($this->staff[0]['isadmin']!=1){
- $data['district']=$district->get_lvByStaffid(1,$this->staff[0]['sid']);
- }else{
- $data['district']=$data['district2'];
- }
- //获得标签
- $ClientTagList=$tagCompanyNexus->getTagClientBySid( $this->staff[0]['sid']);
- foreach ($ClientTagList as $key=>$value){
- $ClientTagList[$key]['taginfo']= $tagCompany->getTagByTidL($value['tag']);
- }
- foreach ($data['company'] as $key=>$value){
- if(!empty($value['cid'])){
- $data['company'][$key]['taginfo']= array();
- $data['company'][$key]['tag']="";
- foreach ($ClientTagList as $k=>$v){
- if($value['cid']==$v['company']){
- $data['company'][$key]['taginfo']= $v['taginfo'];
- $data['company'][$key]['tag']=$v['tag'];
- }
- }
- }
- }
-
- $comcid=$countL=array();
- foreach ($data['company'] as $key=>$value){
- array_push($comcid, $value['cid']);
- }
- $comcid=implode(",", $comcid);
- if(!empty($comcid))
- $countL=$client->getCountByCompany($comcid);
- foreach ($data['company'] as $key=>$value){
- $data['company'][$key]['count']=0;
- foreach ($countL as $k=>$v){
- if($value['cid']==$v['companyid']){
- $data['company'][$key]['count']=$v['count'];
- break;
- }
- }
- }
-
- $CC1="";$CC2="";$CC3="";$natureHtml='';
- if (!empty($districtCount)){
- $clientCount=$company->find(array('select'=>'district','where' => "district like '".$lv1.",%'",'asArray' => TRUE));
- $CC1=count($clientCount);
- if (!empty($clientCount)&&!empty($lv2)){
- $CC2=0;
- foreach ($clientCount as $key=>$value){
- if (strpos($value['district'],$lv2)){
- $CC2++;
- }
- }
- }
-
- if (!empty($clientCount)&&!empty($lv3)){
- $CC3=0;
- foreach ($clientCount as $key=>$value){
- if (strpos($value['district'],$lv3)){
- $CC3++;
- }
- }
- }
-
- $clientCount=$company->find(array('select'=>'district,nature','where' => $districtCount,'asArray' => TRUE));
-
- $natureCount=array();
- foreach ($this->nature as $value){
- $natureCount[$value]=0;
- foreach ($clientCount as $v){
- $ak=explode(",", $v['nature']);
- foreach ($ak as $a){
- if ($value==$a){
- $natureCount[$value]++;
- }
- }
- }
- }
-
-
- }
-
- $natureHtml='';
- foreach ($this->nature as $value){
- $natureHtml.='<a href="javascript:void(0)" ';
- if( $value==$nature)
- $natureHtml.='class="now"';
- if(isset($natureCount[$value]))
- $natureHtml.='onclick="showNature(\''.$value.'\',this)">'.$value.'('.$natureCount[$value].')</a>';
- else
- $natureHtml.='onclick="showNature(\''.$value.'\',this)">'.$value.'</a>';
- }
-
-
- $taglist=$tagCompany->find(array('where' => 'sid='.$this->staff[0]['sid'],'asArray' => TRUE));
- if (empty($taglist)){
- for ($i=1;$i<=7;$i++){
- $tag = new tagCompany ();
- $tag->name="个人标签";
- $tag->sid=$this->staff[0]['sid'];
- $tag->colorid=$i;
- $tag->insert();
- }
- }
-
- $data['product']=array();
- $data['tagList']=$tagList;
- $data['tag']=$tagCompany->getAllBySid($this->staff[0]['sid']);
- $data['natureHtml']=$natureHtml;
- $data['CC1']=$CC1;
- $data['CC2']=$CC2;
- $data['CC3']=$CC3;
- $data['lv1']=$lv1;
- $data['lv2']=$lv2;
- $data['lv3']=$lv3;
- $data['districtLv']=$districtLv;
- $data['Hnature']=$nature;
- $data['nature']=$this->nature;
- $this->render ( "/contacts_company", $data );
- }
- function contacts(){
- $data['memu']="contacts";
- $data['staff']=$this->staff;
- $search=$this->get_args('search')?trim($this->get_args('search')):"";
- if (empty($search))
- $search=urldecode(isset($this->params ['search'])?$this->params ['search']:"");
- $lv1=$this->get_args('lv1')?$this->get_args('lv1'):0;
- $lv2=$this->get_args('lv2')?$this->get_args('lv2'):0;
- $lv3=$this->get_args('lv3')?$this->get_args('lv3'):0;
- $lv4=$this->get_args('lv4')?$this->get_args('lv4'):"";
- $tagList=$this->get_args('tag')?$this->get_args('tag'):array();
- $tooltip=$this->get_args('tooltip')?$this->get_args('tooltip'):"";
- $districtLv=$this->get_args('districtLv')?$this->get_args('districtLv'):0;
- if ($lv1==0){
- $lv1=isset($this->params ['lv1'])&&is_numeric ( $this->params ['lv1'] ) ? $this->params ['lv1'] : 0;
- if ($lv1!=0)
- $districtLv=1;
- }
- if ($lv2==0){
- $lv2=isset($this->params ['lv2'])&&is_numeric ( $this->params ['lv2'] ) ? $this->params ['lv2'] : 0;
- if ($lv2!=0)
- $districtLv=2;
- }
- if ($lv3==0){
- $lv3=isset($this->params ['lv3'])&&is_numeric ( $this->params ['lv3'] ) ? $this->params ['lv3'] : 0;
- if ($lv2!=0)
- $districtLv=3;
- }
- $sortV=$this->get_args('sortV')?$this->get_args('sortV'):"h";
- $page = isset($this->params ['page'])&&is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
- Doo::loadModel ( 'client_staff' );
- Doo::loadModel ( 'client' );
- Doo::loadModel('tag');
- Doo::loadModel ( 'district' );
- Doo::loadModel('tag_client');
- Doo::loadModel('L_category');
- Doo::loadModel('longle');
- Doo::loadModel('C_tooltip');
- $c_tooltip=new C_tooltip();
- $longle=new longle();
- $client=new client();
- $category=new L_category();
- $tagClient=new tag_client();
- $district = new district ();
- $tag = new tag ();
- $client_staff = new client_staff ();
- $data['tag']=$tag->getAllBySid($this->staff[0]['sid']);
- $data['district2']=$district->get_lv(1);
- $page_size=200;
- $linfo=$category->getCategoryById($this->staff[0]['cid'],$this->staff['0']['othercid']);
- $staffid=$condition=$a="";
- if($this->staff[0]['isadmin']!=1){
- //加入办事处地区
- $data['district']=$district->get_lvByStaffid(1,$this->staff[0]['sid']);
- if(!empty($search))
- $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."%')";
- else {
- //or b.district like '".$linfo[0]['districtid']."%'
- $a=" and b.district like '".$linfo[0]['districtid']."%'";
- if(!empty($tooltip))
- $sch="";
- $search=urldecode(isset($this->params ['search'])?$this->params ['search']:"");
- if(!empty($search))
- $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."%')";
- else{
- $staffid=$data['staff'][0]['sid'];
- $sqstr="";
- foreach ($linfo as $key=>$value){
- if($key!=0){
- $sqstr.=" or b.district like '".$value['districtid'].",%'";
- }
- }
- $a="and b.district like '".$linfo[0]['districtid'].",%'".$sqstr;
- }
- }
- }else{
- $data['district']=$data['district2'];
- if(!empty($search))
- $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."%')";
- else {
- $sch=" ";
- $search=urldecode(isset($this->params ['search'])?$this->params ['search']:"");
- if(!empty($search))
- $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."%')";
- }
- }
- $data['htmllv2']=$data['htmllv3']=array();
- if($districtLv==1){
- $a="";
- $condition="";
- if(!empty($lv1)){
- $condition.=" and district like '".$lv1.",%'";
- $data['htmllv2']=$district->get_lvByid(2, $lv1);
- }
- }
- if($districtLv==2){
- $a="";
- if(!empty($lv2))
- $condition.=" and district like '".$lv1.",".$lv2.",%'";
- else
- $condition.=" and district like '".$lv1.",%'";
- $data['htmllv2']=$district->get_lvByid(2, $lv1);
- $data['htmllv3']=$district->get_lvByid(2, $lv2);
- }
- if($districtLv==3){
- $a="";
- if(!empty($lv3))
- $condition.=" and district like '".$lv1.",".$lv2.",".$lv3."'";
- else
- $condition.=" and district like '".$lv1.",".$lv2.",%'";
- $data['htmllv2']=$district->get_lvByid(2, $lv1);
- $data['htmllv3']=$district->get_lvByid(2, $lv2);
- }
- $condition.=$a;
- $districtCount=$condition;
-
- if(!empty($lv4)){
- $condition.=" and nature like '%".$lv4."%'";
- }
- $tagSQL=false;
- if(!empty($tagList)){
- $tagSQL=true;
- foreach ($tagList as $value){
- $condition.=" and c.tag like '%".$value."%' ";
- }
- $search="";
- }
- if(!empty($search))
- $condition.=$sch;
- // if(!empty($tooltip))
- // $condition.=" and tooltip like '%".$tooltip."%'";
- $pageinfo=$this->get_page("CLD_client_staff", $condition, $page, $page_size, "","","",$staffid,$search,$tooltip,$this->staff[0]['cid'],$tagSQL);
- if($sortV=="h"){//order by a.cid desc
- $limit = " order by cid desc limit " . $pageinfo ['lower'] . " , " . $page_size . " ";
- }
- if($sortV=="g"){//order by updatetime desc
- $limit = " limit " . $pageinfo ['lower'] . " , " . $page_size . " ";
- }
- if($sortV=="f"){//order by updatetime desc
- $limit = " limit " . $pageinfo ['lower'] . " , " . $page_size . " ";
- }
- if($sortV=="i"){//order by servicetime desc
- $limit = " limit " . $pageinfo ['lower'] . " , " . $page_size . " ";
- }
- //检索是全局
- $data['clientInfo']=$client_staff->getClientByStaff($condition,$limit,$staffid,$this->staff[0]['sid'],$search,$tooltip,$this->staff[0]['cid'],$tagSQL);
- //获取其他办事处的客户
- // if(!empty($districtstr)){
- // $buclient=$client->getClientByDistrict($districtstr);
- //
- // foreach ($buclient as $key=>$vlaue){
- //
- // $falg=true;
- //
- // foreach ($data['clientInfo'] as $y=>$v){
- // if($vlaue['clientname']==$v['clientname']&&$vlaue['companyname']==$v['companyname'])
- // $falg=false;
- // }
- // if($falg)
- // array_push($data['clientInfo'], $vlaue);
- // }
- //
- // }
- $k="";
- for ($i=1;$i<=$pageinfo['total_page'];$i++){
- if($page==$i)
- $k.="<option value='".$search.":".$i.":".$lv1.":".$lv2.":".$lv3."' selected>第".$i."页</option>";
- else
- $k.="<option value='".$search.":".$i.":".$lv1.":".$lv2.":".$lv3."'>第".$i."页</option>";
- }
- $data['pageinfo']=$k;
- Doo::loadModel('product');
- $product=new product();
- $data['nature']=$this->nature;
- $data['product']=$product->getProudct();
- //获得标签
- $ClientTagList=$tagClient->getTagClientBySid( $this->staff[0]['sid']);
- $toollist=$c_tooltip->find(array('where'=>'cateid='.$this->staff[0]['cid'],'asArray'=>true));
- //$ToolTipList=$
- foreach ($ClientTagList as $key=>$value){
- $ClientTagList[$key]['taginfo']= $tag->getTagByTidL($value['tag']);
- }
- //print_r($ClientTagList);die;
- foreach ($data['clientInfo'] as $key=>$value){
- if(!empty($value['cid'])){
- //$tinfo=$tagClient->getTagClientBySCid($value['cid'], $this->staff[0]['sid']);
- $data['clientInfo'][$key]['taginfo']= array();
- $data['clientInfo'][$key]['tag']="";
- foreach ($ClientTagList as $k=>$v){
- //$tag->getTagByTidL($value['tag']);$value['tag'];
- if($value['cid']==$v['client']){
- $data['clientInfo'][$key]['taginfo']= $v['taginfo'];
- $data['clientInfo'][$key]['tag']=$v['tag'];
- }
- }
- //array_pop 可以优化数组
- }
- $data['clientInfo'][$key]['tooltipList']=array();
- foreach ($toollist as $k=>$v){
- if($v['cid']==$value['cid']){
- $data['clientInfo'][$key]['tooltipList']=explode(",", $v['name']);
- break;
- }//array_pop 可以优化数组
- }
- // $tl=array();
- // if(!empty($value['tooltip']))
- // $tl=explode(',', $value['tooltip']);
- // $data['clientInfo'][$key]['tooltipList']=$tl;
- $data['clientInfo'][$key]['locount']=0;//$longle->count(array('where'=>'clientid='.$value['cid']));
- }
- $CC1="";$CC2="";$CC3="";
- if (!empty($districtCount)){
- $clientCount=$client->find(array('select'=>'district','where' => "district like '".$lv1.",%'",'asArray' => TRUE));
- $CC1=count($clientCount);
- if (!empty($clientCount)&&!empty($lv2)){
- $CC2=0;
- foreach ($clientCount as $key=>$value){
- if (strpos($value['district'],$lv2)){
- $CC2++;
- }
- }
- }
-
- if (!empty($clientCount)&&!empty($lv3)){
- $CC3=0;
- foreach ($clientCount as $key=>$value){
- if (strpos($value['district'],$lv3)){
- $CC3++;
- }
- }
- }
-
- }
- Doo::loadModel('remind');
- $remind=new remind();
- // and date_add(time, INTERVAL day DAY) <= CURDATE()
- $remindList=$remind->find(array('where' => "staffID = '".$this->staff[0]['sid']."' and status=0 ",'asc'=>'date_add(time, INTERVAL day DAY)','asArray' => TRUE));
- $rc=0;
- foreach ($remindList as $key=>$value){
- $a=strtotime($value['time']." +".$value['day']." days");
- $b=strtotime(date('y-m-d'));
- if ($a<=$b){
- $rc++;
- $remindList[$key]['isRemind']=1;
- }else
- $remindList[$key]['isRemind']=0;
- $remindList[$key]['Ctime']=date('m-d',strtotime($value['time']));
- $remindList[$key]['Etime']=date('m-d',strtotime($value['time']." +".$value['day']." days"));
- }
-
- $data['remindCount']=$rc;
- $data['remindList']=$remindList;
- $data['CC1']=$CC1;
- $data['CC2']=$CC2;
- $data['CC3']=$CC3;
- $data['lv1']=$lv1;
- $data['lv2']=$lv2;
- $data['lv3']=$lv3;
- $data['lv4']=$lv4;
- $data['districtLv']=$districtLv;
- $data['tagList']=$tagList;
- $data['tooltip']=$this->tooltip;
- $data['ttip']=$tooltip;
- $data['search']=$search;
- $data['totalData']=$pageinfo['total_data'];
- //$data['messagehtml']=$html;
- $this->render ( "/contacts_client", $data );
- }
- function remindCL(){
-
- $rid=isset($this->params['rid'])?$this->params['rid']:0;
-
- Doo::loadModel('remind');
- $remind=new remind();
-
- $remind->status=1;
- $remind->update(array('where' => "staffID = '".$this->staff[0]['sid']."' and rid=".$rid,'asArray' => TRUE));
-
- return "/contacts";
- }
-
- function communication(){
- $data['memu']="contacts";
- $data['staff']=$this->staff;
- $cid=$this->get_args('cid')?$this->get_args('cid'):0;
- Doo::loadModel ( 'L_category' );
- $L_category=new L_category();
- Doo::loadModel ( 'staff' );
- $staff=new staff();
- Doo::loadModel ( 'staffDynamic' );
- $staffDynamic=new staffDynamic();
- if (!empty($cid))
- $data['staffList']=$staff->getStaffByCid($cid);
- else
- $data['staffList']=$staff->getStaff();
- foreach ($data['staffList'] as $key=>$value){
- if (!empty($value['birthday'])){
- $dataD=date("d",strtotime($value['birthday']));
- if (date('m')==date("m",strtotime($value['birthday']))){
- $now=date('d');
- $post=$dataD-7;//date("d",mktime(0,0,0,date("m"),date("d")+7,date("Y")));
- if ($now>=$post&&$now<=$dataD){
- $data['staffList'][$key]['birthday']="birthday";
- $data['staffList'][$key]['birthDAY']=date("m-d",strtotime($value['birthday']));
- }
- }
- }
- $happy=date("m-d",strtotime($value['birthday']));
- if ($happy==date('m-d')){
- $SBL=$staffDynamic->getStaffBirthday($happy,$value['sid']);
- if (empty($SBL)){
- $staffDynamic->content='<img src="/global/img/cake.gif"><span class="colOrange">今天过生日!</span>';
- $staffDynamic->cid=$value['cid'];
- $staffDynamic->category=$value['category'];
- $staffDynamic->time=time();
- $staffDynamic->sid=$value['sid'];
- $staffDynamic->staff=$value['username'];
- $staffDynamic->insert();
- }
- }
- }
- $sDynaimic=$staffDynamic->getStaffDynamic();
- foreach ($sDynaimic as $key=>$value){
- $time=date("Y-m-d",$value['time']);
- $timeArray=explode('-', $time);
- $sDynaimic[$key]['year']=$timeArray[0];
- $sDynaimic[$key]['month']=$timeArray[1];
- $sDynaimic[$key]['day']=$timeArray[2];
- }
- $data['sDynaimic']=$sDynaimic;
- $data['category']=$L_category->getCategory();
- $data['cid']=$cid;
- $this->render ( "/staff_contacts", $data );
- }
- function app(){
- $data['memu']="app";
- $data['staff']=$this->staff;
- $this->render ( "/app", $data );
- }
- function synClient(){
- if($this->staff[0]['isadmin']!=1){
- Doo::loadModel ( 'L_category' );
- Doo::loadModel ( 'client_staff' );
- $client_staff=new client_staff();
- $cate=new L_category();
- $district=$cate->getOne(array('where'=>'cid='.$this->staff[0]['cid'],'asArray'=>true));
- $syn=$client_staff->synClient($this->staff[0]['sid'] ,$district['districtid']);
- $bei=$client_staff->find(array('where'=>"sid = ".$this->staff[0]['sid'],'asArray'=>true));
- foreach ($syn as $value){
- $falg=true;
- foreach ($bei as $v){
- if(($v['cid']==$value['cid'])&&($v['sid']==$this->staff[0]['sid'])){
- $falg=false;
- break;
- }
- }
- if($falg){
- $client_staff=new client_staff();
- $client_staff->sid=$this->staff[0]['sid'];
- $client_staff->cid=$value['cid'];
- $client_staff->insert();
- }
- }
- }
- return "/contacts";
- }
- function DoAddTagCompany(){
- $cid = $this->get_args ( 'id' );
-
- $tid = $this->get_args ( 'tagALD' );
- Doo::loadModel('tagCompanyNexus');
- $strtid=implode(",", $tid);
- foreach ($cid as $key=>$value){
- $tagClient=new tagCompanyNexus();
- $tagClientInfo=$tagClient->getTagClientBySCid($value,$this->staff[0]['sid']);
- $ar=explode(",", $strtid.','.$tagClientInfo['tag']);
- $re=array_filter(array_unique($ar));
- $tagClient->tag=implode(",", $re);
- if(!empty($tagClientInfo)){
- $tagClient->tcid=$tagClientInfo['tcid'];
- $tagClient->update();
- }else{
- $tagClient->sid=$this->staff[0]['sid'];
- $tagClient->company=$value;
- $tagClient->insert();
- }
- }
- header("Location: /mycompany");
- }
-
- function DoAddTag(){
- $cid = $this->get_args ( 'id' );
- $tooltipAct=$this->get_args('tooltipAct')?$this->get_args('tooltipAct'):"";
- Doo::loadModel ( 'client' );
- if (!empty($tooltipAct)){
- $tid = $this->get_args ( 'tooltiplist' );
- $k=implode(",", $tid);
- Doo::loadModel('C_tooltip');
- $s=" and cateid=".$this->staff[0]['cid'];
- if(!empty($this->staff[0]['othercid'])){
- $othercid=explode(",", $this->staff[0]['othercid']);
- foreach ($othercid as $value){
- $s.=" or cateid=".$value;
- }
- }
- foreach ($cid as $key=>$value){
- $C_tooltip = new C_tooltip ();
- $tooltip=$C_tooltip->getOne(array('where'=>'cid='.$value." ".$s,'asArray'=>true));
- if(empty($tooltip)){
- $C_tooltip->cid=$value;
- $C_tooltip->name=$k;
- $C_tooltip->cateid=$this->staff[0]['cid'];
- $C_tooltip->insert();
- }else{
- $C_tooltip->tip=$tooltip['tip'];
- $C_tooltip->name=$k;
- $C_tooltip->update();
- }
- }
- }else{
- $tid = $this->get_args ( 'tagALD' );
- Doo::loadModel('tag_client');
- $strtid=implode(",", $tid);
- foreach ($cid as $key=>$value){
- $tagClient=new tag_client();
- $tagClientInfo=$tagClient->getTagClientBySCid($value,$this->staff[0]['sid']);
- $ar=explode(",", $strtid.','.$tagClientInfo['tag']);
- $re=array_filter(array_unique($ar));
- $tagClient->tag=implode(",", $re);
- if(!empty($tagClientInfo)){
- $tagClient->tcid=$tagClientInfo['tcid'];
- $tagClient->update();
- }else{
- $tagClient->sid=$this->staff[0]['sid'];
- $tagClient->client=$value;
- $tagClient->insert();
- }
- }
- }
- header("Location: /contacts");
- }
- function ajaxDeleteTag(){
- $cid = $this->get_args ( 'cid' );
- $tid = $this->get_args ( 'tid' );
- Doo::loadModel ( 'tag_client' );
- $tagClient = new tag_client ();
- $tagInfo=$tagClient->getTagClientBySCid($cid, $this->staff[0]['sid']);
- $tag=str_replace($tid,"",$tagInfo['tag']);
- $ar=explode(',', $tag);
- $tag=implode(',', array_filter($ar));
- $tagClient->tcid=$tagInfo['tcid'];
- $tagClient->tag=$tag;
- $tagClient->update();
- }
- function ajaxDeleteTagCompany(){
- $cid = $this->get_args ( 'cid' );
- $tid = $this->get_args ( 'tid' );
- Doo::loadModel ( 'tagCompanyNexus' );
- $tagClient = new tagCompanyNexus ();
- $tagInfo=$tagClient->getTagClientBySCid($cid, $this->staff[0]['sid']);
- $tag=str_replace($tid,"",$tagInfo['tag']);
- $ar=explode(',', $tag);
- $tag=implode(',', array_filter($ar));
- $tagClient->tcid=$tagInfo['tcid'];
- $tagClient->tag=$tag;
- $tagClient->update();
- }
-
- function deleteToolTip(){
- $cid = $this->get_args ( 'cid' );
- $cateid = $this->get_args ( 'cateid' );
- $name = $this->get_args ( 'name' );
- Doo::loadModel("C_tooltip");
- $tooltip=new C_tooltip();
- if(!empty($cid)&&!empty($cateid)&&!empty($name)){
- $tool=$tooltip->getOne(array('where'=>'cid='.$cid.' and cateid='.$cateid,'asArray'=>true));
- if(!empty($tool)){
- $name=str_replace($name,"",$tool['name']);
- $name=explode(',', $name);
- $name=implode(',', array_filter($name));
- $tooltip->name=$name;
- $tooltip->tip=$tool['tip'];
- $tooltip->update();
- }
- }
- }
- function DoEdiTagCompany(){
- $tag_1=$this->get_args('tag_1')?$this->get_args('tag_1'):"";
- $tag_2=$this->get_args('tag_2')?$this->get_args('tag_2'):"";
- $tag_3=$this->get_args('tag_3')?$this->get_args('tag_3'):"";
- $tag_4=$this->get_args('tag_4')?$this->get_args('tag_4'):"";
- $tag_5=$this->get_args('tag_5')?$this->get_args('tag_5'):"";
- $tag_6=$this->get_args('tag_6')?$this->get_args('tag_6'):"";
- $tag_7=$this->get_args('tag_7')?$this->get_args('tag_7'):"";
- $tid_1=$this->get_args('tid_1')?$this->get_args('tid_1'):0;
- $tid_2=$this->get_args('tid_2')?$this->get_args('tid_2'):0;
- $tid_3=$this->get_args('tid_3')?$this->get_args('tid_3'):0;
- $tid_4=$this->get_args('tid_4')?$this->get_args('tid_4'):0;
- $tid_5=$this->get_args('tid_5')?$this->get_args('tid_5'):0;
- $tid_6=$this->get_args('tid_6')?$this->get_args('tid_6'):0;
- $tid_7=$this->get_args('tid_7')?$this->get_args('tid_7'):0;
- Doo::loadModel('tagCompany');
- if(!empty($tag_1)&&!empty($tid_1)){
- $tag = new tagCompany ();
- $tag->tid=$tid_1;
- $tag->name=$tag_1;
- $tag->update();
- }
- if(!empty($tag_2)&&!empty($tid_2)){
- $tag = new tagCompany ();
- $tag->tid=$tid_2;
- $tag->name=$tag_2;
- $tag->update();
- }
- if(!empty($tag_3)&&!empty($tid_3)){
- $tag = new tagCompany ();
- $tag->tid=$tid_3;
- $tag->name=$tag_3;
- $tag->update();
- }
- if(!empty($tag_4)&&!empty($tid_4)){
- $tag = new tagCompany ();
- $tag->tid=$tid_4;
- $tag->name=$tag_4;
- $tag->update();
- }
- if(!empty($tag_5)&&!empty($tid_5)){
- $tag = new tagCompany ();
- $tag->tid=$tid_5;
- $tag->name=$tag_5;
- $tag->update();
- }
- if(!empty($tag_6)&&!empty($tid_6)){
- $tag = new tagCompany ();
- $tag->tid=$tid_6;
- $tag->name=$tag_6;
- $tag->update();
- }
- if(!empty($tag_7)&&!empty($tid_7)){
- $tag = new tagCompany ();
- $tag->tid=$tid_7;
- $tag->name=$tag_7;
- $tag->update();
- }
- return "/mycompany";
- }
-
-
- function DoEdiTag(){
- $tag_1=$this->get_args('tag_1')?$this->get_args('tag_1'):"";
- $tag_2=$this->get_args('tag_2')?$this->get_args('tag_2'):"";
- $tag_3=$this->get_args('tag_3')?$this->get_args('tag_3'):"";
- $tag_4=$this->get_args('tag_4')?$this->get_args('tag_4'):"";
- $tag_5=$this->get_args('tag_5')?$this->get_args('tag_5'):"";
- $tag_6=$this->get_args('tag_6')?$this->get_args('tag_6'):"";
- $tag_7=$this->get_args('tag_7')?$this->get_args('tag_7'):"";
- $tid_1=$this->get_args('tid_1')?$this->get_args('tid_1'):0;
- $tid_2=$this->get_args('tid_2')?$this->get_args('tid_2'):0;
- $tid_3=$this->get_args('tid_3')?$this->get_args('tid_3'):0;
- $tid_4=$this->get_args('tid_4')?$this->get_args('tid_4'):0;
- $tid_5=$this->get_args('tid_5')?$this->get_args('tid_5'):0;
- $tid_6=$this->get_args('tid_6')?$this->get_args('tid_6'):0;
- $tid_7=$this->get_args('tid_7')?$this->get_args('tid_7'):0;
- Doo::loadModel('tag');
- if(!empty($tag_1)&&!empty($tid_1)){
- $tag = new tag ();
- $tag->tid=$tid_1;
- $tag->name=$tag_1;
- $tag->update();
- }
- if(!empty($tag_2)&&!empty($tid_2)){
- $tag = new tag ();
- $tag->tid=$tid_2;
- $tag->name=$tag_2;
- $tag->update();
- }
- if(!empty($tag_3)&&!empty($tid_3)){
- $tag = new tag ();
- $tag->tid=$tid_3;
- $tag->name=$tag_3;
- $tag->update();
- }
- if(!empty($tag_4)&&!empty($tid_4)){
- $tag = new tag ();
- $tag->tid=$tid_4;
- $tag->name=$tag_4;
- $tag->update();
- }
- if(!empty($tag_5)&&!empty($tid_5)){
- $tag = new tag ();
- $tag->tid=$tid_5;
- $tag->name=$tag_5;
- $tag->update();
- }
- if(!empty($tag_6)&&!empty($tid_6)){
- $tag = new tag ();
- $tag->tid=$tid_6;
- $tag->name=$tag_6;
- $tag->update();
- }
- if(!empty($tag_7)&&!empty($tid_7)){
- $tag = new tag ();
- $tag->tid=$tid_7;
- $tag->name=$tag_7;
- $tag->update();
- }
- return "/contacts";
- }
- function ajaxGetLv2(){
- $lv1=isset($_POST['lv1'])?$_POST['lv1']:0;
- $s=isset($_POST['s'])?$_POST['s']:0;
- if($lv1==0){
- echo json_encode(array("success"=>false,"info"=>""));die;
- }
- if(!empty($lv1)){
- Doo::loadModel ( 'district' );
- $district = new district ();
- $district=$district->get_lvByid($s,$lv1);
- echo json_encode(array("success"=>true,"info"=>$district));
- }
- }
- function keyonline(){
- $data['memu']="keyonline";
- $data['staff']=$this->staff;
-
- $year=$this->get_args('year')?$this->get_args('year'):"";
- if (empty($year))
- $year=isset($this->params['year'])?$this->params['year']:date('Y');
- $cid=$this->get_args('cid')?$this->get_args('cid'):"";
- if (empty($cid))
- $cid=isset($this->params['cid'])?$this->params['cid']:$this->staff[0]['cid'];
- $staff=$this->get_args('staff')?$this->get_args('staff'):"";
- if (empty($staff))
- $staff=isset($this->params['staff'])?$this->params['staff']:"";
- $status=$this->get_args('status')?$this->get_args('status'):"";
- if (empty($status))
- $status=isset($this->params['status'])?$this->params['status']:0;
- $search=$this->get_args('search')?$this->get_args('search'):"";
- $productW=$this->get_args('product')?$this->get_args('product'):"";
-
- Doo::loadModel ( 'longle' );
- $longle = new longle ();
- $data['longleArray']=$longle->getLongleByStatus($year,$cid,$staff,$status,$search,$productW);
- //获取接收锁信息
- //$longle->getLongleByRe($this->staff[0]['cid'],1);
- $othstr="";
- if(!empty($this->staff[0]['othercid']))
- $othstr=" cid in (".$this->staff[0]['cid'].",".$this->staff[0]['othercid'].")";
- else
- $othstr=" cid in (".$this->staff[0]['cid'].")";
- $data['reLongle']=$longle->count(array('where'=>$othstr.' and status=1'));
- $data['cid']=$cid;
- $data['year']=$year;
- $data['staff']=$staff;
- $data['status']=$status;
- $data['productName']=$productW;
-
- Doo::loadModel ( 'L_category' );
- Doo::loadModel('staff');
- Doo::loadModel('product');
- $product=new product();
- $staff=new staff();
- $L_category = new L_category ();
- $data['product']=$product->getProudct();
-
- $data['staffu']=$staff->getUserById($this->staff[0]['sid']);
- $data['category']=$L_category->getCategory();
- $data['staffList']=$staff->getStaffByCid($cid);
- if($cid==1)
- $data['cid']=$data['category'][0]['cid'];
- $dateHtml="";$now=date("Y");
- for ($YEARD=2050;$YEARD>=2004;$YEARD--){
- if ($YEARD<=$now){
- $dateHtml.='<option ';
- if ($data['year']==$YEARD ){
- $dateHtml.='selected ';
- }
- $dateHtml.='value="'.$YEARD.'">'.$YEARD.'</option>';
- }
- }
-
- $data['dateHtml']=$dateHtml;
- $this->render ( "/lock_look", $data );
- }
- function keyStatistics(){
-
- Doo::loadModel('staff');
- $staff=new staff();
- Doo::loadModel ( 'longle' );
- $longle = new longle ();
-
- $staffCondition="";
- if($this->staff[0]['cid']!=12)
- $staffCondition=" and cid=".$this->staff[0]['cid'];
-
- $staffList=$staff->find(array ('where' => "isadmin= 0 ".$staffCondition,'asArray' => TRUE));
- Doo::db()->beginTransaction();
- foreach ($staffList as $key=>$value){// not in(1,2)
- $sum=$longle->count(array ('where' => "status!= 1 and responsible ='".$value['username']."'",'asArray' => TRUE));
- $a=$longle->count(array ('where' => "status!= 2 and status!= 1 and responsible ='".$value['username']."'",'asArray' => TRUE));
-
- $b=$sum-$a;
- $staffList[$key]['sum']=$sum;
- $staffList[$key]['a']=$a;
- $staffList[$key]['b']=$b;
- }
- Doo::db()->commit();
-
- $data['staff']=$this->staff;
- $data['staffList']=$staffList;
- $data['memu']="keyStatistics";
- $this->render ( "lock_count", $data );
- }
-
- function addDoLockLog(){
- Doo::loadModel ( 'longle_log' );
- Doo::loadModel ( 'longle' );
- Doo::loadModel("action_log");
- Doo::loadModel ( 'client' );
- $clientobj = new client ();
- $longle = new longle ();
- $longle_log = new longle_log ();
- Doo::loadModel ( 'district' );
- $district = new district ();
- $status=isset($_POST['longleStatus'])?$_POST['longleStatus']:0;
- $lid=isset($_POST['klid'])?$_POST['klid']:0;
- if(empty($lid))
- return "/keyonline/";
- $linfo=$longle->getLongleByLid($lid);
- if($status==0)
- return "/keyonline/".$lid;
- elseif($status==3){
- $client=isset($_POST['browseClient'])?$_POST['browseClient']:"";
- $client=explode('-', $client);
- $product=isset($_POST['browseProduct'])?$_POST['browseProduct']:"";
- $clientname=$clientobj->getClientByName2($client[0],$client[1]);
- if(empty($clientname))
- return "/keyonline/".$lid;
- if($client[0]!=""){
- $longle->client=$client[0];
- $longle->clientid=$clientname[0]['cid'];
- }
- // if($product!="")
- // $longle->product=$product;
- $longle->statusT="借出";
- $longle_log->client=$client[0];
- $longle_log->clientid=$clientname[0]['cid'];
- $longle_log->product=$linfo[0]['product'];
- $longle_log->statusT="借出";
- //日常行为
- $action_log=new action_log();
- $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'].')';
- $action_log->sid=$this->staff[0]['sid'];
- $action_log->cid=$this->staff[0]['cid'];
- $action_log->updatetime=date("Y-m-d");
- $action_log->time=date("H:i");
- $action_log->status=4;
- $action_log->districtid=$clientname[0]['district'];
- $local=$district->getbyidlist($clientname[0]['district']);
- $action_log->city=$local[0]['name'];
- $action_log->province=$local[1]['name'];
- $action_log->company=$clientname[0]['companyname'];
- Doo::loadModel('company');
- $company=new company();
- $companyInfo=$company->getOne(array('where'=>' companyname="'.$clientname[0]['companyname'].'"','asArray'=>true));
- $nature=explode(',', $companyInfo['nature']);
- $action_log->nature=$nature[0];
- $action_log->class=$action_log->iconBorrow;
- $action_log->insert();
- }elseif($status==4){
- $product=isset($_POST['sellProduct'])?$_POST['sellProduct']:"";
- $client=isset($_POST['sellClient'])?$_POST['sellClient']:"";
- $client=explode('-', $client);
- $clientname=$clientobj->getClientByName2($client[0],$client[1]);
- if(empty($clientname))
- return "/keyonline/".$lid;
- if($client[0]!=""){
- $longle->client=$client[0];
- $longle->clientid=$clientname[0]['cid'];
- }
- // if($product!="")
- // $longle->product=$product;
- $longle->statusT="销售";
- $longle_log->client=$client[0];
- $longle_log->clientid=$clientname[0]['cid'];
- $longle_log->product=$linfo[0]['product'];
- $longle_log->statusT="销售";
- //日常行为
- $action_log=new action_log();
- $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'].')';
- $action_log->sid=$this->staff[0]['sid'];
- $action_log->cid=$this->staff[0]['cid'];
- $action_log->updatetime=date("Y-m-d");
- $action_log->time=date("H:i");
- $action_log->status=5;
- $action_log->districtid=$clientname[0]['district'];
- $local=$district->getbyidlist($clientname[0]['district']);
- $action_log->city=$local[0]['name'];
- $action_log->province=$local[1]['name'];
- $action_log->company=$clientname[0]['companyname'];
- Doo::loadModel('company');
- $company=new company();
- $companyInfo=$company->getOne(array('where'=>' companyname="'.$clientname[0]['companyname'].'"','asArray'=>true));
- $nature=explode(',', $companyInfo['nature']);
- $action_log->nature=$nature[0];
- $action_log->class=$action_log->iconSell;
- $action_log->insert();
- }elseif($status==5){
- $product=isset($_POST['newProduct'])?$_POST['newProduct']:"";
- if($product!="")
- $longle->product=$linfo[0]['product']."+".$product;
- $longle->statusT="升级";
- $longle_log->product=$linfo[0]['product']."+".$product;
- $longle_log->statusT="升级";
- $longle_log->client=$linfo[0]['client'];
- $longle_log->clientid=$linfo[0]['clientid'];
- $clientname=$clientobj->getOne( array ('where' => "cid= '".$linfo[0]['clientid']."'",'asArray' => TRUE));
- //日常行为
- $action_log=new action_log();
- $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>';
- $action_log->sid=$this->staff[0]['sid'];
- $action_log->cid=$this->staff[0]['cid'];
- $action_log->updatetime=date("Y-m-d");
- $action_log->time=date("H:i");
- $action_log->class=$action_log->iconUpdate;
- $action_log->sid=$this->staff[0]['sid'];
- $action_log->cid=$this->staff[0]['cid'];
- $action_log->status=7;
- $action_log->insert();
- }elseif($status==6){
- $key_num=isset($_POST['key_num'])?$_POST['key_num']:"";
- $key_num2=explode("-", $key_num);
- $key_num=$key_num2[0]."-".$key_num2[1];
- //if($key_num!="")
- // $longle->key_num=$key_num;
- //新锁拷贝记录
- $newLongle=new longle();
- //$newLongle->product=$linfo[0]['product'];
- $newLongle->statusT="更换";
- $newLongle->status=6;
- $newLongle->client=$linfo[0]['client'];
- $newLongle->clientid=$linfo[0]['clientid'];
- $newlid=$newLongle->update(array('where'=>' key_num= \''.$key_num."'"));
- $longleinfo=$longle->getOne(array('where'=>' key_num =\''.$key_num."'",'asArray'=>true));
- $longleLog=$longle_log->getOne(array('where'=>' lid ='.$linfo[0]['lid'],'desc'=>'logid','asArray'=>true));
- //新记录日志
- $newlongle_log=new longle_log();
- $newlongle_log->statusT="更换";
- $newlongle_log->status=6;
- $newlongle_log->client=$linfo[0]['client'];
- $newlongle_log->new_key_num=$linfo[0]['key_num'];
- $newlongle_log->product=$linfo[0]['product'];
- $newlongle_log->category=$this->staff[0]['category'];
- $newlongle_log->dateline=date("Y-m-d");
- $newlongle_log->operator=$this->staff[0]['username'];
- $newlongle_log->lid=$longleinfo['lid'];
- $newlongle_log->insert();
- $newlongle_log=new longle_log();
- $newlongle_log->statusT=$longleLog['statusT'];
- $newlongle_log->status=$longleLog['status'];
- $newlongle_log->client=$longleLog['client'];
- $newlongle_log->new_key_num=$longleLog['new_key_num'];
- $newlongle_log->product=$longleLog['product'];
- $newlongle_log->category=$longleLog['category'];
- $newlongle_log->dateline=$longleLog['dateline'];
- $newlongle_log->operator=$longleLog['operator'];
- $newlongle_log->lid=$longleinfo['lid'];
- $newlongle_log->insert();
- $newLongle=new longle();
- $newLongle->statusT=$longleLog['statusT'];
- $newLongle->status=$longleLog['status'];
- $newlid=$newLongle->update(array('where'=>' key_num= \''.$key_num."'"));
- //新锁状态拷贝
- $longle->statusT="更换";
- $longle_log->new_key_num=$key_num;
- $longle_log->statusT="更换";
- $longle_log->client=$linfo[0]['client'];
- $clientname=$clientobj->getOne( array ('where' => "cid= '".$linfo[0]['clientid']."'",'asArray' => TRUE));
- //日常行为
- $action_log=new action_log();
- $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'].')';
- $action_log->sid=$this->staff[0]['sid'];
- $action_log->cid=$this->staff[0]['cid'];
- $action_log->updatetime=date("Y-m-d");
- $action_log->time=date("H:i");
- $action_log->class=$action_log->iconReplace;
- $action_log->sid=$this->staff[0]['sid'];
- $action_log->cid=$this->staff[0]['cid'];
- $action_log->status=8;
- $action_log->insert();
- }elseif($status==7){
- $longle->statusT="收回";
- $longle_log->statusT="收回";
- $longle_log->responsible=$linfo[0]['responsible'];
- //日常行为
- $action_log=new action_log();
- $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>';
- $action_log->sid=$this->staff[0]['sid'];
- $action_log->cid=$this->staff[0]['cid'];
- $action_log->updatetime=date("Y-m-d");
- $action_log->time=date("H:i");
- $action_log->class=$action_log->iconRecycle;
- $action_log->sid=$this->staff[0]['sid'];
- $action_log->cid=$this->staff[0]['cid'];
- $action_log->status=9;
- $action_log->insert();
- }elseif($status==8){
- $mark=isset($_POST['mark'])?$_POST['mark']:"";
-
- if (empty($mark)){
- echo json_encode(array('msg'=>2));die;
- }
-
- $longle_log->mark=$mark;
- //日常行为
- $action_log=new action_log();
- $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>添加新备注。';
- $action_log->sid=$this->staff[0]['sid'];
- $action_log->cid=$this->staff[0]['cid'];
- $action_log->updatetime=date("Y-m-d");
- $action_log->time=date("H:i");
- $action_log->sid=$this->staff[0]['sid'];
- $action_log->cid=$this->staff[0]['cid'];
- $action_log->status=10;
- $action_log->class=$action_log->iconLock;
- $action_log->insert();
- }elseif($status==9){
- $longle->statusT="赠送";
- $longle_log->statusT="赠送";
- $client=isset($_POST['giftClient'])?$_POST['giftClient']:"";
- $client=explode('-', $client);
- $clientname=$clientobj->getClientByName2($client[0],$client[1]);
- if(empty($clientname))
- return "/keyonline/".$lid;
- if($client[0]!=""){
- $longle->client=$client[0];
- $longle->clientid=$clientname[0]['cid'];
- }
- $longle_log->client=$client[0];
- $longle_log->clientid=$clientname[0]['cid'];
- //日常行为
- $action_log=new action_log();
- $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'].')';
- $action_log->updatetime=date("Y-m-d");
- $action_log->time=date("H:i");
- $action_log->class=$action_log->iconRecycle;
- $action_log->sid=$this->staff[0]['sid'];
- $action_log->cid=$this->staff[0]['cid'];
- $action_log->status=6;
- $action_log->districtid=$clientname[0]['district'];
- $local=$district->getbyidlist($clientname[0]['district']);
- $action_log->city=$local[0]['name'];
- $action_log->province=$local[1]['name'];
- $action_log->company=$clientname[0]['companyname'];
- Doo::loadModel('company');
- $company=new company();
- $companyInfo=$company->getOne(array('where'=>' companyname="'.$clientname[0]['companyname'].'"','asArray'=>true));
- $nature=explode(',', $companyInfo['nature']);
- $action_log->nature=$nature[0];
- $action_log->insert();
- }
- //记录使用过的状态
- $statuslog=$status.",".$linfo[0]['statuslog'];
- $ar=explode(',', $statuslog);
- $statuslog=implode(',', array_unique(array_filter($ar)));
- $longle->statuslog=$statuslog;
- if($linfo[0]['status']<=2){
- if($status>=4&&$status<=2){
- return "/keyonline/".$lid;
- }
- }
- if($lid!=0){
- $longle->lid=$lid;
- if($status!=8)
- $longle->status=$status;
- //if($status!=8)
- $longle->responsible=$this->staff[0]['username'];
- $longle->update();
- }
- $longle_log->lid=$lid;
- $longle_log->status=$status;
- $longle_log->operator=$this->staff[0]['username'];
- //责任人
- $longle_log->category=$this->staff[0]['category'];
- $longle_log->dateline=date("Y-m-d");
- $longle_log->insert();
- echo json_encode(array('msg'=>1));die;
- //return "/keyonline/".$lid;
- }
- function ajaxGetLongleByName(){
- Doo::loadModel ( 'longle_log' );
- Doo::loadModel ( 'longle' );
- $longle = new longle ();
- $longle_log = new longle_log ();
- $name=isset($_POST['name'])?$_POST['name']:"";
- if(empty($name)){
- echo json_encode(array("success"=>false));die;
- }
- $ky=$longle->getLongleBykeynum($name);
- $t=$longle_log->getLongleByLid($ky[0]['lid']);
- if(isset($t[0]))
- $tk=$t[0];
- else
- $tk=array();
- $longleLog=$tk;
- $longleLog['klid']=$t[0]['lid'];
- $longleLog['longle']=$ky[0];
- $longleLog['longleLogHtml']=$this->_getLongleLogHtml($t);
- echo json_encode($longleLog);
- }
- function ajaxGetLongleN(){
- Doo::loadModel ( 'longle_log' );
- Doo::loadModel ( 'longle' );
- $longle = new longle ();
- $longle_log = new longle_log ();
- $keynum=isset($_POST['keynum'])?$_POST['keynum']:"";
- if(empty($keynum)){
- echo json_encode(array("success"=>false));die;
- }
- $ky=$longle->getLongleBykeynum($keynum);
- if(!empty($ky)){
- $t=$longle_log->getLongleByLid($ky[0]['lid']);
- if(isset($t[0]))
- $tk=$t[0];
- else
- $tk=array();
- $longleLog=$tk;
- $longleLog['klid']=$ky[0]['lid'];
- $longleLog['longle']=$ky[0];
- $longleLog['longleLogHtml']=$this->_getLongleLogHtml($t);
- echo json_encode($longleLog);
- }
- }
- function ajaxGetLongle(){
- Doo::loadModel ( 'longle_log' );
- Doo::loadModel ( 'longle' );
- $longle = new longle ();
- $longle_log = new longle_log ();
- $lid=isset($_POST['lid'])?$_POST['lid']:0;
- if($lid==0){
- echo json_encode(array("success"=>false));die;
- }
- $t=$longle_log->getLongleByLid($lid);
- if(isset($t[0]))
- $tk=$t[0];
- else
- $tk=array();
- $longleLog=$tk;
- $longleLog['klid']=$lid;
- $ky=$longle->getLongleByLid($lid);
- $longleLog['longle']=$ky[0];
- $longleLog['longleLogHtml']=$this->_getLongleLogHtml($t);
- echo json_encode($longleLog);
- }
- function ajaxGetStaffInfo(){
- $username=isset($_POST['username'])?$_POST['username']:"";
- if($username==""){
- echo json_encode(array("success"=>false));die;
- }
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- $staffInfo=$staff->getOne(array('where'=>' username like "'.$username.'"', 'asArray' => TRUE ));
- if(empty($staffInfo)){
- echo json_encode(array("success"=>false,'html'=>''));die;
- }
- $staffHtml=array('html'=>'<div class="contactPanel"><h1>'.$staffInfo['username'].'</h1>
- <table><tbody><tr><th>性别</th><td>'.$staffInfo['gender'].'</td><th>办事处</th><td>'.$staffInfo['category'].'</td></tr>
- <tr><th>手机</th><td>'.$staffInfo['telephone'].'</td><th>电话</th><td>'.$staffInfo['phone'].'</td></tr>
- <tr><th>QQ</th><td>'.$staffInfo['qq'].'</td><th>邮箱</th><td>'.$staffInfo['email'].'</td></tr>
- </tbody></table>
- </div>');
- echo json_encode($staffHtml);
- }
- function ajaxGetCompanyByAdd(){
- $cid=isset($_POST['cid'])?$_POST['cid']:"";
- if(!empty($cid)){
- Doo::loadModel ( 'company' );
- $company = new company();
- Doo::loadModel ( 'client' );
- Doo::loadModel('district');
- $district=new district();
- $client = new client();
- $districtInfo=$district->get_lv(1);
- $companyInfo=$client->getClientByCompanyId($cid);
- $companyInfo=$companyInfo[0];
- $cInfo=$company->getOne(array('where'=>"cid = ".$cid,'asArray' => TRUE));
- $companyInfo['ride']=$cInfo['ride'];
- $companyInfo['landmarks']=$cInfo['landmarks'];
- $companyInfo['stay']=$cInfo['stay'];
- $artld=explode(',', $cInfo['local']);
- $districtid=explode(',', $cInfo['district']);
- $html="";
- $html.='<select name="lv21" id="lv31" onchange="dislv(\'lv31\',\'32\');"><option value="'.$districtid[0].'">'.$artld[0].'</option>';
- // foreach ($districtInfo as $key=>$value){
- //
- // $html.='<option selected value="'.$value['id'].'">'.$value['name'].'</option>';
- // }
- $html.='</select> ';
- $html.='<span id="mlv32">
- <select id="lv32" name="lv22">
- <option selected value="'.$districtid[1].'" >'.$artld[1].'</option>
- </select>
- </span>';
- $html.='<span id="mlv33">
- <select id="lv33" name="lv23">
- <option selected value="'.$districtid[2].'" >'.$artld[2].'</option>
- </select>
- </span>';
- $companyInfo['dishtml']=$html;
- $companyInfo['natureAr']=$this->nature;
- $companyInfo['natureArlenght']=12;
- echo json_encode(array("success"=>true,'data'=>$companyInfo));die;
- }else
- echo json_encode(array("success"=>false,'data'=>''));die;
- }
- function doEditCompanyD(){
- $cid=isset($_POST['cid'])?$_POST['cid']:0;
- $companyname=isset($_POST['companyname'])?$_POST['companyname']:"";
- $lv21=isset($_POST['lv21'])?$_POST['lv21']:0;
- $lv22=isset($_POST['lv22'])?$_POST['lv22']:0;
- $lv23=isset($_POST['lv23'])?$_POST['lv23']:0;
- $nature=isset($_POST['nature'])?$_POST['nature']:"";
- $fax=isset($_POST['fax'])?$_POST['fax']:"";
- $webservice=isset($_POST['webservice'])?$_POST['webservice']:"";
- $address=isset($_POST['address'])?$_POST['address']:"";
- $ride=isset($_POST['ride'])?$_POST['ride']:"";
- $stay=isset($_POST['stay'])?$_POST['stay']:"";
- $landmarks=isset($_POST['landmarks'])?$_POST['landmarks']:"";
- if(empty($cid)||empty($companyname)){
- echo json_encode(array("success"=>false));die;
- }
- Doo::loadModel("company");
- Doo::loadModel("client");
- $client=new client();
- $company=new company();
- $company->cid=$cid;
- if(!empty($lv21)&&!empty($lv22)&&!empty($lv23)){
- Doo::loadModel ( 'district' );
- $district = new district ();
- //更新公司信息
- $lv1=$district->getbyid($lv21);
- $lv2=$district->getbyid($lv22);
- $lv3=$district->getbyid($lv23);
- $company->district=$lv21.",".$lv22.",".$lv23;
- $company->local=$lv1[0]['name'].",".$lv2[0]['name'].",".$lv3[0]['name'];
- }
- if(!empty($nature)){
- $nature=implode(",", $nature);
- $company->nature=$nature;
- }
- if(!empty($companyname)){
- $company->companyname=$companyname;
- $client->companyname=$companyname;
- }
- if(!empty($fax))
- $company->fax=$fax;
- if(!empty($webservice))
- $company->webservice=$webservice;
- if(!empty($address))
- $company->address=$address;
- if(!empty($ride))
- $company->ride=$ride;
- if(!empty($stay))
- $company->stay=$stay;
- if(!empty($landmarks))
- $company->landmarks=$landmarks;
- $company->update();
- $client->update(array('where'=>' companyid ='.$cid));
- echo json_encode(array("success"=>true));die;
- }
- function ajaxEditCompany(){
- $companyname=isset($_POST['companyId'])?$_POST['companyId']:0;
- if(!empty($companyname)){
- Doo::loadModel ( 'company' );
- $company = new company();
- $companyInfo=$company->getOne(array('where'=>"cid = '".$companyname."'",'asArray' => TRUE));
- if(!empty($companyInfo)){
- Doo::loadModel('district');
- $district=new district();
- $districtinfo=$district->get_lv(1);
- $dinfo=$district->getbyidlist($companyInfo['district']);
- $html='
- <div class="contactInfo clearfix">
- <div class="header">
- <h1 class="companyName">'.$companyInfo['companyname'].'</h1>
- </div>
- </div>
- <div class="lockRecord">
- <div class="contactPanel">
- <table>
- <tbody><tr><th>单位全称</th><td colspan="3"><input type="text" name="companyname" id="companyname" value="'.$companyInfo['companyname'].'"></td></tr>
- <tr><th>地区</th><td colspan="3">
- <select name="lv21" id="lv21" onchange="dislv(\'lv21\',22);">
- <option value="0">请选择</option>';
- foreach ($districtinfo as $key=>$value){
- if($value['id']==$dinfo[0]['id'])
- $html.='<option selected value="'.$value['id'].'">'.$value['name'].'</option>';
- else
- $html.='<option value="'.$value['id'].'">'.$value['name'].'</option>';
- }
- $html.='</select>
- <span id="mlv22">
- <select id="lv22">
- <option value="'.$dinfo[1]['id'].'">'.$dinfo[1]['name'].'</option>
- </select>
- </span>
- <span id="mlv23">
- <select id="lv23">
- <option value="'.$dinfo[2]['id'].'">'.$dinfo[2]['name'].'</option>
- </select>
- </span>
- </td></tr>
- ';
- $html.='<tr><th>性质</th><td colspan="3">';
- $ntre=explode(",", $companyInfo['nature']);
- foreach ($this->nature as $key=>$value){
- $falg=true;
- foreach ($ntre as $k=>$v){
- if($value==$v){
- $falg=false;
- $html.='<label><input type="checkbox" checked name="nature[]" value="'.$value.'">'.$value.'</label> ';
- }
- }
- if($falg)
- $html.='<label><input type="checkbox" name="nature[]" value="'.$value.'">'.$value.'</label> ';
- }
- $html.=' </td></tr>
- <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>
- <tr><th>单位地址</th><td colspan="3"><input type="text" name="address" id="address" value="'.$companyInfo['address'].'"> </td></tr>
- <tr><th>乘车路线</th><td colspan="3"><input type="text" name="ride" id="ride" value="'.$companyInfo['ride'].'"> </td></tr>
- <tr><th>地标建筑</th><td colspan="3"><input type="text" name="landmarks" id="landmarks" value="'.$companyInfo['landmarks'].'"> </td></tr>
- <tr><th>住宿参考</th><td colspan="3"><input type="text" name="stay" id="stay" value="'.$companyInfo['stay'].'"> </td></tr>
- <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>
- </tbody></table>
- <div class="bsAlert bsInfo">单位全称将与该单位已存在的客户进行同步;其他单位信息不会进行同步;<br>单位信息随该单位第一位客户录入,并作为“在这添加客户”的基础数据</div>
- </div>
- </div>
- ';
- echo json_encode(array("success"=>true,'html'=>$html));die;
- }
- }else
- echo json_encode(array("success"=>false,'html'=>''));die;
- }
- function ajaxGetCompany(){
- $companyname=isset($_POST['companyId'])?$_POST['companyId']:0;
- if(!empty($companyname)){
- Doo::loadModel ( 'company' );
- $company = new company();
- $companyInfo=$company->getOne(array('where'=>"cid = '".$companyname."'",'asArray' => TRUE));
- if(!empty($companyInfo)){
-
- Doo::loadModel ( 'client' );
- Doo::loadModel ( 'staff' );
- Doo::loadModel ( 'client_staff' );
- Doo::loadModel ( 'longle' );
- $longle = new longle();
- $client_staff = new client_staff();
- $staff = new staff();
- $client = new client();
-
- $clientlist=$client->getClientByCompanyId($companyInfo['cid']);
- $department=$client->getDepartment($companyInfo['cid']);
- Doo::loadModel("tagCompanyNexus");
- Doo::loadModel("tagCompany");
- $tag=new tagCompany();
- $tag_client=new tagCompanyNexus();
-
- $tagId=$tag_client->getTagClientBySCid($companyInfo['cid'], $this->staff[0]['sid']);
- $taginfo=$tag->getTagByTidL($tagId['tag']);
- $taghtml="";
-
- foreach ($taginfo as $key=>$value){
- $taghtml.='<span class="contactsTag tagCol-0'.$value['colorid'].'">'.$value['name'].'</span>';
- }
-
-
- $html='<div class="header">
- <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>
- <div class="contactPanel">
- <table>
- <tbody>
- <tr><th>单位地区</th><td><span>'.$companyInfo['local'].'</span></td><th>单位性质</th><td>'.$companyInfo['nature'].'</td></tr>
- <tr><th>单位地址</th><td colspan="3">'.$companyInfo['address'].'</td></tr>
- <tr><th>单位乘车</th><td colspan="3">'.$companyInfo['ride'].'</td></tr>
- <tr><th>单位地标</th><td colspan="3">'.$companyInfo['landmarks'].'</td></tr>
- <tr><th>单位住宿</th><td colspan="3">'.$companyInfo['stay'].'</td></tr>
- <tr><td colspan="4">
- '.$taghtml.'
- </td></tr>
- </tbody></table></div>
- <h2 class="cate">';
- $html.='<a href="javascript:void(0)" onclick="departmentC()" class="now">不限</a>';
- foreach ($department as $key=>$value){
- if ($value!="")
- $html.='<a href="javascript:void(0)" onclick="departmentC(\''.$value['department'].'\')">'.$value['department'].'</a>';
- }
- $html.='</h2></div><script>$(".header .cate a").click(function(){
- $(this).addClass("now").siblings("a").removeClass("now");
- });
- </script>';
- $html.='<div class="lockRecord autoHeightR2" >';
- foreach ($clientlist as $key=>$value){
- $scinfo=$client_staff->getClientByCid($value['cid']);
- $staffinfo=$staff->getUserById($scinfo['sid']);
- $html.='<div class="contactPanel" id="PART_'.$value['department'].'">
- <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>
- <tbody><tr><th>性别</th><td>'.$value['gender'].'</td><th>昵称</th><td>'.$value['nicename'].'</td></tr>
- <tr><th>部门</th><td>'.$value['department'].'</td><th>办公室</th><td>'.$value['office'].'</td></tr>
- <tr><th>手机</th><td>'.$value['telephone'].'</td><th>电话</th><td>'.$value['phone'].'</td></tr>
- <tr><th>QQ</th><td>'.$value['qq'].'</td><th>邮箱</th><td>'.$value['email'].'</td></tr>
- <tr><th>备注</th><td colspan="3">'.$value['mark'].'</td></tr>';
- //$longleinfo=$longle->getLongleBykeynum($value['keynum']);
- $longleinfo=$longle->getLongleByClientid($value['cid']);
- if(empty($longleinfo)){
- $longleinfo=array(0=>array('lid'=>'','key_num'=>'','product'=>'','statusT'=>''));
- }
- $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>';
- $html.='</tbody></table></div>';
- }
- $html.="</div><script type='text/javascript'>autoFlashHeight();</script>";
- echo json_encode(array("success"=>true,'html'=>$html));die;
- }
- }else
- echo json_encode(array("success"=>false,'html'=>''));die;
- }
- function checkclicomname(){//地区区分
- $companyname=isset($_POST['companyname'])?$_POST['companyname']:"";
- $clientname=isset($_POST['clientname'])?$_POST['clientname']:"";
- $district1=isset($_POST['district1'])?$_POST['district1']:0;
- $district2=isset($_POST['district2'])?$_POST['district2']:0;
- $district3=isset($_POST['district3'])?$_POST['district3']:0;
- Doo::loadModel ( 'client' );
- $client = new client ();
- $local=$district1.",".$district2.",".$district3;
- $companyname=trim($companyname);
- $clientname=trim($clientname);
- $clientinfo=$client->getClientToName($clientname,$companyname,$local);
- if(!empty($clientinfo)){
- echo json_encode(array('success'=>false));
- }else{
- echo json_encode(array('success'=>true));
- }
- }
- function ajaxGetClientInfoN(){
- $clientname=isset($_POST['client'])?$_POST['client']:"";
- if($clientname==""){
- echo json_encode(array("success"=>false));die;
- }
- Doo::loadModel ( 'client' );
- Doo::loadModel ( 'client_staff' );
- Doo::loadModel ( 'longle' );
- Doo::loadModel ( 'company' );
- Doo::loadModel ( 'service_log' );
- $service_log = new service_log();
- $company = new company();
- $longle = new longle();
- $client = new client ();
- $client_staff = new client_staff ();
- $clientInfo=$client->getOne(array("where"=>' cid like "'.$clientname.'"', 'asArray' => TRUE));
- if(empty($clientInfo)){
- echo json_encode(array("success"=>false,'html'=>''));die;
- }
- //获取锁
- $longleInfo=$longle->getLongleByClient($clientname);
- $k="";
- foreach ($longleInfo as $key=>$value){
- if($value['status']==6||$value['status']==7)
- $k.='<a href="javascript:void(0)" class="disenable" onclick="getLock('.$value['lid'].')" >'.$value['key_num'].'/'.$value['product'].'/'.$value['statusT'].'</a> ';
- else
- $k.='<a href="javascript:void(0)" onclick="getLock('.$value['lid'].')" >'.$value['key_num'].'/'.$value['product'].'/'.$value['statusT'].'</a> ';
- }
- //获取办事人
- $staffInfo=$client_staff->getClientByCid($clientInfo['cid']);
- //获取公司信息
- $companyInfo=$company->getCompanyByCid($clientInfo['companyid']);
- $serviceLog=$service_log->getServiceByClientid($clientInfo['cid']);
- $u="";
- $order = array("\r\n", "\n", "\r");
- $replace = '</br>';
- foreach ($serviceLog as $key=>$value){
- $datetime=explode("-", $value['date']);
- $u.='<div class="infoFlowList">
- <div class="dateTitle">
- <em class="month"><span class="num">'.$datetime['1'].'</span><span class="text">-'.$datetime['2'].'</span></em>
- <span class="year">'.$datetime['0'].'</span>
- </div>
- <ul class="flowList">';
- if($value['status']==1)
- $u.='<li class="item iconService">上门服务</li>';
- elseif ($value['status']==2)
- $u.='<li class="item iconPhone">电话拜访</li>';
- elseif ($value['status']==3)
- $u.='<li class="item iconOther">其他</li>';
- $u.='
- <li class="item">'.$value['category'].'<a href="javascript:void(0)" onclick="getStaffInfo(\''.$value['staffname'].'\')" >'.$value['staffname'].'</a></li>
- <li class="item">
- '.str_replace($order, $replace, $value['mark']).'
- </li>
- </ul>
- </div>';
- }
- Doo::loadModel("tag_client");
- Doo::loadModel("tag");
- $tag=new tag();
- $tag_client=new tag_client();
- $tagId=$tag_client->getTagClientBySCid($clientInfo['cid'], $this->staff[0]['sid']);
- $taginfo=$tag->getTagByTidL($tagId['tag']);
- // $taghtml="";
- //
- // foreach ($taginfo as $key=>$value){
- // $taghtml.='<span class="contactsTag tagCol-0'.$value['colorid'].'">'.$value['name'].'</span>';
- // }
- $mhtml="";$dhtml="";
- for ($month=1;$month<=12;$month++){
- if(date("m")==$month)
- $mhtml.='<option selected value="'.$month.'">'.$month.'月</option>';
- else
- $mhtml.='<option value="'.$month.'">'.$month.'月</option>';
- }
- for ($day=1;$day<=31;$day++){
- if(date("d")==$day)
- $dhtml.='<option selected value="'.$day.'">'.$day.'日</option>';
- else
- $dhtml.='<option value="'.$day.'">'.$day.'日</option>';
- }
- // $b="";
- // if(!empty($staffInfo))
- // $b='<p class="fR">'.$staffInfo['category'].'-<a href="javascript:void(0)" onclick="getStaffInfo(\''.$staffInfo['username'].'\')" >'.$staffInfo['username'].'</a></p>'.$clientInfo['clientname'].' ';
- //
- $m="";
- if(!empty($companyInfo)){
- $m='
- <table width="100%">
- <tbody>
- <tr><th>单位全称</th><td colspan="3"><a href="javascript:void(0)" >'.$companyInfo[0]['companyname'].'</a></td></tr>
- <tr><th>地区</th><td>'.$companyInfo[0]['local'].'</td><th>部门/职位</th><td>'.$clientInfo['department'].'/'.$clientInfo['position'].'</td></tr>
- <tr><th>传真</th><td>'.$companyInfo[0]['fax'].'</td><th>办公室</th><td>'.$companyInfo[0]['office'].'</td></tr>
- <tr><th>单位地址</th><td colspan="3">'.$companyInfo[0]['address'].'</td></tr>
- <tr><th>乘车路线</th><td colspan="3">'.$companyInfo[0]['ride'].'</td></tr>
- <tr><th>地标建筑</th><td colspan="3">'.$companyInfo[0]['landmarks'].'</td></tr>
- <tr><th>参考住宿</th><td colspan="3">'.$clientInfo['stay'].'</td></tr>
- <tr><th>单位主页</th><td colspan="3">'.$clientInfo['webservice'].'</td></tr>
- </tbody></table>
- ';
- }
- $clientHtml=array('html'=>'
- <div class="modal-dialog ">
- <div class="modal-content">
- <div class="modal-header">
- <h3><span class="fR"><a>'.$staffInfo['category'].' '.$staffInfo['username'].'</a></span>'.$clientInfo['clientname'].'</h3>
- </div>
- <div class="modal-body">
- <div class="modalClientTable">
- <table width="100%">
- <tbody><tr><th>性别</th><td>'.$clientInfo['gender'].'</td><th>昵称</th><td>'.$clientInfo['nicename'].'</td></tr>
- <tr><th>手机</th><td>'.$clientInfo['telephone'].'</td><th>QQ</th><td>'.$clientInfo['qq'].'</td></tr>
- <tr><th>电话</th><td>'.$clientInfo['phone'].'</td><th>邮箱</th><td>'.$clientInfo['email'].'</td></tr>
- <tr><th>软件锁</th><td colspan="3">'.$k.'</td></tr>
- <tr><td colspan="4">
- </td></tr>
- </tbody>
- </table>
- '.$m.'
- <div class="clearfix">
- '.$u.'
- </div>
- </div>
- </div>
- <div class="modal-footer">
- <a href="javascript:void(0)" onclick="closeClick()" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a>
- </div>
- </div></div>
- ');
- echo json_encode($clientHtml);
- }
- function ajaxGetClientInfo(){
- $clientname=isset($_POST['client'])?$_POST['client']:"";
- if($clientname==""){
- echo json_encode(array("success"=>false));die;
- }
- Doo::loadModel ( 'client' );
- Doo::loadModel ( 'client_staff' );
- Doo::loadModel ( 'longle' );
- Doo::loadModel ( 'company' );
- Doo::loadModel ( 'service_log' );
- Doo::loadModel("district");
- $district=new district();
- $service_log = new service_log();
- $company = new company();
- $longle = new longle();
- $client = new client ();
- $client_staff = new client_staff ();
- $nameStr=explode(",", $clientname);
- //$clientname=$nameStr[1];
- if(!empty($nameStr[0])){
- $clientInfo=$client->getOne(array("where"=>' cid = "'.$nameStr[0].'"', 'asArray' => TRUE));
- }elseif (!empty($nameStr[1]))
- $clientInfo=$client->getOne(array("where"=>' clientname = "'.$nameStr[1].'"', 'asArray' => TRUE));
- else
- $clientInfo=array();
- if(empty($clientInfo)){
- echo json_encode(array("success"=>false,'html'=>''));die;
- }
- //获取锁
- $longleInfo=$longle->getLongleByClientid($clientInfo['cid']);
- $k="";
- foreach ($longleInfo as $key=>$value){
- if($value['status']==6||$value['status']==7)
- $k.='<a href="javascript:void(0)" class="disenable" onclick="getLock('.$value['lid'].')" >'.$value['key_num'].'/'.$value['product'].'/'.$value['statusT'].'</a> ';
- else
- $k.='<a href="javascript:void(0)" onclick="getLock('.$value['lid'].')" >'.$value['key_num'].'/'.$value['product'].'/'.$value['statusT'].'</a> ';
- }
- //获取办事人
- $staffInfo=$client_staff->getClientByCid($clientInfo['cid']);
- $b="";
- if(!empty($staffInfo))
- $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>';
- //获取公司信息
- $companyInfo=$company->getCompanyByCid($clientInfo['companyid']);
- $serviceLog=$service_log->getServiceByClientid($clientInfo['cid']);
- $local=$district->getbyidlist($clientInfo['district']);
- if(!isset($local[1]))
- $local[1]['name']="";
- if(!isset($local[2]))
- $local[2]['name']="";
- $m="";
- if(!empty($companyInfo)){
- $m='<div class="contactPanel">
- <table>
- <tbody>
- <tr><th>单位全称</th><td colspan="3"><a href="javascript:void(0)" onclick="getCompany(\''.$companyInfo[0]['cid'].'\')">'.$companyInfo[0]['companyname'].'</a></td></tr>
- <tr><th>单位主页</th><td colspan="3">'.$clientInfo['webservice'].'</td></tr>
- <tr><th>客户地区</th><td>'.$local[0]['name'].','.$local[1]['name'].','.$local[2]['name'].'</td><th>部门/职位</th><td>'.$clientInfo['department'].'/'.$clientInfo['position'].'</td></tr>
- <tr><th>客户传真</th><td>'.$clientInfo['fax'].'</td><th>办公室</th><td>'.$clientInfo['office'].'</td></tr>
- <tr><th>客户地址</th><td colspan="3">'.$clientInfo['address'].'</td></tr>
- <tr><th>客户乘车</th><td colspan="3">'.$clientInfo['ride'].'</td></tr>
- <tr><th>客户地标</th><td colspan="3">'.$clientInfo['landmarks'].'</td></tr>
- <tr><th>客户住宿</th><td colspan="3">'.$clientInfo['stay'].'</td></tr>
- </tbody></table>
- </div>';
- }
- $u="";
- $order = array("\r\n", "\n", "\r");
- $replace = '</br>';
- foreach ($serviceLog as $key=>$value){
- $datetime=explode("-", $value['date']);
- $u.='<div class="infoFlowList">
- <div class="dateTitle">
- <em class="month"><span class="num">'.$datetime['1'].'</span><span class="text">-'.$datetime['2'].'</span></em>
- <span class="year">'.$datetime['0'].'</span>
- </div>
- <ul class="flowList">';
- if($value['status']==1)
- $u.='<li class="item iconService">上门服务<';
- elseif ($value['status']==2)
- $u.='<li class="item iconPhone">电话拜访<';
- elseif ($value['status']==3)
- $u.='<li class="item iconOther">其他<';
- $u.=$value['category'].'<a href="javascript:void(0)" onclick="getStaffInfo(\''.$value['staffname'].'\')" >'.$value['staffname'].'</a></li>
- <li class="item">
- '.str_replace($order, $replace, $value['mark']).'
- </li>
- </ul>
- </div>';
- }
- Doo::loadModel("tag_client");
- Doo::loadModel("tag");
- $tag=new tag();
- $tag_client=new tag_client();
- $tagId=$tag_client->getTagClientBySCid($clientInfo['cid'], $this->staff[0]['sid']);
- $taginfo=$tag->getTagByTidL($tagId['tag']);
- $taghtml="";
- foreach ($taginfo as $key=>$value){
- $taghtml.='<span class="contactsTag tagCol-0'.$value['colorid'].'">'.$value['name'].'</span>';
- }
- $mhtml="";$dhtml="";$yhtml="";
- for ($year=2020;$year>=2004;$year--){
- if(date("Y")==$year)
- $yhtml.='<option selected value="'.$year.'">'.$year.'年</option>';
- else
- $yhtml.='<option value="'.$year.'">'.$year.'年</option>';
- }
- for ($month=1;$month<=12;$month++){
- if(date("m")==$month)
- $mhtml.='<option selected value="'.$month.'">'.$month.'月</option>';
- else
- $mhtml.='<option value="'.$month.'">'.$month.'月</option>';
- }
- for ($day=1;$day<=31;$day++){
- if(date("d")==$day)
- $dhtml.='<option selected value="'.$day.'">'.$day.'日</option>';
- else
- $dhtml.='<option value="'.$day.'">'.$day.'日</option>';
- }
- $clientHtml=array('html'=>'<div class="contactInfo clearfix">
- <div class="contactPanel">
- <h1>'.$b.'<a data-original-title="编辑客户" data-toggle="ctooltip" data-placement="right" href="javascript:clientEdit('.$clientInfo['cid'].')" class="icon- edit">I</a></h1>
- <table>
- <tbody><tr><th>性别</th><td>'.$clientInfo['gender'].'</td><th>昵称</th><td>'.$clientInfo['nicename'].'</td></tr>
- <tr><th>手机</th><td>'.$clientInfo['telephone'].'</td><th>QQ</th><td>'.$clientInfo['qq'].'</td></tr>
- <tr><th>电话</th><td>'.$clientInfo['phone'].'</td><th>邮箱</th><td>'.$clientInfo['email'].'</td></tr>
- <tr><th>软件锁</th><td colspan="3">'.$k.'</td></tr>
- <tr><th>备注</th><td colspan="3">'.$clientInfo['mark'].'</td></tr>
- <tr><td colspan="4">
- '.$taghtml.'
- </td></tr>
- </tbody></table>
- </div>
- '.$m.'
- </div>
- <div class="lockRecord autoHeightR1" >
- <!--添加记录按钮-->
- <div class="addRecord addRecordButton clearfix" >
- <a href="#" onclick="slideupInfo(this)">+ 打开添加服务记录</a>
- </div>
- <!--添加记录-->
- <div class="addRecord addRecordForm clearfix hide">
- <a onclick="slidedownInfo(this)" class="fR slidedownInfo">- 关闭添加记录</a>
- <form name="lk" action="/addServiceLog" method="post" >
- <div class="control-group">
- <div class="controls">
- <label class="radio inline">
- <input type="radio" name="logstatus" id="status" checked value="2">电话拜访
- </label>
- <label class="radio inline">
- <input type="radio" name="logstatus" id="status" value="1" >上门服务
- </label>
- <label class="radio inline">
- <input type="radio" name="logstatus" id="status" value="3">其他
- </label>
- </div>
- </div>
- <div class="control-group">
- <div class="controls">时间:
- <select name="y" id="y">
- '.$yhtml.'
- </select>
- <select name="m" id="m">
- '.$mhtml.'
- </select>
- <select name="d" id="d">
- '.$dhtml.'
- </select>
- </div>
- </div>
-
- <link href="'.WEB_SITE_GLOBAL.'css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
- <!--添加记录-备注-->
- <!--<div class="control-group">
- <div class="controls">
- <select name="date" id="date">
- <option value="2013">2013</option>
- </select>
- </div>
- </div>-->
- <div class="control-group">
- <div class="controls" onclick="slideupInfo()">
- <textarea name="mark" id="mark" style="width:95%" rows="5"></textarea>
-
- <div class="bsAlert bsWarning"><b>含泪告知:</b>客户记录暂时无法修改!删除!,添加时请谨慎。点击确定添加成功后,信息会立即出现在下方!注意咯,别猛戳‘确定添加’导致重复添加了哦~</div>
- </div>
- </div>
-
- <div class="control-group">
- <div class="controls">
- <div style="display:inline-block;margin-right:10px"><label><input name="Remind" onclick="reFK()" type="checkbox" value="1"> 添加提醒</label></div>
- <span id="reHL" class="hide">
- <div>
- 限期:<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">
- <input type="hidden" name="time" id="dtp_input2" value="" class="hide"/>
- </div>
- <div>
- 备注:<input id="remark" name="remark" type="text"></span>
- </div>
- </div>
-
- <div class="control-group">
- <div class="controls clearfix">
- <input type="button" value="确定添加" id="conSer" onclick="aServiceLog(\''.$this->staff[0]['category'].'\',\''.$this->staff[0]['username'].'\','.$clientInfo['cid'].')" class="button"></input>
- <div id="load"></div>
- </div>
- </div>
- </div>
- </form>
- </div>
- <!--添加记录按钮-->
- <!--记录列表-->
- <div id="kl"></div>
- '.$u.'
-
-
- <script type="text/javascript" src="'.WEB_SITE_GLOBAL.'js/bootstrap.min.js"></script>
- <script type="text/javascript" src="'.WEB_SITE_GLOBAL.'js/bootstrap-datetimepicker.js" charset="UTF-8"></script>
- <script type="text/javascript" src="'.WEB_SITE_GLOBAL.'js/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
- <script type="text/javascript">
-
- $(".form_date").datetimepicker({
- language: "zh-CN",
- weekStart: 1,
- todayBtn: 1,
- autoclose: 1,
- todayHighlight: 1,
- startView: 2,
- minView: 2,
- forceParse: 0,
- startDate: "'.date('Y-m-d').'"
- });
-
- </script>
-
- <script type="text/javascript">autoFlashHeight();</script> </div>');
- echo json_encode($clientHtml);
- }
- function ajaxGetCompanyInfo(){
- }
- function checkClient(){
- $searchDbInforItem=isset($_POST['name'])?$_POST['name']:"";
- $searchDbInforItem=explode('-', $searchDbInforItem);
- if(!empty($searchDbInforItem)){
- Doo::loadModel ( 'client' );
- $client = new client();
- $clientInfo=$client->getClientByName2($searchDbInforItem[0],$searchDbInforItem[1]);
- if(!empty($clientInfo))
- echo json_encode(array("success"=>true));
- else
- echo json_encode(array("success"=>false));
- }else{
- echo json_encode(array("success"=>false));
- }
- }
- function searchClient(){
- $searchDbInforItem=isset($_GET['searchDbInforItem'])?$_GET['searchDbInforItem']:"";
- if(!empty($searchDbInforItem)){
- Doo::loadModel ( 'client' );
- $client = new client();
- $clientInfo=$client->getClientByName($searchDbInforItem);
- echo json_encode($clientInfo);
- }else{
- echo json_encode(array(0=>array('clientname'=>'')));
- }
- }
- function searchCompany(){
- $searchDbInforItem=isset($_GET['searchDbInforItem'])?$_GET['searchDbInforItem']:"";
- if(!empty($searchDbInforItem)){
- Doo::loadModel ( 'company' );
- $company = new company();
- $clientInfo=$company->searchCompany($searchDbInforItem);
- echo json_encode($clientInfo);
- }else{
- echo json_encode(array(0=>array('companyname'=>'','local'=>'')));
- }
- }
- function checkCompany(){
- $searchDbInforItem=isset($_POST['name'])?$_POST['name']:"";
- $searchDbInforItem=explode('-', $searchDbInforItem);
- $this->nature['naturelenght']=15;
- Doo::loadModel ( 'district' );
- $district = new district ();
- $d=$district->get_lv(1);
- $html='<option vlaue="0">请选择</option>';
- foreach ($d as $key=>$value){
- $html.='<option value="'.$value['id'].'">'.$value['name'].'</option>';
- }
- $this->nature['district']=$html;
- if(!empty($searchDbInforItem)){
- Doo::loadModel ( 'company' );
- $company = new company();
- if(!isset($searchDbInforItem[1])){
- echo json_encode(array("success"=>false,'nature'=>$this->nature));die;
- }
- $clientInfo=$company->getCompanyByName($searchDbInforItem[0],$searchDbInforItem[1]);
- if(!empty($clientInfo))
- echo json_encode(array("success"=>true,'data'=>$clientInfo));
- else
- echo json_encode(array("success"=>false,'nature'=>$this->nature));
- }else{
- echo json_encode(array("success"=>false,'nature'=>$this->nature));
- }
- }
- function checkLongle(){
- $searchDbInforItem=isset($_POST['name'])?$_POST['name']:"";
- $searchDbInforItem=explode(' ', $searchDbInforItem);
- if(!empty($searchDbInforItem)){
- Doo::loadModel ( 'longle' );
- $longle = new longle();
- $clientInfo=$longle->getLongleBykeynum($searchDbInforItem[0]);
- if(!empty($clientInfo))
- echo json_encode(array("success"=>true));
- else
- echo json_encode(array("success"=>false));
- }else{
- echo json_encode(array("success"=>false));
- }
- }
- function searchLongle(){
- $searchDbInforItem=isset($_GET['searchDbInforItem'])?$_GET['searchDbInforItem']:"";
- if(!empty($searchDbInforItem)){
- Doo::loadModel ( 'longle' );
- $longle = new longle();
- $longleInfo=$longle->getLongleBykeynum2($searchDbInforItem);
- echo json_encode($longleInfo);
- }else{
- echo json_encode(array(0=>array('clientname'=>'')));
- }
- }
- function updateChangeCompany(){
- $cid=isset($_POST['cid'])?$_POST['cid']:0;
- $clientID=isset($_POST['clientID'])?$_POST['clientID']:0;
- $companyname=isset($_POST['companyname'])?$_POST['companyname']:"";
- Doo::loadModel ( 'company' );
- Doo::loadModel ( 'client' );
- $client = new client();
- $company = new company();
- $companyname=explode("-", $companyname);
- if(isset($companyname[1]))
- $k=$company->getCompanyByName($companyname[0], $companyname[1]);
- else
- $k=array();
- if(!empty($cid)&&!empty($k)&&!empty($clientID)){
- $client->cid=$clientID;
- $client->companyid=$cid;
- $client->companyname=$companyname[0];
- $client->update();
- }else{
- $local1=isset($_POST['lv21'])?$_POST['lv21']:0;
- $local2=isset($_POST['lv22'])?$_POST['lv22']:0;
- $local3=isset($_POST['lv23'])?$_POST['lv23']:0;
- Doo::loadModel ( 'district' );
- $district = new district ();
- //更新公司信息
- $lv1=$district->getbyid($local1);
- $lv2=$district->getbyid($local2);
- $lv3=$district->getbyid($local3);
- if(empty($local1)||empty($local2))
- return "/";
- if(!empty($local1)&&!empty($local2))
- $company->local=$lv1[0]['name'].",".$lv2[0]['name'].",".$lv3[0]['name'];
- if(!empty($local1)&&!empty($local2))
- $company->district=$local1.",".$local2.",".$local3;
- $nature=isset($_POST['nature'])?$_POST['nature']:"";
- $fax=isset($_POST['fax'])?$_POST['fax']:"";
- $webservice=isset($_POST['webservice'])?$_POST['webservice']:"";
- $address=isset($_POST['address'])?$_POST['address']:"";
- $landmarks=isset($_POST['landmarks'])?$_POST['landmarks']:"";
- $stay=isset($_POST['stay'])?$_POST['stay']:"";
- $ride=isset($_POST['ride'])?$_POST['ride']:"";
- $nature=implode(",", $nature);
- $company->companyname=$companyname[0];
- $company->ride=$ride;
- $company->fax=$fax;
- $company->webservice=$webservice;
- $company->address=$address;
- $company->landmarks=$landmarks;
- $company->stay=$stay;
- $company->nature=$nature;
- $cid=$company->insert();
- $client->cid=$clientID;
- $client->companyid=$cid;
- $client->companyname=$companyname[0];
- $client->update();
- }
- return "/";
- }
- function AddClientInfo(){//不编辑公司
- $cid=isset($_POST['cid'])?$_POST['cid']:0;
- $clientname=isset($_POST['clientname'])?$_POST['clientname']:"";
- $gender=isset($_POST['gender'])?$_POST['gender']:"";
- $nicename=isset($_POST['nicename'])?$_POST['nicename']:"";
- $telephone=isset($_POST['telephone'])?$_POST['telephone']:"";
- $phone=isset($_POST['phone'])?$_POST['phone']:"";
- $email=isset($_POST['email'])?$_POST['email']:"";
- $unit=isset($_POST['unit'])?$_POST['unit']:"";
- $fax=isset($_POST['fax'])?$_POST['fax']:"";
- $webservice=isset($_POST['webservice'])?$_POST['webservice']:"";
- $department=isset($_POST['department'])?$_POST['department']:"";
- $position=isset($_POST['position'])?$_POST['position']:"";
- $office=isset($_POST['office'])?$_POST['office']:"";
- $address=isset($_POST['address'])?$_POST['address']:"";
- $ride=isset($_POST['ride'])?$_POST['ride']:"";
- $landmarks=isset($_POST['landmarks'])?$_POST['landmarks']:"";
- $qq=isset($_POST['qq'])?$_POST['qq']:"";
- $priority=isset($_POST['priority'])?$_POST['priority']:5;
- $stay=isset($_POST['stay'])?$_POST['stay']:"";
- $mark=isset($_POST['mark'])?$_POST['mark']:"";
- $lv21=isset($_POST['lv21'])?$_POST['lv21']:0;
- $lv22=isset($_POST['lv22'])?$_POST['lv22']:0;
- $lv23=isset($_POST['lv23'])?$_POST['lv23']:0;
- if(!empty($cid)&&!empty($clientname)){
- Doo::loadModel ( 'client' );
- Doo::loadModel('district');
- $district=new district();
- $client = new client();
- $client->cid=$cid;
- $client->clientname=$clientname;
- $client->gender=$gender;
- $client->nicename=$nicename;
- $client->telephone=$telephone;
- $client->phone=$phone;
- $client->email=$email;
- // if(!empty($unit)){
- // $client->unit=$unit;
- // $client->companyname=$unit;
- // }
- if(!empty($lv21)&&!empty($lv22)&&!empty($lv23)){
- $client->district=$lv21.",".$lv22.",".$lv23;
- }
- if(!empty($client->district)){
- $districtList=$district->find(array('where'=>'id in('.$client->district.')','asArray'=>true));
- $jsonString=array();
- foreach ($districtList as $value){
- array_push($jsonString, $value['name']);
- }
- $jsonString=implode(",", $jsonString);
- if (!empty($jsonString))
- $client->local=$jsonString;
- }
- $client->fax=$fax;
- $client->webservice=$webservice;
- $client->department=$department;
- $client->position=$position;
- $client->office=$office;
- $client->address=$address;
- $client->ride=$ride;
- $client->landmarks=$landmarks;
- $client->qq=$qq;
- $client->stay=$stay;
- $client->priority=$priority;
- $client->mark=$mark;
- $client->updatetime=time();
- $client->update();
- // Doo::loadModel ( 'company' );
- // $company = new company();
- // $companyid=$client->getOne(array('where'=>' cid='.$cid,'asArray'=>true));
- // $company->office=$office;
- // $company->fax=$fax;
- // $company->address=$address;
- // $company->ride=$ride;
- // $company->landmarks=$landmarks;
- // $company->cid=$companyid['companyid'];
- // if(!empty($unit)){
- // $company->companyname=$unit;
- // }
- // $company->update();
- $clientInfo=$client->getOne(array('where'=>' cid='.$cid,'asArray'=>true));
- //日常行为
- Doo::loadModel("action_log");
- $action_log=new action_log();
- $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'].')';
- $action_log->sid=$this->staff[0]['sid'];
- $action_log->cid=$this->staff[0]['cid'];
- $action_log->updatetime=date("Y-m-d");
- $action_log->time=date("H:i");
- $action_log->class=$action_log->iconContacts;
- $action_log->status=2;
- $action_log->districtid=$clientInfo['district'];
- $local=$district->getbyidlist($clientInfo['district']);
- $action_log->city=$local[0]['name'];
- $action_log->province=$local[1]['name'];
- $action_log->company=$clientInfo['companyname'];
- Doo::loadModel('company');
- $company=new company();
- $companyInfo=$company->getOne(array('where'=>' companyname="'.$clientInfo['companyname'].'"','asArray'=>true));
- $nature=explode(',', $companyInfo['nature']);
- $action_log->nature=$nature[0];
- $action_log->insert();
- echo json_encode(array("success"=>true));die;
- }else
- echo json_encode(array("success"=>false));die;
- }
- function ajaxClientInfo(){
- $cid=isset($_POST['cid'])?$_POST['cid']:0;
- if(!empty($cid)){
- Doo::loadModel ( 'client' );
- Doo::loadModel('company');
- Doo::loadModel('district');
- $district = new district();
- $company = new company();
- $client = new client();
- $info=$client->getOne(array('where'=>' cid='.$cid,'asArray'=>true));
- $cinfo=$company->getOne(array('where'=>' cid='.$info['companyid'],'asArray'=>true));
- $districtLv1=$district->get_lv(1);
- $info['districtList']=$district->getbyidlist($info['district']);
- $optionHtml='<option vlaue="0">请选择</option>';
- foreach ($districtLv1 as $key=>$value){
- if($value['name']==$info['districtList'][0]['name'])
- $optionHtml.='<option selected value="'.$value['id'].'">'.$value['name'].'</option>';
- else
- $optionHtml.='<option value="'.$value['id'].'">'.$value['name'].'</option>';
- }
- $info['districtLv1']=$optionHtml;
- $info['companyInfo']=$cinfo;
- echo json_encode(array("success"=>true,'html'=>$info));die;
- }else
- echo json_encode(array("success"=>false,'html'=>''));die;
- }
- function ajaxAddServiceLog(){
- $status=isset($_POST['status'])?$_POST['status']:"";
- $clientid=isset($_POST['cid'])?$_POST['cid']:"";
- $mark=isset($_POST['mark'])?$_POST['mark']:"";
- $m=isset($_POST['m'])?$_POST['m']:"";
- $d=isset($_POST['d'])?$_POST['d']:"";
- $y=isset($_POST['y'])?$_POST['y']:date("Y");
-
- $Remind=isset($_POST['Remind'])?$_POST['Remind']:0;
- $time=isset($_POST['time'])?$_POST['time']:0;
- $remark=isset($_POST['remark'])?$_POST['remark']:"";
-
- if(!empty($status)&&!empty($clientid)){
- Doo::loadModel ( 'service_log' );
- Doo::loadModel ( 'client_staff' );
- Doo::loadModel ( 'client' );
- Doo::loadModel('district');
- $district=new district();
- $client = new client();
- $clientStaff=new client_staff();
- $service_log = new service_log();
- $service_log->status=$status;
- $service_log->clientid=$clientid;
- $service_log->mark=htmlspecialchars($mark);
- $service_log->date=$y."-".$m."-".$d;
- $service_log->category=$this->staff[0]['category'];
- $service_log->staffname=$this->staff[0]['username'];
- $service_log->staffid=$this->staff[0]['sid'];
- $service_log->insert();
- //日常行为
- Doo::loadModel("action_log");
- Doo::loadModel("client");
- $client=new client();
- //记录服务时间
- $client->cid=$clientid;
- $client->servicetime=time();
- $client->update();
- $action_log=new action_log();
- $clientInfo=$client->getOne(array('where'=>' cid='.$clientid,'asArray' => TRUE));
- $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'].')添加新客户记录。';
- $action_log->sid=$this->staff[0]['sid'];
- $action_log->cid=$this->staff[0]['cid'];
- $action_log->updatetime=date("Y-m-d");
- $action_log->time=date("H:i");
- $action_log->status=3;
- $action_log->districtid=$clientInfo['district'];
- $local=$district->getbyidlist($clientInfo['district']);
- $action_log->city=$local[0]['name'];
- $action_log->province=$local[1]['name'];
- $action_log->company=$clientInfo['companyname'];
- Doo::loadModel('company');
- $company=new company();
- $companyInfo=$company->getOne(array('where'=>' companyname="'.$clientInfo['companyname'].'"','asArray'=>true));
- $nature=explode(',', $companyInfo['nature']);
- $action_log->nature=$nature[0];
- $action_log->class=$action_log->iconContacts;
- $action_log->insert();
-
- if (!empty($Remind)){
- Doo::loadModel('remind');
- $remindObj=new remind();
-
- $datetime1 = new DateTime(date('Y-m-d'));
- $datetime2 = new DateTime($time);
- $interval = $datetime1->diff($datetime2);
-
- $remindObj->day=$interval->format('%a');
- $remindObj->remark=$remark;
- $remindObj->time=date("Y-m-d");
- $remindObj->clientName=$clientInfo['clientname'];
- $remindObj->clientID=$clientid;
- $remindObj->companyName=$clientInfo['companyname'];
- $remindObj->companyID=$companyInfo['cid'];
- $remindObj->staffID=$this->staff[0]['sid'];
- if ($status==1)
- $remindObj->class="iconService";
- if ($status==2)
- $remindObj->class="iconPhone";
- if ($status==3)
- $remindObj->class="iconOther";
- $remindObj->insert();
- }
-
- echo json_encode(array("success"=>true,'html'=>''));die;
- }else
- echo json_encode(array("success"=>false,'html'=>''));die;
- }
- function _getLongleLogHtml($longleLog=array()){
- $html="";
- foreach ($longleLog as $key=>$value){
- $dateline=explode("-", $value['dateline']);
- $html.='<div class="infoFlowList">
- <div class="dateTitle">
- <em class="month"><span class="num">'.$dateline[1].'</span><span class="text">-'.$dateline[2].'</span></em>
- <span class="year">'.$dateline[0].'</span>
- </div>
- ';
- //备注
- if($value['status']==8){
- $html.='
- <ul class="flowList">
- <li class="item iconLock">备注<'.$value['category'].'<a href="javascript:void(0);" onclick="getStaffInfo(\''.$value['operator'].'\')" >'.$value['operator'].'</a></li>
- <li class="item">'.$value['mark'].'</li>
- </ul>';
- //生成
- }elseif($value['status']==1){
- $html.='<ul class="flowList">
- <li class="item iconGenerate">生成<'.$value['category'].'<a href="javascript:void(0);" onclick="getStaffInfo(\''.$value['operator'].'\')" >'.$value['operator'].'</a></li>
- </ul>';
- //接收
- }elseif($value['status']==2){
- $html.='<ul class="flowList">
- <li class="item iconReceive">接收<'.$value['category'].'<a href="javascript:void(0);" onclick="getStaffInfo(\''.$value['operator'].'\')" >'.$value['operator'].'</a></li>
- </ul>';
- //借出
- }elseif($value['status']==3){
- $html.='<ul class="flowList">
- <li class="item iconBorrow">借出<'.$value['category'].'<a href="javascript:void(0);" onclick="getStaffInfo(\''.$value['operator'].'\')" >'.$value['operator'].'</a></li>
- <li class="item">'.$value['product'].'</li>
- <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\''.$value['clientid'].",".$value['client'].'\')" >'.$value['client'].'</a></li>
- </ul>';
- //销售
- }elseif($value['status']==4){
- $html.='<ul class="flowList">
- <li class="item iconSell">销售<'.$value['category'].'<a href="javascript:void(0);" onclick="getStaffInfo(\''.$value['operator'].'\')" >'.$value['operator'].'</a></li>
- <li class="item">'.$value['product'].'</li>
- <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\''.$value['clientid'].",".$value['client'].'\')" >'.$value['client'].'</a></li>
- </ul>';
- //升级
- }elseif($value['status']==5){
- $html.='<ul class="flowList">
- <li class="item iconUpdate">升级<'.$value['category'].'<a href="javascript:void(0);" onclick="getStaffInfo(\''.$value['operator'].'\')" >'.$value['operator'].'</a></li>
- <li class="item">'.$value['product'].'</li>
- <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\''.$value['clientid'].",".$value['client'].'\')" >'.$value['client'].'</a></li>
- </ul>';
- //更换
- }elseif($value['status']==6){
- $html.='<ul class="flowList">
- <li class="item iconReplace">更换<'.$value['category'].'<a href="javascript:void(0);" onclick="getStaffInfo(\''.$value['operator'].'\')">'.$value['operator'].'</a></li>
- <li class="item"><a href="javascript:void(0);" onclick="getLockByName(\''.$value['new_key_num'].'\')">'.$value['new_key_num'].'</a>
- <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\''.$value['clientid'].",".$value['client'].'\')" >'.$value['client'].'</a></li>
- </ul>';
- //回收
- }elseif($value['status']==7){
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- $staffinfo=$staff->getOne(array('where'=>' username like "'.$value['responsible'].'"','asArray'=>true));
- if (empty($staffinfo))
- $staffinfo['category']="";
- $html.='<ul class="flowList">
- <li class="item iconRecycle">收回<'.$value['category'].'<a href="javascript:void(0);" onclick="getStaffInfo(\''.$value['operator'].'\')">'.$value['operator'].'</a></li>
- <li class="item">'.$staffinfo['category'].'<a href="javascript:void(0);" id="ajaxStaff" data="'.$value['responsible'].'">'.$value['responsible'].'</a></li>
- </ul>';
- }elseif($value['status']==9){
- $html.='<ul class="flowList">
- <li class="item iconGif">赠送 < '.$value['category'].'<a href="javascript:void(0);" onclick="getStaffInfo(\''.$value['operator'].'\')">'.$value['operator'].'</a></li>
- <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\''.$value['clientid'].",".$value['client'].'\')" >'.$value['client'].'</a></li>
- </ul>';
- }
- $html.='</div>';
- }
- return $html;
- }
- function adminLock(){
- $emsg=isset($this->params['emsg'])?$this->params['emsg']:"";
- $data['emsg']="";
- if($emsg!="")
- $data['emsg']="请填写完整的数据";
- $data['memu']="keyonline";
- $data['staff']=$this->staff;
- if($this->staff[0]['isadmin']!=1)
- return "/adminmyinfo";
- Doo::loadModel ( 'L_category' );
- $L_category = new L_category ();
- $data['category']=$L_category->getCategory();
- $data['time']=time();
- $this->render ( "/admin/admin_addlock", $data );
- }
- function adminAddLock(){
- $cid=isset($_POST['cid'])?$_POST['cid']:0;
- $path=isset($_POST['path'])?$_POST['path']:"";
- if($cid!=0&&$path!=""){
- Doo::loadModel ( 'longle' );
- Doo::loadModel ( 'L_category' );
- $L_category = new L_category ();
- Doo::loadModel ( 'longle_log' );
- $exlArray=$this->_format_excel_to_array(DOO::conf()->SITE_PATH."upload/".iconv("UTF-8", "GB2312", $path));
- //print_r($exlArray);die;
- //echo json_encode($exlArray);die;
- $category=$L_category->getCategoryById($cid);
- foreach ($exlArray as $key=>$value){
- //锁记录
- $longle = new longle ();
- $longle->key_num=str_replace("'","",$value['key_num']);
- $longle->product=str_replace("'","",$value['product']);
- $longle->make_day=$value['make_day'];
- $longle->alloted_time=$value['alloted_time'];
- $longle->status=1;
- $longle->statusT="生成";
- $longle->cid=$cid;
- $longle->category=$category[0]['title'];
- $longle->SerialNumber=$value['SerialNumber'];
- $longle->version=$value['version'];
- $lid=$longle->insert();
- //锁日志记录
- $longle_log=new longle_log();
- $longle_log->lid=$lid;
- $longle_log->status=1;
- $longle_log->statusT="生成";
- $longle_log->operator=$this->staff[0]['username'];
- $longle_log->product=$longle->product;
- $longle_log->category=$this->staff[0]['category'];
- $longle_log->dateline=date("Y-m-d");
- $id=$longle_log->insert();
- }
- //记录日常行为
- Doo::loadModel("action_log");
- $action_log=new action_log();
- $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>个锁';
- $action_log->sid=$this->staff[0]['sid'];
- $action_log->cid=$this->staff[0]['cid'];
- $action_log->class=$action_log->iconGenerate;
- $action_log->updatetime=date("Y-m-d");
- $action_log->time=date("H:i");
- $action_log->status=11;
- $action_log->insert();
- return "/keyonline";
- }else
- return "/adminlock/error";
- }
- function avatarCM(){
- $vid=isset($this->params['vid'])?$this->params['vid']:0;
- if(!empty($vid)){
- Doo::loadModel("verify");
- $verify=new verify();
- Doo::loadModel('staff');
- $staff=new staff();
- $list=$verify->getOne(array('where'=>'vid='.$vid,'asArray'=>true));
- if (empty($list))
- return "/adminverify";
- $avatar=json_decode($list['staff']);
- foreach ($avatar as $key=>$value){
- $uinfo=$staff->getOne(array('where'=>'sid='.$value[0],'asArray'=>true));
- $avatar[$key]['2']=$uinfo['avatar'];
- }
- $verify->staff=json_encode($avatar);
- $verify->update(array('where'=>'vid='.$vid));
- }
- return "/adminverify";
- }
- function adminmyinfo(){
- $data['memu']="adminmyinfo";
- $data['staff']=$this->staff;
- $birArray=explode('-', $this->staff[0]['birthday']);
- $data['year']=$birArray[0];
- $year=date('Y');$yearHtml="";
- for (;$year>=1900;$year--){
- $yearHtml.='<option ';
- if ($data['year']==$year)
- $yearHtml.='selected';
- $yearHtml.=' value="'.$year.'">'.$year.'</option>';
- }
- $data['yearHtml']=$yearHtml;
- $data['month']=01;
- $data['day']=01;
- if(isset($birArray[1])){
- $data['month']=$birArray[1];
- $data['day']=$birArray[2];
- }
- $data['msg']=urldecode($this->params['msg']);
- $this->render ( "/admin/admin_myinfo", $data );
- }
- function updateMyinfo(){
- $telephone=$this->get_args('telephone')?$_POST['telephone']:0;
- $phone=$this->get_args('phone')?$_POST['phone']:0;
- $email=isset($_POST['email'])?$_POST['email']:"";
- $qq=is_numeric($this->get_args('qq'))?$_POST['qq']:0;
- $year=$this->get_args('year')?$_POST['year']:date("Y");
- $month=$this->get_args('month')?$_POST['month']:"";
- $day=$this->get_args('day')?$_POST['day']:"";
- $position=$this->get_args('position')?$_POST['position']:"";
- $gender=$this->get_args('gender')?$_POST['gender']:"男";
-
- $oldpassword=$this->get_args('oldpassword')?$_POST['oldpassword']:"";
- $newpassword=$this->get_args('newpassword')?$_POST['newpassword']:"";
- $rnewpassword=$this->get_args('rnewpassword')?$_POST['rnewpassword']:"";
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadModel ( 'staffDynamic' );
- $staffDynamic=new staffDynamic();
- $staff->sid=$this->staff[0]['sid'];
- $content="";$ext="更新了他的";
- if($telephone!=0&&$this->staff[0]['telephone']!=$telephone){
- $staff->telephone=$telephone;
- $content.="<b>手机</b> ";
- }
- if($phone!=0&&$this->staff[0]['phone']!=$phone){
- $staff->phone=$phone;
- $content.="<b>电话</b> ";
- }
- if($qq!=0&&$this->staff[0]['qq']!=$qq){
- $staff->qq=$qq;
- $content.="<b>QQ</b> ";
- }
- if($year!=2014){
- $staff->birthday=$year."-".$month."-".$day;
- $content.="<b>生日</b> ";
- }
- if($email!=""&&filter_var($email, FILTER_VALIDATE_EMAIL)&&$this->staff[0]['email']!=$email){
- $staff->email=$email;
- $content.="<b>邮箱</b> ";
- }
- if (!empty($position)){
- $staff->position=$position;
- $content.="<b>职位</b> ";
- }
- $staff->gender=$gender;
- $msg="更新成功";
- if($this->staff[0]['passwork']==md5($oldpassword)){
- if($newpassword==$rnewpassword&&(!empty($newpassword)))
- $staff->passwork=md5($newpassword);
- else
- $msg="密码不一致";
- }else{
- if($oldpassword!="")
- $msg="密码错误";
- }
- if (!empty($content)){
- $staffDynamic->content=$ext.$content;
- $staffDynamic->cid=$this->staff[0]['cid'];
- $staffDynamic->category=$this->staff[0]['category'];
- $staffDynamic->time=time();
- $staffDynamic->sid=$this->staff[0]['sid'];
- $staffDynamic->staff=$this->staff[0]['username'];
- $staffDynamic->insert();
- }
- $staff->update(array('where'=>' sid='.$this->staff[0]['sid']));
- return "/adminmyinfo/".$msg;
- }
-
-
-
-
-
-
-
-
-
-
- function admincontacts(){
- $data['memu']="admincontacts";
- $data['staff']=$this->staff;
- Doo::loadModel ( 'L_category' );
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- $L_category = new L_category ();
- $this->render ( "/admin/admin_addContacts", $data );
- }
- function eMailTask(){
- Doo::loadModel('tag');
- $tag=new tag();
- Doo::loadModel('district');
- $district= new district();
- $tagList=$tag->getAllBySid($this->staff[0]['sid']);
- $districtList=$district->get_lv(1);
- $data['tagList']=$tagList;
- $data['districtList']=$districtList;
- $data['memu']="eMailTask";
- $data['staff']=$this->staff;
- $data['mailMemu']='eMailTask';
- $data['nature']=$this->nature;
-
- $this->render ( "/mail_create", $data );
- }
- function eMialCenter(){
- $year=$this->get_args('year')?$this->get_args('year'):date("Y");
- $month=$this->get_args('month')?$this->get_args('month'):0;
-
- Doo::loadModel('eMailList');
- $eMailList=new eMailList();
- Doo::loadModel('tag');
- $tag=new tag();
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- $dateCondition="status!=2 and Year(date) =".$year;
- if(!empty($month))
- $dateCondition="Year(date) =".$year." and Month(date) = ".$month;
- $mailList=$eMailList->find(array('where'=>$dateCondition,'asc'=>'status','desc'=>'elid','asArray'=>true));
-
- foreach ($mailList as $key=>$value){
-
- $mailList[$key]['clientName2']=$mailList[$key]['clientName3']=array();
- $mailList[$key]['clientName']=json_decode(gzuncompress(base64_decode($value['clientName'])),true);
- if(!empty($value['clientName2']))
- $mailList[$key]['clientName2']=json_decode(gzuncompress(base64_decode($value['clientName2'])),true);
- if(!empty($value['clientName3']))
- $mailList[$key]['clientName3']=json_decode(gzuncompress(base64_decode($value['clientName3'])),true);
-
-
- $mailList[$key]['illegalEmail']=json_decode($value['illegalEmail'],true);
- $mailList[$key]['sendEmail']=json_decode($value['sendEmail'],true);
- $mailList[$key]['clientCount']=count($mailList[$key]['clientName'])+count($mailList[$key]['clientName2'])+count($mailList[$key]['clientName3']);
- $mailList[$key]['tag']=array();
- $kks=$staff->getOne(array('where'=>'username like "'.$value['staffName'].'"','asArray'=>true));
- $mailList[$key]['category']=$kks['category'];
- if (!empty($value['tag']))
- $mailList[$key]['tag']=$tag->find(array('where'=>'tid in ( '.$value['tag'].') ','asArray'=>true));
- }
-
- $dateHtml="";$now=date("Y");
- for ($YEARD=2014;$YEARD<=2050;$YEARD++){
- if ($YEARD<=$now){
- $dateHtml.='<option ';
- if ($year==$YEARD )
- $dateHtml.=' selected ';
- $dateHtml.=' value="'.$YEARD.'">'.$YEARD.'</option>';
- }
- }
- $monthHtml='<option value="0">所有月份</option>';
- for ($i=1;$i<=12;$i++){
- $monthHtml.='<option ';
- if ($i==$month )
- $monthHtml.=' selected ';
- $monthHtml.=' value="'.$i.'">'.$i.'</option>';
- }
-
- $data['monthHtml']=$monthHtml;
- $data['dateHtml']=$dateHtml;
- $data['mailList']=$mailList;
- $data['memu']="eMailTask";
- $data['staff']=$this->staff;
-
- $data['mailMemu']='eMialCenter';
- $data['nature']=$this->nature;
-
- $this->render ( "/mailCenter", $data );
- }
-
- function authMail(){
- $elid=isset($this->params['elid'])?$this->params['elid']:0;
- if (!empty($elid)){
- Doo::loadModel('eMailList');
- $eMailList=new eMailList();
-
- $eMailList->examine=2;
-
- $eMailList->mark=$this->staff[0]['username']."已同意";
- $eMailList->update(array('where'=>'elid='.$elid,'asArray'=>true));
- }
- return '/eMialCenter';
- }
-
- function editMailView(){
- $elid=isset($this->params['elid'])?$this->params['elid']:0;
-
- Doo::loadModel('tag');
- $tag=new tag();
- Doo::loadModel('district');
- $district= new district();
- Doo::loadModel('eMailList');
- $eMList=new eMailList();
-
- $mail=$eMList->getOne(array('where'=>'elid ='.$elid.'','asArray'=>true));
-
- if(empty($mail))
- return "/eMailList";
- $mail['tagList']=explode(",", $mail['tag']);
- $tagList=$tag->getAllBySid($this->staff[0]['sid']);
- $districtList=$district->get_lv(1);
- $tagHtml='';
- foreach ($tagList as $key=>$value){
- $tagHtml.='<label><span data-original-title="'.$value['name'].'" data-toggle="ctooltip" data-placement="right" class="contactsTag tagCol-0'.$value['colorid'].'">
- <input type="checkbox" name="tagId[]"';
- foreach ($mail['tagList'] as $k=>$v){
- if ($value['tid']==$v){
- $tagHtml.=' checked ';break;
- }
- }
- $tagHtml.=' value="'.$value['tid'].'"></span></label>';
- }
-
- $districtHtml='';
- foreach ($districtList as $key=>$value){
- $districtHtml.='<option value="'.$value['id'].'"';
- if($value['id']==$mail['districtId'])
- $districtHtml.='selected';
-
- $districtHtml.='>'.$value['name'].'</option>';
- }
-
- $natureHtml='';
- $natList=explode(",", $mail['nature']);
- foreach ($this->nature as $key=>$value){
-
- $natureHtml.='<label><input type="checkbox" name="nature[]" ';
- foreach ($natList as $k=>$v){
- if ($value==$v){
- $natureHtml.=' checked ';break;
- }
- }
- $natureHtml.='value="'.$value.'">'.$value.'</label>';
- }
-
- $data['natureHtml']=$natureHtml;
- $data['districtHtml']=$districtHtml;
- $data['tagHtml']=$tagHtml;
- $data['mail']=$mail;
- $data['tagList']=$tagList;
- $data['districtList']=$districtList;
- $data['memu']="eMailTask";
- $data['staff']=$this->staff;
- $data['mailMemu']='eMailList';
- $data['nature']=$this->nature;
-
- $this->render ( "/mailEdit", $data );
- }
-
- function editEmail(){
- $title=$this->get_args('title')?$this->get_args('title'):"";
- $skin=$this->get_args('skin')?$this->get_args('skin'):"";
- $content=isset($_POST['content'])?$_POST['content']:"";
- $tagId=$this->get_args('tagId')?$this->get_args('tagId'):array();
- $nature=$this->get_args('nature')?$this->get_args('nature'):array();
- $natureNULL=$this->get_args('natureNULL')?$this->get_args('natureNULL'):"";
-
- $did=$this->get_args('did')?$this->get_args('did'):"";
- $stype=$this->get_args('stype')?$this->get_args('stype'):"";
- $elid=$this->get_args('elid')?$this->get_args('elid'):"";
-
- if (!empty($title)&&!empty($elid)&&(!empty($tagId)||!empty($did))){
-
- Doo::loadModel('eMailList');
- $eMailList=new eMailList();
- $etid=$eMailList->getOne(array('select'=>'etid,annexName,annex','where'=>'elid='.$elid,'asArray'=>true));
-
- Doo::loadModel('eMailTemplate');
- $eMailTemplate=new eMailTemplate();
- Doo::loadModel('eMailJournal');
- $eMailJournal=new eMailJournal();
-
- if ($natureNULL!='NULL'){
- if (empty($tagId)&&!empty($did)&&empty($nature))
- die('请选择性质');
- }
- //annex
- $annexPath="";$annexEXT=$this->_GetFileEXT($_FILES["annex"]["name"]);$annexName="";
- if ( isset($_FILES['annex']['name']) ){
- if ((($annexEXT == "doc")|| ($annexEXT == "xls")|| ($annexEXT == "pdf")|| ($annexEXT == "ppt")|| ($annexEXT == "txt")|| ($annexEXT == "smr")
- || ($annexEXT == "spu")|| ($annexEXT == "zip")|| ($annexEXT == "rar")|| ($annexEXT == "jpg")|| ($annexEXT == "png")
- )&& ($_FILES["annex"]["size"] < 10485760)){
- $path=DOO::conf()->SITE_PATH."upload/emailAnnex/";
- if (!file_exists( $path. $_FILES["annex"]["name"])){
- $fileName=time().".".$annexEXT;
- $annexName=$_FILES['annex']['name'];
- $annexPath=$path.$fileName ;
- move_uploaded_file($_FILES["annex"]["tmp_name"],$annexPath);
- $annexPath=$this->webPath.$fileName;
- }
- }
- }
- if (!empty($annexPath)){
- $annexHtml='<table style="width:100%;margin:10px 0">
- <thead>
- <tr>
- <th align="left" colspan="2" style="background-color:ff6501;color:#fff;font-size:16px;padding:5px">下载附件:</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td style="padding:5px"><a href="'.$annexPath.'" target="_blank" style="font-size:16px">'.$annexName.'</a></td>
- <td> </td>
- </tr>
- </tbody>
- </table>';
- }elseif (!empty($etid['annexName'])&&empty($annexPath))
- $annexHtml=$etid['annex'];
- $smartcostMail='smartcost_mail_1';
- $info="";
- //html template
- if($skin==1){
- $html='<div><table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
- <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">
- <tbody><tr>
- <td style="background-color:#ff6501;padding:20px 0 25px;" align="center">
- <span style="vertical-align:bottom;font-size:20px;color:#fff;">'.$title.'</span>
- </td></tr><tr><td>
- <table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;border-top:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
- <tbody><tr><td style="padding: 0 40px;" align="left">
- <p style="margin-top:40px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
- </td></tr><tr><td style="padding: 0 40px;" align="left">
- <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>'.$this->staff[0]['username'].'</b>:</p>
- <p style="margin-top:0px;margin-bottom:20px;color:#383838;font-size:16px;line-height:32px;">
- '.$content.'</p>
- </td></tr>
- <tr><td align="left" style="padding: 0 40px;background:#fff">
- '.$annexHtml.'
- </td></tr>
- <tr> <td style="padding: 20px 40px;border-top:1px dashed #ddd" align="left">
- <p style="margin-bottom:10px;color:#383838;font-size:16px;line-height:22px;border-left:2px solid #FF6501;padding-left:5px">
- 纵横公路造价软件'.$this->staff[0]['category'].'办事处</p>
- <table>
- <tr><th align="right">电话:</th><td>'.$this->staff[0]['phone'].'</td></tr>
- <tr><th align="right">联系人:</th><td>'.$this->staff[0]['username'].'</td></tr>
- <tr><th align="right">手机:</th><td>'.$this->staff[0]['telephone'].'</td></tr>
- <tr><th align="right">QQ:</th><td>'.$this->staff[0]['qq'].'</td></tr>
- <tr><th align="right">邮箱:</th><td>'.$this->staff[0]['email'].'</td></tr>
- </table></td></tr></tbody></table></td></tr><tr>
- <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>
- </tr></tbody></table></td></tr></tbody></table></div>';
- $info='<table><tr><th align="right">电话:</th><td>'.$this->staff[0]['phone'].'</td></tr>
- <tr><th align="right">联系人:</th><td>'.$this->staff[0]['username'].'</td></tr>
- <tr><th align="right">手机:</th><td>'.$this->staff[0]['telephone'].'</td></tr>
- <tr><th align="right">QQ:</th><td>'.$this->staff[0]['qq'].'</td></tr>
- <tr><th align="right">邮箱:</th><td>'.$this->staff[0]['email'].'</td></tr></table>';
- }elseif ($skin==2){
- $smartcostMail='smartcost_mail_2';
- $html='<table cellspacing="0" cellpadding="0" style="background-color:#e4e4e4; width:100%;"><tbody><tr><td>
- <table align="center" cellspacing="0" cellpadding="0" style="background-color:#f8f8f8; width:640px;margin-bottom:20px">
- <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;">
- <b><span name="titleHtml">'.$title.'</span></b></p></td>
- </tr><tr><td><table align="center" cellspacing="0" cellpadding="0" style="border:1px solid #ddd;"><tbody><tr>
- <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>
- </tr><tr><td align="center" style="background-color:#fff;"><img width="640" height="191" src="http://zonghengvideo.qiniudn.com/hero.jpg"></td>
- </tr><tr><td align="left" style="background-color:#fff;padding:40px;border-bottom:1px solid #ddd;">
- <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
- <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>'.$this->staff[0]['username'].'</b>:</p>
- <p name="contentHtml" style="margin-top:0px;margin-bottom:15px;color:#383838;font-size:16px;line-height:32px;">'.$content.'</p></td>
- </tr>
- <tr><td align="left" style="padding: 0 40px;background:#fff">
- '.$annexHtml.'
- </td></tr>
- <tr><td style="padding: 10px 0;background:#EEF2F5"><table><tbody><tr>
- <td style="font-size:14pxl;color:#333;padding:0 20px"><b>纵横公路造价软件'.$this->staff[0]['category'].'办事处</b><br>'.$this->staff[0]['username'].'</td>
- <td><table><tbody><tr style="font-size:12px;color:#666">
- <th align="right">电话:</th><td style="padding:0 20px 0 0">'.$this->staff[0]['phone'].'</td>
- <th align="right">手机:</th><td>'.$this->staff[0]['telephone'].'</td></tr><tr style="font-size:12px;color:#666">
- <th align="right">QQ:</th><td>'.$this->staff[0]['qq'].'</td>
- <th align="right">邮箱: </th><td>'.$this->staff[0]['email'].'</td>
- </tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr>
- <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>
- </tr></tbody></table></td></tr></tbody> </table>';
- $info='<table><tbody><tr style="font-size:12px;color:#666">
- <th align="right">电话:</th><td style="padding:0 20px 0 0">'.$this->staff[0]['phone'].'</td>
- <th align="right">手机:</th><td>'.$this->staff[0]['telephone'].'</td></tr><tr style="font-size:12px;color:#666">
- <th align="right">QQ:</th><td>'.$this->staff[0]['qq'].'</td>
- <th align="right">邮箱: </th><td>'.$this->staff[0]['email'].'</td>
- </tr></tbody></table>';
- }else{
- $smartcostMail='smartcost_mail_3';
- $html='<table cellspacing="0" cellpadding="0" style="background-color:#ECF0E1; width:100%">
- <tbody>
- <tr>
- <td>
- <table align="center" cellspacing="0" cellpadding="0" style="width:698px;margin-bottom:30px;margin-top:30px;">
- <tbody>
- <tr>
- <td>
- <table align="center" cellspacing="0" cellpadding="0" style="border:1px solid #ccc;width:100%;border-top:none">
- <tbody>
- <tr>
- <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;">
- <div style="position:relative;text-align:right">
- <b style="font-size:24px;color:#8A9F98;z-index:999"><span name="titleHtml">'.$title.'</span></b>
- <div style="width:80px;height:80px;position:absolute;top:0;left:0"><img src="http://zonghengvideo.qiniudn.com/zonghenglogo.png"></div>
- </div>
- </td>
- </tr>
- <tr>
- <td align="left" style="background-color:#fff;padding:40px;border-bottom:1px solid #ddd;">
- <p style="margin-top:0px;margin-bottom:10px;color:#666;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
- <p style="margin-top:0px;margin-bottom:10px;color:#666;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>'.$this->staff[0]['username'].'</b>:</p>
- <p name="contentHtml" style="margin-top:0px;margin-bottom:15px;color:#666;font-size:16px;line-height:32px;">'.$content.'</p></td>
- </tr>
- <tr><td align="left" style="padding: 0 40px;background:#fff">
- '.$annexHtml.'
- </td></tr>
- <tr>
- <td style="padding: 10px 0 0;background:#F6F6F6;">
- <table>
- <tbody><tr>
- <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>
- <td>
- <table style="width:100%">
- <tbody><tr style="font-size:12px;color:#496781">
- <th align="right">电话:</th><td>'.$this->staff[0]['phone'].'</td>
- <th align="right">手机:</th><td>'.$this->staff[0]['telephone'].'</td>
- </tr>
- <tr style="font-size:12px;color:#496781">
- <th align="right">QQ:</th><td>'.$this->staff[0]['qq'].'</td>
- <th align="right">邮箱: </th><td>'.$this->staff[0]['email'].'</td>
- </tr>
- </tbody></table>
- </td>
- </tr>
- </tbody></table>
- </td>
- </tr>
- <tr>
- <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>
- </tr>
- </tbody>
- </table></td>
- </tr>
- </tbody>
- </table></td>
- </tr>
- </tbody>
- </table>';
- $info='<table><tr style="font-size:12px;color:#496781"><th align="right">电话:</th><td>'.$this->staff[0]['phone'].'</td>
- <th align="right">手机:</th><td>'.$this->staff[0]['telephone'].'</td></tr><tr style="font-size:12px;color:#496781">
- <th align="right">QQ:</th><td>'.$this->staff[0]['qq'].'</td>
- <th align="right">邮箱: </th><td>'.$this->staff[0]['email'].'</td></tr></table>
- ';
- }
-
- Doo::loadModel('tag_client');
- $tagClient=new tag_client();
- Doo::loadModel('client');
- $client=new client();
-
- Doo::loadModel('company');
- $company=new company();
-
-
-
- $eMailTemplate->title=$title;
- $eMailTemplate->skin=$skin;
- $eMailTemplate->content=$content;
- if (!empty($tagId))
- $eMailTemplate->tag=implode(",", $tagId);
- $eMailTemplate->staffId=$this->staff[0]['sid'];
- $eMailTemplate->staffName=$this->staff[0]['username'];
- $eMailTemplate->status=0;
- $eMailTemplate->html=$html;
- if (!empty($annexPath)){
- $eMailTemplate->annex=$annexPath;
- $eMailTemplate->annexName=$annexName;
- }
- $etid=$eMailTemplate->update(array('where'=>'etid='.$etid['etid']));
- //create email list
-
-
- $tagCondition="";$tagArray=array();
- foreach ($tagId as $value){
- array_push($tagArray, " tag like '%".$value."%' ");
- }
- if(!empty($tagArray))
- $tagCondition=' and ('.implode(" or ", $tagArray).')';
- $clientList=$tagClient->find(array('select'=>'client','where'=>'sid='.$this->staff[0]['sid'].$tagCondition,'asArray'=>true));
- $clientArray=array();
- foreach ($clientList as $value){
- array_push($clientArray, $value['client']);
- }
- $clientEmailList=array();
- if (!empty($clientArray))
- $clientEmailList=$client->find(array('select'=>'email,cid,nicename as clientname,companyname','where'=>'cid in ('.implode(",", $clientArray).')','asArray'=>true));
- //
- if ($stype==2){
- //获取性质相关数据
- $cidList='';
- if ($natureNULL==''){
- $nD=array();
- foreach ($nature as $key=>$value){
- array_push($nD, ' nature like "'.$value.'"');
- //$nD=' nature like "'.$value.'"';
- }
- $nD=implode(' or ', $nD);
-
- $companycid=$company->find(array('select'=>'cid','where'=>$nD,'asArray'=>true));
- $cidList=array();
- foreach ($companycid as $key=>$value){
- array_push($cidList, $value['cid']);
- }
- $cidList=implode(',', $cidList);
- if (!empty($cidList))
- $cidList=' and companyid in ('.$cidList.')';
- else
- $cidList='';
- }
- //'select'=>'email,cid,nicename as clientname,companyname,district'
- $clientEmailList=$client->find(array('select'=>'email,cid,nicename as clientname,companyname,district','where'=>'district like "'.$did.',%" '.$cidList,'asArray'=>true));
- }
-
- //;datediff(curdate(), 'date')>=10
- $eMailJournal->delete(array('where'=>"datediff(curdate(), date)>=7"));
- $eMailJournal->delete(array('where'=>'DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(date)'));
-
- $checkMail=$eMailJournal->find(array('where'=>'DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(date)',' groupby'=>'email','asArray'=>true));
- $emailNameList=$emailArray=$illegalEmail=$sendEmail=array();
- Doo::db()->beginTransaction();
- foreach ($clientEmailList as $value){
- if(filter_var($value['email'], FILTER_VALIDATE_EMAIL)){
- if(!empty($checkMail)){
- $falg=true;
- foreach ($checkMail as $v){
- if($v['email']==$value['email']){
- $Bdate=strtotime($v['date'])+7*24*3600;
- if($Bdate<=time()){
- array_push($emailArray, $value['email']);
- array_push($emailNameList, $value);
- $eMailJournal->date=date("Y-m-d");
- $eMailJournal->update(array('where'=>'ejid='.$v['ejid']));
- }else{
- array_push($sendEmail, $value);
- }
- $falg=false;
- break;
- }
- }
- if ($falg){
- array_push($emailArray, $value['email']);
- array_push($emailNameList, $value);
- $eMailJournal->clientId=$value['cid'];
- $eMailJournal->status=1;
- $eMailJournal->email=$value['email'];
- $eMailJournal->date=date("Y-m-d");
- $eMailJournal->insert();
- }
- }else{
- array_push($emailArray, $value['email']);
- array_push($emailNameList, $value);
- $eMailJournal->clientId=$value['cid'];
- $eMailJournal->status=1;
- $eMailJournal->email=$value['email'];
- $eMailJournal->date=date("Y-m-d");
- $eMailJournal->insert();
- }
- }else{
- array_push($illegalEmail, $value);
- }
- }
- Doo::db()->commit();
- //echo json_encode($illegalEmail);
- //json_encode(array_slice($illegalEmail,0,100))
- // $kk=gzcompress();
- // $ll=gzuncompress($kk);
- //."</br>".strlen($kk)."</br>".strlen($ll);die;
-
- $size=floor(count($emailArray)/3);
-
- if (!empty($emailArray)){
- if(count($emailArray)<3){
- $list=array(0=>$emailArray,1=>array(),2=>array());
- }else
- $list=array_chunk($emailArray,$size);
-
- }else
- $list=array(0=>array(),1=>array(),2=>array());
- $emailJson=array();
- foreach ($list as $value){
- $em=array();
- foreach ($value as $v){
- array_push($em, $v);
- }
- array_push($emailJson, $em);
- }
-
- $size=floor(count($emailNameList)/3);
-
- if (!empty($emailNameList)){
- if(count($emailNameList)<3){
- $list=array(0=>$emailNameList,1=>array(),2=>array());
- }else
- $list=array_chunk($emailNameList,$size);
- }else
- $list=array(0=>array(),1=>array(),2=>array());
- $emailNameJson=array();
- foreach ($list as $value){
- $em=array();
- foreach ($value as $v){
- array_push($em, $v);
- }
- array_push($emailNameJson, $em);
- }
-
- //
- $eMailList->date=date("Y-m-d");
- $eMailList->clientEmail=base64_encode(gzcompress(json_encode($emailJson[0])));
- $eMailList->clientEmail2=base64_encode(gzcompress(json_encode($emailJson[1])));
- $eMailList->clientEmail3=base64_encode(gzcompress(json_encode($emailJson[2])));
- $eMailList->clientName=base64_encode(gzcompress(json_encode($emailNameJson[0])));
- $eMailList->clientName2=base64_encode(gzcompress(json_encode($emailNameJson[1])));
- $eMailList->clientName3=base64_encode(gzcompress(json_encode($emailNameJson[2])));
- $eMailList->illegalEmail=json_encode(array_slice($illegalEmail,0,100));//json_encode($illegalEmail);
- $eMailList->sendEmail=json_encode($sendEmail);
-
- $eMailList->templateName=$smartcostMail;
- $eMailList->eTitle=$title;
- $eMailList->html=$html;
- $eMailList->content=$content;
- $eMailList->info=$info;
- if (!empty($annexName)){
- $eMailList->annex=$annexHtml;
- $eMailList->annexName=$annexName;
- }
- if ($stype==1){
- $eMailList->tag=implode(",", $tagId);
- $eMailList->districtId="";
- $eMailList->nature="";
- }
- if ($stype==2){
- $eMailList->districtId=$did;
- $eMailList->nature=implode(",", $nature);
- $eMailList->tag="";
- }
- $eMailList->update(array('where'=>'elid='.$elid));
- return "/eMailList";
- }
- return "/eMailTask";
- }
-
- function createEmail(){
-
- //include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
- $title=$this->get_args('title')?$this->get_args('title'):"";
- $skin=$this->get_args('skin')?$this->get_args('skin'):"";
- $content=isset($_POST['content'])?$_POST['content']:"";
- $tagId=$this->get_args('tagId')?$this->get_args('tagId'):array();
- $nature=$this->get_args('nature')?$this->get_args('nature'):array();
- $natureNULL=$this->get_args('natureNULL')?$this->get_args('natureNULL'):"";
-
- $did=$this->get_args('did')?$this->get_args('did'):"";
- $stype=$this->get_args('stype')?$this->get_args('stype'):"";
- if (!empty($title)&&(!empty($tagId)||!empty($did))){
- Doo::loadModel('eMailTemplate');
- $eMailTemplate=new eMailTemplate();
- Doo::loadModel('eMailJournal');
- $eMailJournal=new eMailJournal();
-
- if ($natureNULL!='NULL'){
- if (empty($tagId)&&!empty($did)&&empty($nature)){
- header ( 'Content-Type:text/html;charset=utf-8' );
- die('请选择性质');
- }
- }
- //annex
- $annexPath="";$annexEXT=$this->_GetFileEXT($_FILES["annex"]["name"]);$annexName="";
- if ( isset($_FILES['annex']['name']) ){
- if ((($annexEXT == "doc")|| ($annexEXT == "xls")|| ($annexEXT == "pdf")|| ($annexEXT == "ppt")|| ($annexEXT == "txt")|| ($annexEXT == "smr")
- || ($annexEXT == "spu")|| ($annexEXT == "zip")|| ($annexEXT == "rar")|| ($annexEXT == "jpg")|| ($annexEXT == "png")
- )&& ($_FILES["annex"]["size"] < 10485760)){
- $path=DOO::conf()->SITE_PATH."upload/emailAnnex/";
- if (!file_exists( $path. $_FILES["annex"]["name"])){
- $fileName=time().".".$annexEXT;
- $annexName=$_FILES['annex']['name'];
- $annexPath=$path.$fileName ;
- move_uploaded_file($_FILES["annex"]["tmp_name"],$annexPath);
- $annexPath=$this->webPath.$fileName;
- }
- }
- }
- $annexHtml='<table style="width:100%;margin:10px 0">
- <thead>
- <tr>
- <th align="left" colspan="2">下载附件:</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><a href="'.$annexPath.'" target="_blank">'.$annexName.'</a></td>
- <td> </td>
- </tr>
- </tbody>
- </table>';
- $smartcostMail='smartcost_mail_1';
- $info="";
- //html template
- if($skin==1){
- $html='<div><table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
- <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">
- <tbody><tr>
- <td style="background-color:#ff6501;padding:20px 0 25px;" align="center">
- <span style="vertical-align:bottom;font-size:20px;color:#fff;">'.$title.'</span>
- </td></tr><tr><td>
- <table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;border-top:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
- <tbody><tr><td style="padding: 0 40px;" align="left">
- <p style="margin-top:40px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
- </td></tr><tr><td style="padding: 0 40px;" align="left">
- <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>'.$this->staff[0]['username'].'</b>:</p>
- <p style="margin-top:0px;margin-bottom:20px;color:#383838;font-size:16px;line-height:32px;">
- '.$content.'</p>
- </td></tr>
- <tr><td align="left" style="padding: 0 40px;background:#fff">
- '.$annexHtml.'
- </td></tr>
- <tr> <td style="padding: 20px 40px;border-top:1px dashed #ddd" align="left">
- <p style="margin-bottom:10px;color:#383838;font-size:16px;line-height:22px;border-left:2px solid #FF6501;padding-left:5px">
- 纵横公路造价软件'.$this->staff[0]['category'].'办事处</p>
- <table>
- <tr><th align="right">电话:</th><td>'.$this->staff[0]['phone'].'</td></tr>
- <tr><th align="right">联系人:</th><td>'.$this->staff[0]['username'].'</td></tr>
- <tr><th align="right">手机:</th><td>'.$this->staff[0]['telephone'].'</td></tr>
- <tr><th align="right">QQ:</th><td>'.$this->staff[0]['qq'].'</td></tr>
- <tr><th align="right">邮箱:</th><td>'.$this->staff[0]['email'].'</td></tr>
- </table></td></tr></tbody></table></td></tr><tr>
- <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>
- </tr></tbody></table></td></tr></tbody></table></div>';
- $info='<table><tr><th align="right">电话:</th><td>'.$this->staff[0]['phone'].'</td></tr>
- <tr><th align="right">联系人:</th><td>'.$this->staff[0]['username'].'</td></tr>
- <tr><th align="right">手机:</th><td>'.$this->staff[0]['telephone'].'</td></tr>
- <tr><th align="right">QQ:</th><td>'.$this->staff[0]['qq'].'</td></tr>
- <tr><th align="right">邮箱:</th><td>'.$this->staff[0]['email'].'</td></tr></table>';
- }elseif ($skin==2){
- $smartcostMail='smartcost_mail_2';
- $html='<table cellspacing="0" cellpadding="0" style="background-color:#e4e4e4; width:100%;"><tbody><tr><td>
- <table align="center" cellspacing="0" cellpadding="0" style="background-color:#f8f8f8; width:640px;margin-bottom:20px">
- <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;">
- <b><span name="titleHtml">'.$title.'</span></b></p></td>
- </tr><tr><td><table align="center" cellspacing="0" cellpadding="0" style="border:1px solid #ddd;"><tbody><tr>
- <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>
- </tr><tr><td align="center" style="background-color:#fff;"><img width="640" height="191" src="http://zonghengvideo.qiniudn.com/hero.jpg"></td>
- </tr><tr><td align="left" style="background-color:#fff;padding:40px;border-bottom:1px solid #ddd;">
- <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
- <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>'.$this->staff[0]['username'].'</b>:</p>
- <p name="contentHtml" style="margin-top:0px;margin-bottom:15px;color:#383838;font-size:16px;line-height:32px;">'.$content.'</p></td>
- </tr>
- <tr><td align="left" style="padding: 0 40px;background:#fff">
- '.$annexHtml.'
- </td></tr>
- <tr><td style="padding: 10px 0;background:#EEF2F5"><table><tbody><tr>
- <td style="font-size:14pxl;color:#333;padding:0 20px"><b>纵横公路造价软件'.$this->staff[0]['category'].'办事处</b><br>'.$this->staff[0]['username'].'</td>
- <td><table><tbody><tr style="font-size:12px;color:#666">
- <th align="right">电话:</th><td style="padding:0 20px 0 0">'.$this->staff[0]['phone'].'</td>
- <th align="right">手机:</th><td>'.$this->staff[0]['telephone'].'</td></tr><tr style="font-size:12px;color:#666">
- <th align="right">QQ:</th><td>'.$this->staff[0]['qq'].'</td>
- <th align="right">邮箱: </th><td>'.$this->staff[0]['email'].'</td>
- </tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr>
- <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>
- </tr></tbody></table></td></tr></tbody> </table>';
- $info='<table><tbody><tr style="font-size:12px;color:#666">
- <th align="right">电话:</th><td style="padding:0 20px 0 0">'.$this->staff[0]['phone'].'</td>
- <th align="right">手机:</th><td>'.$this->staff[0]['telephone'].'</td></tr><tr style="font-size:12px;color:#666">
- <th align="right">QQ:</th><td>'.$this->staff[0]['qq'].'</td>
- <th align="right">邮箱: </th><td>'.$this->staff[0]['email'].'</td>
- </tr></tbody></table>';
- }else{
- $smartcostMail='smartcost_mail_3';
- $html='<table cellspacing="0" cellpadding="0" style="background-color:#ECF0E1; width:100%">
- <tbody>
- <tr>
- <td>
- <table align="center" cellspacing="0" cellpadding="0" style="width:698px;margin-bottom:30px;margin-top:30px;">
- <tbody>
- <tr>
- <td>
- <table align="center" cellspacing="0" cellpadding="0" style="border:1px solid #ccc;width:100%;border-top:none">
- <tbody>
- <tr>
- <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;">
- <div style="position:relative;text-align:right">
- <b style="font-size:24px;color:#8A9F98;z-index:999"><span name="titleHtml">'.$title.'</span></b>
- <div style="width:80px;height:80px;position:absolute;top:0;left:0"><img src="http://zonghengvideo.qiniudn.com/zonghenglogo.png"></div>
- </div>
- </td>
- </tr>
- <tr>
- <td align="left" style="background-color:#fff;padding:40px;border-bottom:1px solid #ddd;">
- <p style="margin-top:0px;margin-bottom:10px;color:#666;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
- <p style="margin-top:0px;margin-bottom:10px;color:#666;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>'.$this->staff[0]['username'].'</b>:</p>
- <p name="contentHtml" style="margin-top:0px;margin-bottom:15px;color:#666;font-size:16px;line-height:32px;">'.$content.'</p></td>
- </tr>
- <tr><td align="left" style="padding: 0 40px;background:#fff">
- '.$annexHtml.'
- </td></tr>
- <tr>
- <td style="padding: 10px 0 0;background:#F6F6F6;">
- <table>
- <tbody><tr>
- <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>
- <td>
- <table style="width:100%">
- <tbody><tr style="font-size:12px;color:#496781">
- <th align="right">电话:</th><td>'.$this->staff[0]['phone'].'</td>
- <th align="right">手机:</th><td>'.$this->staff[0]['telephone'].'</td>
- </tr>
- <tr style="font-size:12px;color:#496781">
- <th align="right">QQ:</th><td>'.$this->staff[0]['qq'].'</td>
- <th align="right">邮箱: </th><td>'.$this->staff[0]['email'].'</td>
- </tr>
- </tbody></table>
- </td>
- </tr>
- </tbody></table>
- </td>
- </tr>
- <tr>
- <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>
- </tr>
- </tbody>
- </table></td>
- </tr>
- </tbody>
- </table></td>
- </tr>
- </tbody>
- </table>';
- $info='<table><tr style="font-size:12px;color:#496781"><th align="right">电话:</th><td>'.$this->staff[0]['phone'].'</td>
- <th align="right">手机:</th><td>'.$this->staff[0]['telephone'].'</td></tr><tr style="font-size:12px;color:#496781">
- <th align="right">QQ:</th><td>'.$this->staff[0]['qq'].'</td>
- <th align="right">邮箱: </th><td>'.$this->staff[0]['email'].'</td></tr></table>
- ';
- }
- $eMailTemplate->title=$title;
- $eMailTemplate->skin=$skin;
- $eMailTemplate->content=$content;
- if (!empty($tagId))
- $eMailTemplate->tag=implode(",", $tagId);
- $eMailTemplate->staffId=$this->staff[0]['sid'];
- $eMailTemplate->staffName=$this->staff[0]['username'];
- $eMailTemplate->status=0;
- $eMailTemplate->html=$html;
- $eMailTemplate->annex=$annexPath;
- $eMailTemplate->annexName=$annexName;
- $etid=$eMailTemplate->insert();
- //create email list
- Doo::loadModel('tag_client');
- $tagClient=new tag_client();
- Doo::loadModel('client');
- $client=new client();
- Doo::loadModel('eMailList');
- $eMailList=new eMailList();
- Doo::loadModel('company');
- $company=new company();
-
- $tagCondition="";$tagArray=array();
- foreach ($tagId as $value){
- array_push($tagArray, " tag like '%".$value."%' ");
- }
- if(!empty($tagArray))
- $tagCondition=' and ('.implode(" or ", $tagArray).')';
- $clientList=$tagClient->find(array('select'=>'client','where'=>'sid='.$this->staff[0]['sid'].$tagCondition,'asArray'=>true));
- $clientArray=array();
- foreach ($clientList as $value){
- array_push($clientArray, $value['client']);
- }
- $clientEmailList=array();
- if (!empty($clientArray))
- $clientEmailList=$client->find(array('select'=>'email,cid,nicename as clientname,companyname','where'=>'cid in ('.implode(",", $clientArray).')','asArray'=>true));
- //
- if ($stype==2){
- //获取性质相关数据
- $cidList='';
- if ($natureNULL==''){
- $nD=array();
- foreach ($nature as $key=>$value){
- array_push($nD, ' nature like "'.$value.'"');
- //$nD=' nature like "'.$value.'"';
- }
- $nD=implode(' or ', $nD);
-
- $companycid=$company->find(array('select'=>'cid','where'=>$nD,'asArray'=>true));
- $cidList=array();
- foreach ($companycid as $key=>$value){
- array_push($cidList, $value['cid']);
- }
- $cidList=implode(',', $cidList);
- if (!empty($cidList))
- $cidList=' and companyid in ('.$cidList.')';
- else
- $cidList='';
- }
- //'select'=>'email,cid,nicename as clientname,companyname,district'
- $clientEmailList=$client->find(array('select'=>'email,cid,nicename as clientname,companyname,district','where'=>'district like "'.$did.',%" '.$cidList,'asArray'=>true));
- }
-
- //;datediff(curdate(), 'date')>=10
- $eMailJournal->delete(array('where'=>"datediff(curdate(), date)>=7"));
- $checkMail=$eMailJournal->find(array('where'=>'DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(date)',' groupby'=>'email','asArray'=>true));
- $emailNameList=$emailArray=$illegalEmail=$sendEmail=array();
- Doo::db()->beginTransaction();
- foreach ($clientEmailList as $value){
- if(filter_var($value['email'], FILTER_VALIDATE_EMAIL)){
- if(!empty($checkMail)){
- $falg=true;
- foreach ($checkMail as $v){
- if($v['email']==$value['email']){
- $Bdate=strtotime($v['date'])+7*24*3600;
- if($Bdate<=time()){
- array_push($emailArray, $value['email']);
- array_push($emailNameList, $value);
- $eMailJournal->date=date("Y-m-d");
- $eMailJournal->update(array('where'=>'ejid='.$v['ejid']));
- }else{
- array_push($sendEmail, $value);
- }
- $falg=false;
- break;
- }
- }
- if ($falg){
- array_push($emailArray, $value['email']);
- array_push($emailNameList, $value);
- $eMailJournal->clientId=$value['cid'];
- $eMailJournal->status=1;
- $eMailJournal->email=$value['email'];
- $eMailJournal->date=date("Y-m-d");
- //$eMailJournal->insert();
- }
- }else{
- array_push($emailArray, $value['email']);
- array_push($emailNameList, $value);
- $eMailJournal->clientId=$value['cid'];
- $eMailJournal->status=1;
- $eMailJournal->email=$value['email'];
- $eMailJournal->date=date("Y-m-d");
- //$eMailJournal->insert();
- }
- }else{
- array_push($illegalEmail, $value);
- }
- }
- Doo::db()->commit();
- //echo json_encode($illegalEmail);
- //json_encode(array_slice($illegalEmail,0,100))
- // $kk=gzcompress();
- // $ll=gzuncompress($kk);
- //."</br>".strlen($kk)."</br>".strlen($ll);die;
-
- $size=floor(count($emailArray)/3);
-
- if (!empty($emailArray)){
- if(count($emailArray)<3){
- $list=array(0=>$emailArray,1=>array(),2=>array());
- }else
- $list=array_chunk($emailArray,$size);
-
- }else
- $list=array(0=>array(),1=>array(),2=>array());
- $emailJson=array();
- foreach ($list as $value){
- $em=array();
- foreach ($value as $v){
- array_push($em, $v);
- }
- array_push($emailJson, $em);
- }
-
- $size=floor(count($emailNameList)/3);
-
- if (!empty($emailNameList)){
- if(count($emailNameList)<3){
- $list=array(0=>$emailNameList,1=>array(),2=>array());
- }else
- $list=array_chunk($emailNameList,$size);
- }else
- $list=array(0=>array(),1=>array(),2=>array());
- $emailNameJson=array();
- foreach ($list as $value){
- $em=array();
- foreach ($value as $v){
- array_push($em, $v);
- }
- array_push($emailNameJson, $em);
- }
-
- //
- $eMailList->date=date("Y-m-d");
- $eMailList->clientEmail=base64_encode(gzcompress(json_encode($emailJson[0])));
- $eMailList->clientEmail2=base64_encode(gzcompress(json_encode($emailJson[1])));
- $eMailList->clientEmail3=base64_encode(gzcompress(json_encode($emailJson[2])));
- $eMailList->clientName=base64_encode(gzcompress(json_encode($emailNameJson[0])));
- $eMailList->clientName2=base64_encode(gzcompress(json_encode($emailNameJson[1])));
- $eMailList->clientName3=base64_encode(gzcompress(json_encode($emailNameJson[2])));
- $eMailList->illegalEmail=json_encode(array_slice($illegalEmail,0,100));//json_encode($illegalEmail);
- $eMailList->sendEmail=json_encode($sendEmail);
- $eMailList->etid=$etid;
- $eMailList->templateName=$smartcostMail;
- $eMailList->eTitle=$title;
- $eMailList->html=$html;
- $eMailList->content=$content;
- $eMailList->info=$info;
- if (!empty($annexName))
- $eMailList->annex=$annexHtml;
- $eMailList->annexName=$annexName;
- $eMailList->staffId=$this->staff[0]['sid'];
- $eMailList->staffName=$this->staff[0]['username'];
- if ($stype==1)
- $eMailList->tag=implode(",", $tagId);
- if ($stype==2){
- $eMailList->districtId=$did;
- $eMailList->nature=implode(",", $nature);
- }
- $eMailList->insert();
- return "/eMailList";
- }
- return "/eMailTask";
- }
- function eMailList(){
- Doo::loadModel('eMailList');
- $eMailList=new eMailList();
- Doo::loadModel('tag');
- $tag=new tag();
- $mailList=$eMailList->find(array('where'=>'staffId='.$this->staff[0]['sid'],'desc'=>'elid','asArray'=>true));
- foreach ($mailList as $key=>$value){
- $mailList[$key]['clientName2']=$mailList[$key]['clientName3']=array();
- $mailList[$key]['clientName']=json_decode(gzuncompress(base64_decode($value['clientName'])),true);
-
- if(!empty($value['clientName2']))
- $mailList[$key]['clientName2']=json_decode(gzuncompress(base64_decode($value['clientName2'])),true);
- if(!empty($value['clientName3']))
- $mailList[$key]['clientName3']=json_decode(gzuncompress(base64_decode($value['clientName3'])),true);
- $mailList[$key]['illegalEmail']=json_decode($value['illegalEmail'],true);
- $mailList[$key]['sendEmail']=json_decode($value['sendEmail'],true);
- $mailList[$key]['clientCount']=count($mailList[$key]['clientName'])+count($mailList[$key]['clientName2'])+count($mailList[$key]['clientName3']);
- $mailList[$key]['tag']=array();
- if (!empty($value['tag']))
- $mailList[$key]['tag']=$tag->find(array('where'=>'tid in ( '.$value['tag'].') ','asArray'=>true));
- }
- $data['mailList']=$mailList;
- $data['memu']="eMailTask";
- $data['staff']=$this->staff;
- $data['mailMemu']='eMailList';
- $this->render ( "/mail_list", $data );
- }
- function showEmailContent(){
- $elid=isset($this->params['elid'])?$this->params['elid']:0;
-
- Doo::loadModel('eMailList');
- $eMList=new eMailList();
-
- $isSend=$eMList->getOne(array('where'=>'elid ='.$elid.'','asArray'=>true));
- echo htmlspecialchars($isSend['content']);
- }
-
- function postEmail(){
-
- //include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
-
- $elid=isset($this->params['elid'])?$this->params['elid']:0;
- $send=isset($this->params['send'])?$this->params['send']:0;
-
- Doo::loadModel('eMailList');
- $eMList=new eMailList();
- if (!empty($elid)){
-
- $isSend=$eMList->getOne(array('select'=>'send'.$send,'where'=>'elid ='.$elid.' and status=0 and send'.$send.'=1','asArray'=>true));
- if (!empty($isSend))
- die('这批邮件已经发送');
- if ($send==1)
- $send='';
- $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));
- $toFormatMail=array();$sub=array();
-
- $toMail=json_decode(gzuncompress(base64_decode($eMailList['clientEmail'])),true);
- //$toMailCount=count($toMail);
- $subMail=json_decode(gzuncompress(base64_decode($eMailList['clientName'])),true);
-
- $chunkMail=array_chunk($toMail,80);
- $chunkSubMail=array_chunk($subMail,80);
- $vii=0;
- foreach ($chunkMail as $key=>$value){
- $l=$s=$c=$i=$cate=$con=$annex=array();
- $toFormatMail['to']=$value;
- $cn=$chunkSubMail[$key];
- foreach ($cn as $v ){
- array_push($l, $eMailList['eTitle']);
- array_push($s, $eMailList['staffName']);
- array_push($c, $v['clientname']);
- array_push($annex, $eMailList['annex']);
- array_push($i, $eMailList['info']);
- //array_push($con, $eMailList['content']);
- array_push($cate, $this->staff[0]['category']);
- }
- $sub['%eTitle%']=$l;
- $sub['%staffName%']=$s;
- $sub['%clientName%']=$c;
- $sub['%category%']=$cate;
- $sub['%info%']=$i;
- //$sub['%content%']=$con;
- $sub['%annex%']=$annex;
- $toFormatMail['sub']=$sub;
-
-
- $url = 'http://sendcloud.sohu.com/webapi/mail.send_template.xml';
-
-
- $param = array('api_user' => 'cldmail',
- 'api_key' => 'cDO1GjtY1seH',
- 'template_invoke_name'=>$eMailList['templateName'],
- 'from' =>$this->staff[0]['email'],
- 'fromname' => '纵横'.$eMailList['staffName'],
- 'subject' => $eMailList['eTitle'],
- 'substitution_vars' => json_encode($toFormatMail));
- $post_data = http_build_query($param);
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_URL,$url);
- curl_setopt($ch, CURLOPT_HEADER, false); //设定是否输出页面内容
- curl_setopt($ch, CURLOPT_NOBODY, false);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
-
- $result =curl_exec($ch);
- curl_close($ch);
-
- /*
- if($result=='success'){
- $eM=new eMailList();
- $eM->status='2';
- $eM->update(array('where'=>'elid=?','param'=>array($elid)));
- }
- */
- }
-
- if ($send=="")
- $send=1;
-
- $sql = "update `CLD_eMailList` set send".$send."='1' where elid = '" . $elid."'";
- Doo::db ()->query ( $sql );
-
- $isSend=$eMList->getOne(array('where'=>'elid ='.$elid.' and status=0 and send1=1 and send2=1 and send3=1','asArray'=>true));
- if (!empty($isSend)){
- $sql = "update `CLD_eMailList` set status='2' where elid = '" . $elid."'";
- Doo::db ()->query ( $sql );
- }
-
- //die;
- return '/eMailList';
- }
- }
- function a(){
- $substitution_vars=$this->get_args('substitution_vars');
- file_put_contents(DOO::conf()->SITE_PATH .'upload/'."_".time()."_".rand(100,999).".log",$substitution_vars);
- }
- function deleteEmail(){
- $elid=isset($this->params['elid'])?$this->params['elid']:0;
- if (!empty($elid)){
- $sql = "DELETE FROM `CLD_eMailList` where elid = '" . $elid."'";
- Doo::db ()->query ( $sql );
- return '/eMailList';
- }
- }
- /**
- * 发送post请求
- * @param string $url 请求地址
- * @param array $post_data post键值对数据
- * @return string
- */
- function sendPost($url, $post_data) {
- $postdata = http_build_query($post_data);
- //X-Amzn-Authorization: AWS3 AWSAccessKeyId=AKIAIDSE5VYNX5ERJHXQ,Signature=lBP67vCvGlDMBQ=dofZxg8E8SUEXAMPLE,Algorithm=HmacSHA256,SignedHeaders=qG1BdSh9QyYPlWLnjqvjDXjyPdFjl7fUSkfs0Hk2
- $options = array(
- 'http' => array(
- 'method' => 'POST',
- 'header' => '
- Content-Type: application/x-www-form-urlencoded
- ',
- 'content' => $postdata,
- 'timeout' => 15 * 60 // 超时时间(单位:s)
- )
- );
- $context = stream_context_create($options);
- $result = file_get_contents($url, false, $context);
- return $result;
- }
- function avatar(){
- $result = array();
- $result['success'] = false;
- $successNum = 0;
- //定义一个变量用以储存当前头像的序号
- $avatarNumber = 1;
- $i = 0;
- $msg = '';
- //上传目录
- $dir = DOO::conf()->SITE_PATH."global/avatar";
- //遍历所有文件域
- while (list($key, $val) = each($_FILES)){
- if ( $_FILES[$key]['error'] > 0)
- $msg .= $_FILES[$key]['error'];
- else{
- $fileName = 'avatar_'.$this->staff[0]['sid'];
- //原始图片(file 域的名称:__source,如果客户端定义可以上传的话,可在此处理)。
- if ($key == '__source'){//当前头像基于原图的初始化参数,用于修改头像时保证界面的视图跟保存头像时一致。帮助提升用户体验度。修改头像时设置默认加载的原图的url为此图片的url+该参数即可。
- $initParams = $_POST["__initParams"];
- $virtualPath = $dir."/".$fileName."_".$avatarNumber.".jpg";
- $result['sourceUrl'] = '/' . $virtualPath.$initParams;
- move_uploaded_file($_FILES[$key]["tmp_name"], $virtualPath);
- $successNum++;
- }else if (strpos($key, '__avatar') === 0){//头像图片(file 域的名称:__avatar1,2,3...)。
- $virtualPath = $dir."/".$fileName."_".$avatarNumber.".jpg";
- $result['avatarUrls'][$i] = '/' . $virtualPath;
- move_uploaded_file($_FILES[$key]["tmp_name"], $virtualPath);
- $avatarNumber++;
- $successNum++;
- $i++;
- }
- }
- }
- $result['msg'] = $msg;
- if ($successNum > 0)
- $result['success'] = true;
- //返回图片的保存结果(返回内容为json字符串)
- Doo::loadModel('staff');
- $staff=new staff();
- $staff->sid=$this->staff[0]['sid'];
- $staff->avatar="/global/avatar/".$fileName;
- $staff->update();
- echo json_encode($result);
- }
- function lockUpload(){
- //move_uploaded_file($_FILES['Filedata']['tmp_name'], "/upload/".$_FILES['Filedata']['name']);
- if ( isset($_FILES['Filedata']['name']) ){
- $file = $_FILES['Filedata']['tmp_name'];
- $error = false;
- if (!is_uploaded_file($file) ){
- $error = '400 Bad Request';
- }
- if ($error) {
- header('HTTP/1.0 ' . $error);
- die('Error ' . $error);
- }else{
- include (DOO::conf()->SITE_PATH . 'protected/plugin/io.han.php');
- $this->IoHandler = new IoHandler();
- $pics = explode ( '.', $_FILES['Filedata']['name'] );
- //$filedir=$_POST['time'];
- //调用定义物理路径
- $t=DOO::conf()->SITE_PATH."upload/";
- $this->IoHandler->MakeDir($t);
- $filename=$this->_GetFileEXT($_FILES['Filedata']['name']);
- if($filename!='xlsx')
- return "";
- //$upload_dir = $t."/".time().rand(10,100).".".$filename;
- $upload_file = iconv("UTF-8", "GB2312", $_FILES["Filedata"]["name"]);
- $upload_dir = $t."/".$upload_file;
- $k=move_uploaded_file($file, $upload_dir);
- if($k){
- //"series/".$filedir."/".
- $m=round($_FILES['Filedata']['size']/1024/1024, 2);
- echo $pics[0].".".$filename."#".$m."#".$_FILES['Filedata']['size'];
- }
- }
- }
- }
- function getAuthentication(){
-
- }
-
- function loadCVS(){
-
- Doo::loadModel('longle');
- $longle=new longle();
- $list=$longle->find(array('select'=>'key_num','asArray' => TRUE));
-
- $file = fopen(DOO::conf()->SITE_PATH."upload/key2.csv",'r');
- while ($data = fgetcsv($file)) {
- $goods_list[$data[0]] = $data[1] ;
- }
- fclose($file);
-
- $sqlArray=array();
- $sql='UPDATE CLD_longle SET SerialNumber = CASE key_num ';
- foreach($list as $key=>$value){
-
- if(array_key_exists($value['key_num'],$goods_list)){
- //echo $value['key_num'].'-'.$goods_list[$value['key_num']].'<br/>';
- //$longle->SerialNumber=$goods_list[$value['key_num']];
- //$longle->update(array('where'=>'key_num="'.$value['key_num'].'"'));
- $sql.=' WHEN "'.$value['key_num'].'" THEN "'.$goods_list[$value['key_num']].'" ';
-
- array_push($sqlArray, '"'.$value['key_num'].'"');
- unset($goods_list[$value['key_num']]);
- }
- }
- $sql.='END WHERE key_num IN ('.implode(',', $sqlArray).')';
- echo $sql.'<br/>--------------------------------<br/>';
- foreach ($goods_list as $key=>$value){
- echo $key.','.$value.'<br/>';
- }
- }
-
- private function getRandChar($length){
- $str = null;
- $strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
- $max = strlen($strPol)-1;
-
- for($i=0;$i<$length;$i++){
- $str.=$strPol[rand(0,$max)];//rand($min,$max)生成介于min和max两个数之间的一个随机整数
- }
-
- return $str;
- }
- // private function getReceiptCount(){
- // $status=2;
- // $year=date('Y');
- // Doo::loadModel('receipt');
- // $receipt=new receipt();
- // $dateCondition=" and Year(date) =".$year;
- // $approvalCondition=' and nowStaff like "%'.$this->staff[0]['sid'].'%" ';
- // $receiptList=$receipt->find(array('where'=>' status='.$status.$dateCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
-
- // return count($receiptList);
- // }
- // private function getExeCount(){
- // Doo::loadModel('receipt');
- // $receipt=new receipt();
- // $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));
-
- // return count($receiptList);
- // }
-
- /**
- * 格式化excel文件为数组
- * @param unknown_type $file_url
- * @param unknown_type $mcid
- */
- function _format_excel_to_array($file_url = "") {
- if (! file_exists ( $file_url ))
- return array ();
- Doo::loadClass ( 'PHPExcel' );
- $PHPExcel = new PHPExcel ();
- $PHPReader = new PHPExcel_Reader_Excel2007 ();
- if (! $PHPReader->canRead ( $file_url )) {
- $PHPReader = new PHPExcel_Reader_Excel5 ();
- if (! $PHPReader->canRead ( $file_url )) {
- echo 'no Excel';
- return;
- }
- }
- $PHPExcel = $PHPReader->load ( $file_url );
- /**读取excel文件中的第一个工作表*/
- $currentSheet = $PHPExcel->getSheet ( 0 );
- /**取得最大的列号*/
- $allColumn = $currentSheet->getHighestColumn ();
- /**取得一共有多少行*/
- $allRow = $currentSheet->getHighestRow ();
- $excel_array = array ();
- for($currentRow = 2; $currentRow <= $allRow; $currentRow ++) {
- $excel_column = array ();
- //后期改进
- if($allColumn=='AM')
- $allColumn='Z';
- /**从第A列开始输出*/
- for($currentColumn = 'A'; $currentColumn <= $allColumn; $currentColumn ++) {
- $val = $currentSheet->getCellByColumnAndRow ( ord ( $currentColumn ) - 65, $currentRow )->getValue ();
- /**ord()将字符转为十进制数 iconv ( 'utf-8', 'gb2312',*/
- $val = "'" . addslashes ( $val ) . "'";
- if ($currentColumn == 'A')
- $excel_column ['key_num'] = $val;
- elseif ($currentColumn == 'C')
- $excel_column ['product'] = $val;
- elseif ($currentColumn == 'D'){
- $val=str_replace("'","",$val);
- $excel_column ['make_day'] = $this->excelTime($val);
- }elseif($currentColumn == 'E'){
- $val=str_replace("'","",$val);
- $excel_column ['alloted_time'] = $this->excelTime($val);
- }elseif($currentColumn == 'F'){
- $val=str_replace("'","",$val);
- $excel_column ['version'] = $val;
- }elseif ($currentColumn == 'B'){
- $val=str_replace("'","",$val);
- $excel_column ['SerialNumber'] = $val;
- }
- }
- array_push ( $excel_array, $excel_column );
- }
- return $excel_array;
- }
- function excelTime($date, $time = false)
- {
- if (function_exists ( 'GregorianToJD' ))
- {
- if (is_numeric ( $date ))
- {
- $jd = GregorianToJD ( 1, 1, 1970 );
- $gregorian = JDToGregorian ( $jd + intval ( $date ) - 25569 );
- $date = explode ( '/', $gregorian );
- $date_str = str_pad ( $date [2], 4, '0', STR_PAD_LEFT ) . "-" .
- str_pad ( $date [0], 2, '0', STR_PAD_LEFT ) . "-" .
- str_pad ( $date [1], 2, '0', STR_PAD_LEFT ) . ($time ? " 00:00:00" : '');
- return $date_str;
- }
- } else
- {
- $date = $date > 25568 ? $date + 1 : 25569;
- /* There was a bug if Converting date before 1-1-1970 (tstamp 0) */
- $ofs = (70 * 365 + 17 + 2) * 86400;
- $date = date ( "Y-m-d", ($date * 86400) - $ofs ) . ($time ? " 00:00:00" : '');
- }
- return $date;
- }
- function _GetFileEXT($filename) {
- $pics = explode ( '.', $filename );
- $num = count ( $pics );
- return $pics [$num - 1];
- }
- /**
- * 获取get或者POST值
- * @param string $name 属性名称
- * @return fixed 值
- */
- function get_args($name) {
- if (isset ( $_GET [$name] )) {
- if (is_array ( $_GET [$name] ))
- return $_GET [$name];
- else {
- return addslashes ( $_GET [$name] );
- }
- } elseif (isset ( $_POST [$name] )) {
- if (is_array ( $_POST [$name] ))
- return $_POST [$name];
- else {
- return addslashes ( $_POST [$name] );
- }
- } else {
- return false;
- }
- }
- function get_previous($on_page = 1) {
- return $on_page != 0 ? $on_page - 1 : $on_page;
- }
- /**
- * 获得分页数据
- * @param unknown_type $table
- * @param unknown_type $condition
- * @param unknown_type $on_page
- * @param unknown_type $page_size
- */
- function get_Tpage($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "",$tagSQL) {
- $page_c = "";
- $page ['previous'] = $this->get_previous ( $on_page );
- $page ['on_page'] = $on_page;
- $total_count = $this->get_table_Tcount ( $table, $condition,$tagSQL );
- $total = intval ( $total_count / $page_size );
- $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
- $page ['total_data'] = $total_count;
- $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
- $i = 1;
- $page_max = 1;
- if ($on_page > 10) {
- $page_max = intval ( $on_page / 10 ) + 1;
- $i = intval ( $on_page / 10 ) * 10 - 1;
- }
- $page ['page'] = $page_c;
- $page ['lower'] = (-- $on_page) * $page_size;
- return $page;
- }
- /**
- * 获得分页数据
- * @param unknown_type $table
- * @param unknown_type $condition
- * @param unknown_type $on_page
- * @param unknown_type $page_size
- */
- function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page",$staffid="",$search,$tooltip,$cateid,$tagSQL) {
- $page_c = "";
- $page ['previous'] = $this->get_previous ( $on_page );
- $page ['on_page'] = $on_page;
- $total_count = $this->get_table_count ( $table, $condition ,$staffid,$search,$tooltip,$cateid,$tagSQL);
- $total = intval ( $total_count / $page_size );
- $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
- $page ['total_data'] = $total_count;
- $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
- $i = 1;
- $page_max = 1;
- if ($on_page > 10) {
- $page_max = intval ( $on_page / 10 ) + 1;
- $i = intval ( $on_page / 10 ) * 10 - 1;
- }
- for(; $i <= $page ['total_page']; $i ++) {
- if ($i == $on_page) {
- if ($other == "page")
- $page_c .= '<a href="javascript:void(0);" class="current">' . $i . '</a>';
- else
- $page_c .= ' <span class="current">' . $i . '</span> ';
- } else if ($other == "page")
- $page_c .= '<a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a>';
- else
- $page_c .= ' <a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a> ';
- if ($i == (10 * $page_max))
- break;
- }
- $page ['page'] = $page_c;
- $page ['lower'] = (-- $on_page) * $page_size;
- return $page;
- }
- /**
- * 获取总页数
- * @param unknown_type $table
- * @param unknown_type $condition
- */
- public function get_table_Tcount($table = "", $condition = "",$tagSQL) {
- if ($tagSQL)
- $sql = "select count(*) as count from CLD_tagCompanyNexus as a left join CLD_company as b on (a.company=b.cid ) where ".$condition ;
- else
- $sql = "select count(*) as count from CLD_company where " . $condition ;
- $query = Doo::db ()->query ( $sql );
- $result = $query->fetch ();
- return $result ['count'];
- }
- /**
- * 获取总页数
- * @param unknown_type $table
- * @param unknown_type $condition
- */
- public function get_table_count($table = "", $condition = "",$staffid="",$search,$tooltip,$cateid,$tagSQL) {
- //$sql = "select count(*) as count from " . $table . " where 1 " . $condition;
- //echo $staffid;die;
- //
- if (!empty($staffid)){
- //$staffid="and a.sid= '".$staffid."'"; " . $table . " as a left join on (a.cid=b.cid ".$staffid.")
- $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 ;
- }else{
- if(strlen($condition)==1||empty($condition))
- $sql = "select count(*) as count from CLD_client as a ".$condition;
- else
- $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;
- }
- if(!empty($search))
- $sql = "select count(*) as count from CLD_client as a where 1 ".$condition ;
- if(!empty($tooltip)){
- $condition=str_replace("a.","c.",$condition);
- if ($tagSQL)
- $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 ;
- else
- $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 ;
- }
- //echo $sql;
- $query = Doo::db ()->query ( $sql );
- $result = $query->fetch ();
- return $result ['count'];
- }
- }
- ?>
|