MainController.php 241 KB

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