MainController.php 246 KB

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