MainController.php 247 KB

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