MainController.php 266 KB

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