Skip to content

Commit

Permalink
adding email templates, reports, and dashboards
Browse files Browse the repository at this point in the history
  • Loading branch information
jonsayer committed Aug 2, 2019
1 parent 6edf572 commit 577ba56
Show file tree
Hide file tree
Showing 18 changed files with 1,021 additions and 440 deletions.
13 changes: 10 additions & 3 deletions src/classes/C501_CTRL_ClassReg_CreateAcct.cls
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,13 @@ public class C501_CTRL_ClassReg_CreateAcct {
insert term;
if(parent.MobilePhone != null && parent.MobilePhone != '' ){
String SMSmessage = Label.C501_RegSite_ConfirmSMS+' '+schoolNameText.Name;
if(parent.Email != null && parent.Email != ''){
SMSmessage = SMSmessage + Label.C501_RegSite_SMSweSentAnEmail + ' ' + parent.Email;
}
C501_UTIL_ClassRegUtilities.logActivityToContact(parent.Id,SMSmessage, SMSmessage,'Call');
C501_UTIL_ClassRegUtilities.sendSMSGenericFuture(parent.MobilePhone,Label.C501_RegSite_ConfirmSMS+' '+schoolNameText.Name );
}

if(parent.Email != null && parent.Email != '' ){
String teacherName = '';
for(Integer i = 0; i < schoolNameText.npe5__Affiliations__r.size(); i++){
Expand All @@ -415,10 +419,13 @@ public class C501_CTRL_ClassReg_CreateAcct {
nextStartDate = Datetime.newInstance(schoolNameText.C501_Next_Program_Start_Date__c, Time.newInstance(0,0,0,0)).format('MMMMM d, yyyy');
}

String emailMessage = Label.C501_RegSite_ConfirmSMS+' '+schoolNameText.Name +Label.C501_RegSite_EmailConfirmP2+' '+nextStartDate+' '+Label.C501_RegSite_EmailConfirmP3+' '+teacherName+Label.C501_RegSite_EmailConfirmP4;
C501_UTIL_ClassRegUtilities.SendEmailGeneric('[email protected]',parent.Email,Label.C501_RegSite_ConfirmSMS+' '+schoolNameText.Name,emailMessage);
Id templateId = [Select id from EmailTemplate where DeveloperName = 'C501_RegSite_Class_Registration_Confirmation_Message'].Id;

//String emailMessage = Label.C501_RegSite_ConfirmSMS+' '+schoolNameText.Name +Label.C501_RegSite_EmailConfirmP2+' '+nextStartDate+' '+Label.C501_RegSite_EmailConfirmP3+' '+teacherName+Label.C501_RegSite_EmailConfirmP4;
//C501_UTIL_ClassRegUtilities.SendEmailGeneric('[email protected]',parent.Email,Label.C501_RegSite_ConfirmSMS+' '+schoolNameText.Name,emailMessage);
C501_UTIL_ClassRegUtilities.SendEmailGeneric('[email protected]',null,null,null,term.Id,templateId,parent.Id);

C501_UTIL_ClassRegUtilities.logActivityToContact(parent.Id,Label.C501_RegSite_ConfirmSMS+' '+schoolNameText.Name, emailMessage,'Email');
//C501_UTIL_ClassRegUtilities.logActivityToContact(parent.Id,Label.C501_RegSite_ConfirmSMS+' '+schoolNameText.Name, emailMessage,'Email');
}
pageStatus = 'finished';
return null;
Expand Down
69 changes: 43 additions & 26 deletions src/classes/C501_UTIL_ClassRegUtilities.cls
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,12 @@ public class C501_UTIL_ClassRegUtilities {
public static void sendEmailConfirmation(ID AcctID, String emailAddress){
Class_Site_Login_Attempt__c att = generateLoginCode(AcctID, emailAddress);
String message = Label.C501_ClassReg_CodeMessage + ' '+att.Secret_Code__c + ' ' +Label.C501_ClassReg_CodeMessageDisclaim+' '+Label.C501_ClassReg_CodeMessageExpire;
SendEmailGeneric('[email protected]',emailAddress,Label.C501_ClassReg_ConfirmCodeSubject,message);
SendEmailGeneric('[email protected]',emailAddress,Label.C501_ClassReg_ConfirmCodeSubject,message,null,null,null);
insert att;
}

public static void SendEmailGeneric(String fromAddress,String toAddress,String subject,String message){
// Blatantly stolen from here: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_forcecom_email_outbound.htm
public static void SendEmailGeneric(String fromAddress,String toAddress,String subject,String message,ID associatedRecord,ID templateId,ID targetRecord){
// Blatantly stolen from here and modified: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_forcecom_email_outbound.htm

// First, reserve email capacity for the current Apex transaction to ensure
// that we won't exceed our daily email limits when sending email after
Expand All @@ -210,33 +210,50 @@ public class C501_UTIL_ClassRegUtilities {
// that will send out a single email to the addresses in the To, CC & BCC list.
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

OrgWideEmailAddress[] owea = [select Id from OrgWideEmailAddress where Address = :fromAddress and IsAllowAllProfiles = true];
if(owea.size() > 0){
mail.setOrgWideEmailAddressId(owea.get(0).Id);
}


// Strings to hold the email addresses to which you are sending the email.
List<String> toAddresses = new List<String>();
toAddresses.add(toAddress);

if(owea.size() == 0){
// Specify the address used when the recipients reply to the email.
mail.setReplyTo(fromAddress);

// Specify the name used as the display name.
mail.setSenderDisplayName('Techbridge Girls');
}

// Assign the addresses for the To and CC lists to the mail object.
mail.setToAddresses(toAddresses);

// Specify the address used when the recipients reply to the email.
mail.setReplyTo(fromAddress);

// Specify the name used as the display name.
mail.setSenderDisplayName('Techbridge Girls');

// Specify the subject line for your email address.
mail.setSubject(subject);

// Set to True if you want to BCC yourself on the email.
mail.setBccSender(false);

// Optionally append the salesforce.com email signature to the email.
// The email address of the user executing the Apex Code will be used.
mail.setUseSignature(false);

// Specify the text content of the email.
mail.setPlainTextBody(message);

mail.setHtmlBody('<p>'+message+'</p>');
// if we are using a template, set that. If not, send with supplied variables.
if(templateId != null && associatedRecord != null){
mail.setTemplateID(templateId);
mail.setTargetObjectId(targetRecord);
mail.setWhatId(associatedRecord);
// save a copy of this as an activity to the supplied contact ie target record
mail.setSaveAsActivity(true);
} else {
// Specify the subject line for your email address.
mail.setSubject(subject);

// Assign the addresses for the To and CC lists to the mail object.
mail.setToAddresses(toAddresses);

// Set to True if you want to BCC yourself on the email.
mail.setBccSender(false);

// Optionally append the salesforce.com email signature to the email.
// The email address of the user executing the Apex Code will be used.
mail.setUseSignature(false);

// Specify the text content of the email.
mail.setPlainTextBody(message);

mail.setHtmlBody('<p>'+message+'</p>');
}

// Send the email you have created.
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<Dashboard xmlns="http://soap.sforce.com/2006/04/metadata">
<backgroundEndColor>#FFFFFF</backgroundEndColor>
<backgroundFadeDirection>Diagonal</backgroundFadeDirection>
<backgroundStartColor>#FFFFFF</backgroundStartColor>
<dashboardType>SpecifiedUser</dashboardType>
<isGridLayout>false</isGridLayout>
<leftSection>
<columnSize>Medium</columnSize>
<components>
<autoselectColumnsFromReport>true</autoselectColumnsFromReport>
<chartAxisRange>Auto</chartAxisRange>
<componentType>Pie</componentType>
<displayUnits>Auto</displayUnits>
<drillEnabled>false</drillEnabled>
<drillToDetailEnabled>false</drillToDetailEnabled>
<enableHover>false</enableHover>
<expandOthers>true</expandOthers>
<groupingSortProperties/>
<header>Class Reg&apos;s This Year by Method</header>
<legendPosition>Bottom</legendPosition>
<report>unfiled$public/Class_Reg_s_by_Signup_Method_This_Year</report>
<showPercentage>true</showPercentage>
<showValues>true</showValues>
<sortBy>RowLabelAscending</sortBy>
<useReportChart>false</useReportChart>
</components>
</leftSection>
<middleSection>
<columnSize>Medium</columnSize>
</middleSection>
<rightSection>
<columnSize>Medium</columnSize>
</rightSection>
<runningUser>[email protected]</runningUser>
<textColor>#000000</textColor>
<title>Class registration data</title>
<titleColor>#000000</titleColor>
<titleSize>12</titleSize>
</Dashboard>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<messaging:emailTemplate subject="Confirmation for your class registration" recipientType="Contact" relatedToType="School_Term__c">
<messaging:plainTextEmailBody >
Congratulations!
This is your new Visualforce Email Template.
</messaging:plainTextEmailBody>
</messaging:emailTemplate>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<EmailTemplate xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>46.0</apiVersion>
<available>true</available>
<encodingKey>ISO-8859-1</encodingKey>
<name>Class Registration: Confirmation Message</name>
<style>none</style>
<subject>Confirmation for your class registration</subject>
<type>visualforce</type>
<uiType>Aloha</uiType>
</EmailTemplate>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Student Name

Student Email

Student Phone

Address

School

Grade

Transportation home after Techbridge Girls program ends:


Individuals Authorized to Pickup Your Child

Emergency Contact(s)

Student Birthdate
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<EmailTemplate xmlns="http://soap.sforce.com/2006/04/metadata">
<available>true</available>
<encodingKey>ISO-8859-1</encodingKey>
<name>Class Registration: Confirmation Message</name>
<style>none</style>
<subject>Confirmation for your class registration</subject>
<type>text</type>
<uiType>Aloha</uiType>
</EmailTemplate>
37 changes: 31 additions & 6 deletions src/labels/CustomLabels.labels
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@
<language>en_US</language>
<protected>false</protected>
<shortDescription>C501_ClassReg_CodeMessage</shortDescription>
<value>Hello There! Your code for the Techbridge Girls registration system is:</value>
<value>Your Techbridge Girls verification code is</value>
</labels>
<labels>
<fullName>C501_ClassReg_CodeMessageDisclaim</fullName>
<language>en_US</language>
<protected>false</protected>
<shortDescription>C501_ClassReg_CodeMessageDisclaim</shortDescription>
<value>This is an unmonitored account so please don’t reply.</value>
<value>. This phone number is unmonitored.</value>
</labels>
<labels>
<fullName>C501_ClassReg_CodeMessageExpire</fullName>
Expand All @@ -117,7 +117,7 @@
<language>en_US</language>
<protected>false</protected>
<shortDescription>C501_ClassReg_EmergencySubtext</shortDescription>
<value>In case the parent/guardian cannot be reached, please provide an EMERGENCY CONTACT.</value>
<value>In case the parent/guardian cannot be reached, please provide an EMERGENCY CONTACT (other than yourself).</value>
</labels>
<labels>
<fullName>C501_ClassReg_EvalStudy</fullName>
Expand Down Expand Up @@ -419,6 +419,17 @@ We may also look at your child’s school information, like attendance and cours
<shortDescription>C501_RegSite_CodeMismatch</shortDescription>
<value>That doesn&apos;t seem to match the code we sent you. Try again?</value>
</labels>
<labels>
<fullName>C501_RegSite_ConfirmContact</fullName>
<language>en_US</language>
<protected>false</protected>
<shortDescription>C501_RegSite_ConfirmContact</shortDescription>
<value>&lt;p&gt;If you have any questions or notice a mistake in your responses below, please contact the following regional coordinators based on where your student attends school:&lt;/p&gt;

&lt;p&gt;California or Pacific Northwest (WA, ID, OR, MT, AK) - &lt;a href=&quot;mailto:[email protected]&quot;&gt;[email protected]&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Washington DC Metro - &lt;a href=&quot;mailto:[email protected]&quot;&gt;[email protected]&lt;/a&gt;&lt;/p&gt;</value>
</labels>
<labels>
<fullName>C501_RegSite_ConfirmMessageSite</fullName>
<language>en_US</language>
Expand Down Expand Up @@ -501,7 +512,7 @@ We may also look at your child’s school information, like attendance and cours
<language>en_US</language>
<protected>false</protected>
<shortDescription>C501_RegSite_Grade</shortDescription>
<value>Grade</value>
<value>Grade (for 2018-19 school year)</value>
</labels>
<labels>
<fullName>C501_RegSite_InvalidEmailPhone</fullName>
Expand Down Expand Up @@ -587,12 +598,19 @@ We may also look at your child’s school information, like attendance and cours
<shortDescription>C501_RegSite_PickUpChildError</shortDescription>
<value>Please identify someone who can pick up your child from the program.</value>
</labels>
<labels>
<fullName>C501_RegSite_PlzAreaCode</fullName>
<language>en_US</language>
<protected>false</protected>
<shortDescription>C501_RegSite_PlzAreaCode</shortDescription>
<value>Please include area code: (###) ###-####</value>
</labels>
<labels>
<fullName>C501_RegSite_ProvidePhoneEmail</fullName>
<language>en_US</language>
<protected>false</protected>
<shortDescription>C501_RegSite_ProvidePhoneEmail</shortDescription>
<value>Please provide your phone number or email address to log in.</value>
<value>Please provide your phone number or email address to access the student registration system.</value>
</labels>
<labels>
<fullName>C501_RegSite_ProvideStudentId</fullName>
Expand All @@ -608,6 +626,13 @@ We may also look at your child’s school information, like attendance and cours
<shortDescription>C501_RegSite_RememberMeDevice</shortDescription>
<value>Remember me on this device.</value>
</labels>
<labels>
<fullName>C501_RegSite_SMSweSentAnEmail</fullName>
<language>en_US</language>
<protected>false</protected>
<shortDescription>C501_RegSite_SMSweSentAnEmail</shortDescription>
<value>An email with registration info has been sent to</value>
</labels>
<labels>
<fullName>C501_RegSite_SelectGrade</fullName>
<language>en_US</language>
Expand All @@ -634,7 +659,7 @@ We may also look at your child’s school information, like attendance and cours
<language>en_US</language>
<protected>false</protected>
<shortDescription>C501_RegSite_SiteRegFormTitle</shortDescription>
<value>Techbridge Girls Class Registration Form</value>
<value>Techbridge Girls Student Registration Form</value>
</labels>
<labels>
<fullName>C501_RegSite_State</fullName>
Expand Down
4 changes: 4 additions & 0 deletions src/layouts/School_Term__c-School Term Layout.layout
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
<behavior>Edit</behavior>
<field>C501_Sign_Up_Source__c</field>
</layoutItems>
<layoutItems>
<behavior>Edit</behavior>
<field>C501_Free_Reduced_Lunch_Picklist__c</field>
</layoutItems>
</layoutColumns>
<layoutColumns>
<layoutItems>
Expand Down
Loading

0 comments on commit 577ba56

Please sign in to comment.