From 3828abf24dfab433781f27437d1a980b03874a99 Mon Sep 17 00:00:00 2001 From: Tomasz Stalka Date: Tue, 21 Mar 2017 09:57:00 +0100 Subject: [PATCH] Fixed Opps overdue report --- src/classes/OpenOpportunityMailer.cls | 32 ++++++++++----------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/src/classes/OpenOpportunityMailer.cls b/src/classes/OpenOpportunityMailer.cls index d16b1137..be3ac93a 100644 --- a/src/classes/OpenOpportunityMailer.cls +++ b/src/classes/OpenOpportunityMailer.cls @@ -5,7 +5,7 @@ * */ public class OpenOpportunityMailer { - + private static final String EMAIL_SUBJECT = ' | | Biz Dev Report'; private static final String GLOBAL_RED_EMAIL_SUBJECT = 'Dimagi Overdue Opportunities'; private static final String RED_EMAIL_SUBJECT = 'Your Overdue Opportunities'; @@ -14,51 +14,43 @@ public class OpenOpportunityMailer { public static void sendOpenOpportunitiesBatchReport(User user, String[] recipients, Map stagedOpportunities) { Map stageComments = new Map(); - for (String stageComment :stagedOpportunities.keySet()) { + for (String stageComment :stagedOpportunities.keySet()) { stageComments.put(stageComment, ''); } - - String content = OpenOpportunityEmailUtils.buildEmailContent(stagedOpportunities, false, stageComments); - - sendEmail(content, recipients, EMAIL_SUBJECT, user.Name); + + String content = OpenOpportunityEmailUtils.buildEmailContent(stagedOpportunities, true, stageComments); + sendEmail(content, recipients, EMAIL_SUBJECT, user.Name); } - + public static void sendOpenOpportunitiesDailyReport(User[] users, Map stagedOpportunities) { - Map stageComments = new Map(); - for (String stageComment :stagedOpportunities.keySet()) { + for (String stageComment :stagedOpportunities.keySet()) { stageComments.put(stageComment, ''); } - - String content = OpenOpportunityEmailUtils.buildEmailContent(stagedOpportunities, false, stageComments); - + + String content = OpenOpportunityEmailUtils.buildEmailContent(stagedOpportunities, true, stageComments); + sendEmails(content, users, EMAIL_SUBJECT); - } - public static void sendOpenOpportunitiesSingleReport(User[] users, String[] recipients, Map stageComments) { - + public static void sendOpenOpportunitiesSingleReport(User[] users, String[] recipients, Map stageComments) { Id[] usersId = new Id[] {}; String usersNameSubject = ' - '; for (User user :users) { usersId.add(user.Id); usersNameSubject += user.Name + ' - '; } - + Map stagedOpportunities = OpenOpportunityReportController.getInstance().getOpenOpportunitiesOrderByStage(usersId); - String content = OpenOpportunityEmailUtils.buildEmailContent(stagedOpportunities, true, stageComments); - sendEmail(content, recipients, EMAIL_SUBJECT, usersNameSubject); } private static Map getRedStagedOpportunities(Map stagedOpportunities) { Map redStagedOpportunities = new Map(); - Integer daysNotUpdatedLimit = Open_Opportunity_Settings__c.getOrgDefaults().Days_Not_Updated_Limit__c != null ? Open_Opportunity_Settings__c.getOrgDefaults().Days_Not_Updated_Limit__c.intValue() : 30; - Integer daysNotUpdatedLimitEarlyStages = Open_Opportunity_Settings__c.getOrgDefaults().Days_Not_Updated_Limit_Early_Stages__c != null ? Open_Opportunity_Settings__c.getOrgDefaults().Days_Not_Updated_Limit_Early_Stages__c.intValue() : 10;