MainController.php 265 KB

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