Skip to content

Commit

Permalink
changes up to July 7
Browse files Browse the repository at this point in the history
  • Loading branch information
jonsayer committed Jul 7, 2019
1 parent d541648 commit 3c0836c
Show file tree
Hide file tree
Showing 7 changed files with 286 additions and 28 deletions.
75 changes: 61 additions & 14 deletions src/classes/C501_CTRL_ClassReg_CreateAcct.cls
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class C501_CTRL_ClassReg_CreateAcct {
public String pageStatus {get; set;}
public ID loginID {get; set;}
public String schoolName {get; set;}
public String schoolNameText {get; set;}
public Account schoolNameText {get; set;}
public String schoolRegion {
get{
if(schoolRegion == null){
Expand All @@ -18,8 +18,13 @@ public class C501_CTRL_ClassReg_CreateAcct {
}
set;
}

public School_Term__c term {get; set;}
public String grade {get; set;}
public Boolean noState {get; set;}
public Boolean noSchool {get; set;}
public Boolean noGrade {get; set;}
public Boolean noWaiver {get; set;}
private String RegType {get; set;}

public List<SelectOption> schoolList {
Expand Down Expand Up @@ -93,7 +98,11 @@ public class C501_CTRL_ClassReg_CreateAcct {

gradeList = C501_UTIL_ClassRegUtilities.listOfGrades();
schoolName = '';
schoolNameText = '';
schoolNameText = null;
noState = false;
noSchool = false;
noGrade = false;
noWaiver = false;

Map<String, Schema.FieldSet> FsAcctMap = Schema.SObjectType.Account.fieldSets.getMap();
Map<String, Schema.FieldSet> FsContMap = Schema.SObjectType.Contact.fieldSets.getMap();
Expand Down Expand Up @@ -169,17 +178,38 @@ public class C501_CTRL_ClassReg_CreateAcct {
Boolean passValidation = true;

if(schoolName == null || schoolName == '' ){
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Please Select a School') );
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,Label.C501_RegSite_SelectSchool) );
noSchool = true;
passValidation = false;
} else {
noSchool = false;
}
/*if(family.BillingState == null || family.BillingState == '' ){
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,Label.C501_RegSite_SelectState) );
noState = true;
passValidation = false;
} else {
noState = false;
}*/
if(grade == null || grade == '' ){
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Please Select a Grade') );
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,Label.C501_RegSite_SelectGrade) );
noGrade = true;
passValidation = false;
} else {
noGrade = false;
}
if( parent.Email == null && parent.HomePhone == null && parent.MobilePhone == null && parent.OtherPhone == null ){
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Please enter a contact method (phone number or email) for the parent. We need to be able to contact you!') );
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,Label.C501_RegSite_ParentContactRequired) );
passValidation = false;
}
if(term.Waiver__c == false){
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,Label.C501_ClassReg_WaiverRequired) );
noWaiver = true;
passValidation = false;
} else {
noWaiver = false;
}

if(passValidation == false){
return null;
}
Expand All @@ -200,15 +230,37 @@ public class C501_CTRL_ClassReg_CreateAcct {
term.Parent__c = parent.Id;
term.School__c = schoolName;

schoolNameText = [Select id,Name from Account where id = :schoolName].Name;
schoolNameText = [Select id,
Name,
Teachers_at_Site__c,
Primary_Teacher__r.FirstName ,
Primary_Teacher__r.LastName ,
Secondary_Teacher__r.FirstName ,
Secondary_Teacher__r.LastName
from Account
where id = :schoolName];

// future version, need to make this dynamic
term.School_Year__c = C501_UTIL_ClassRegUtilities.currentSchoolYear( Date.today() );
term.C501_Sign_Up_Source__c = 'Online';

insert term;


if(parent.MobilePhone != null && parent.MobilePhone != '' ){
String SMSmessage = Label.C501_RegSite_ConfirmSMS+' '+schoolNameText.Name;
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 = schoolNameText.Primary_Teacher__r.FirstName + ' ' + schoolNameText.Primary_Teacher__r.LastName;

if(schoolNameText.Secondary_Teacher__r.LastName != null){
teacherName = teacherName + ' ' + Label.C501_ClassReg_AND + ' ' + schoolNameText.Secondary_Teacher__r.FirstName + ' ' + schoolNameText.Secondary_Teacher__r.LastName;
}

String emailMessage = Label.C501_RegSite_ConfirmSMS+' '+schoolNameText.Name +Label.C501_RegSite_EmailConfirmP2+' '+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.logActivityToContact(parent.Id,Label.C501_RegSite_ConfirmSMS+' '+schoolNameText.Name, emailMessage,'Email');
}
pageStatus = 'finished';
return null;
}
Expand Down Expand Up @@ -264,9 +316,4 @@ public class C501_CTRL_ClassReg_CreateAcct {
return schoolOptions;
}

/*public map<string,list<SelectOption>> contactFieldName2Options(){
}*/


}
10 changes: 8 additions & 2 deletions src/classes/C501_TEST_ClassReg_CreateAcct.cls
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public class C501_TEST_ClassReg_CreateAcct {
}

@isTest static void testSuccessfulInsert(){
insert new TwilioConfig__c(Name = 'default', AuthToken__c = 'xxx', Default_Send_Number__c = '206222222', AccountSid__c = 'xxx');

Class_Site_Login_Attempt__c att = createLoggedInTestUser();

Account school = new Account(Name='TestSchool',Region__c = 'Seattle');
Expand All @@ -61,13 +63,17 @@ public class C501_TEST_ClassReg_CreateAcct {
Test.setCurrentPage(createAcctPage);
System.currentPageReference().getParameters().put('a', att.id);
System.currentPageReference().getParameters().put('r', '1');
System.currentPageReference().getParameters().put('c', '[email protected]');

Test.startTest();
C501_CTRL_ClassReg_CreateAcct controller = new C501_CTRL_ClassReg_CreateAcct();
System.assert(controller.pageStatus == 'new');

controller.parent.FirstName = 'Test';
controller.parent.LastName = 'LastName';
//System.assert(controller.getRegions().size() == 5);

controller.parent.FirstName = 'Test';
controller.parent.LastName = 'LastName';
controller.parent.MobilePhone = '1234567890';
controller.family.BillingStreet = '123 Main St';
controller.family.BillingCity = 'Seattle';
controller.family.BillingState = 'WA';
Expand Down
27 changes: 24 additions & 3 deletions src/classes/C501_UTIL_ClassRegUtilities.cls
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ public class C501_UTIL_ClassRegUtilities {

public static void sendEmailConfirmation(ID AcctID, String emailAddress){
Class_Site_Login_Attempt__c att = generateLoginCode(AcctID, emailAddress);
String message = 'Hello there! Your code is: '+att.Secret_Code__c;
SendEmailGeneric('[email protected]',emailAddress,'Your Techbridge Girls Confirmation Code',message);
String message = Label.C501_ClassReg_CodeMessage + ' '+att.Secret_Code__c + ' ' +Label.C501_ClassReg_CodeMessageDisclaim;
SendEmailGeneric('[email protected]',emailAddress,Label.C501_ClassReg_ConfirmCodeSubject,message);
insert att;
}

Expand Down Expand Up @@ -256,6 +256,12 @@ public class C501_UTIL_ClassRegUtilities {
return att;
}

@future(callout=true)
public static void sendSMSGenericFuture(String phoneNumber, String message){
sendSMSGeneric(phoneNumber,message);
}


public static void sendSMSGeneric(String phoneNumber, String message){
TwilioConfig__c tcon = [SELECT id, AccountSid__c, AuthToken__c, Default_Send_Number__c FROM TwilioConfig__c WHERE Name = 'default' LIMIT 1];

Expand All @@ -272,7 +278,7 @@ public class C501_UTIL_ClassRegUtilities {

public static void sendSMS(ID AcctID,String phoneNumber){
Class_Site_Login_Attempt__c att = generateLoginCode(AcctId, phoneNumber);
sendSMSGeneric(phoneNumber,'Hello there! Your code is: '+att.Secret_Code__c);
sendSMSGeneric(phoneNumber,Label.C501_ClassReg_CodeMessage + ' '+att.Secret_Code__c + ' ' + Label.C501_ClassReg_CodeMessageDisclaim);
insert att;
}

Expand Down Expand Up @@ -347,6 +353,21 @@ public class C501_UTIL_ClassRegUtilities {
return page;
}

public static void logActivityToContact(Id contactId,String subject, String message,String messageType){
Task log = new Task(
Description = message,
WhoId = contactId,
Priority = 'Normal',
Subject = subject,
Status = 'Completed',
CallType = 'Outbound',
Type = messageType,
Activity_Report_Type__c = 'Programs',
ReminderDateTime = System.now()+1
);
insert log;
}

/*public void ObjectsFieldMerge(Account masterObject, List<Account> duplicateObjects){
Set<Id> mergeCandidates = new Set<Id> {
masterObject.Id
Expand Down
98 changes: 98 additions & 0 deletions src/labels/CustomLabels.labels
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomLabels xmlns="http://soap.sforce.com/2006/04/metadata">
<labels>
<fullName>C501_ClassReg_AND</fullName>
<language>en_US</language>
<protected>false</protected>
<shortDescription>C501_ClassReg_AND</shortDescription>
<value>and</value>
</labels>
<labels>
<fullName>C501_ClassReg_AddtlStudentInfo</fullName>
<language>en_US</language>
<protected>false</protected>
<shortDescription>C501_ClassReg_AddtlStudentInfo</shortDescription>
<value>Additional Student Information</value>
</labels>
<labels>
<fullName>C501_ClassReg_AuthToTreatMinor</fullName>
<language>en_US</language>
Expand Down Expand Up @@ -63,6 +77,20 @@
<shortDescription>C501_ClassReg_ChildSchoolRegion</shortDescription>
<value>Techbridge serves girls in four different regions. Which region is your child&apos;s school in?</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>
</labels>
<labels>
<fullName>C501_ClassReg_ConfirmCodeSubject</fullName>
<language>en_US</language>
<protected>false</protected>
<shortDescription>C501_ClassReg_ConfirmCodeSubject</shortDescription>
<value>Your Techbridge Girls Confirmation Code</value>
</labels>
<labels>
<fullName>C501_ClassReg_EvalStudy</fullName>
<language>en_US</language>
Expand Down Expand Up @@ -244,6 +272,13 @@ We may also look at your child’s school information, like attendance and cours
<shortDescription>C501_ClassReg_PhotoVideoP1</shortDescription>
<value>Occasionally, Techbridge Girls program activities may be photographed, videotaped, and/or audio taped for educational, publicity or fundraising purposes. Please indicate if you give permission for you and/or your child or ward to appear in videos, photos and/or audio recordings without compensation (e.g., as part of brochures, slide shows or program websites). Your authorization below also permits Techbridge Girls to share photos and other media depicting you and/or your child or ward with partner organizations for use in their promotions of Techbridge Girls events and programs.</value>
</labels>
<labels>
<fullName>C501_ClassReg_PlzSelectOne</fullName>
<language>en_US</language>
<protected>false</protected>
<shortDescription>C501_ClassReg_PlzSelectOne</shortDescription>
<value>Please Select One</value>
</labels>
<labels>
<fullName>C501_ClassReg_StudentID</fullName>
<language>en_US</language>
Expand All @@ -258,6 +293,13 @@ We may also look at your child’s school information, like attendance and cours
<shortDescription>C501_ClassReg_SubmitApplication</shortDescription>
<value>Submit Application</value>
</labels>
<labels>
<fullName>C501_ClassReg_WaiverRequired</fullName>
<language>en_US</language>
<protected>false</protected>
<shortDescription>C501_ClassReg_WaiverRequired</shortDescription>
<value>You must check the box to sign the Participant Waiver. This is not optional.</value>
</labels>
<labels>
<fullName>C501_ClassReg_dcArea</fullName>
<language>en_US</language>
Expand Down Expand Up @@ -335,13 +377,41 @@ We may also look at your child’s school information, like attendance and cours
<shortDescription>C501_RegSite_ConfirmMessageSite</shortDescription>
<value>We have received your application. We have sent a confirmation message to the Email Address or Phone Number you provided. A copy of your application is below. Feel free to save or print this for your records.</value>
</labels>
<labels>
<fullName>C501_RegSite_ConfirmSMS</fullName>
<language>en_US</language>
<protected>false</protected>
<shortDescription>C501_RegSite_ConfirmSMS</shortDescription>
<value>Thanks for registering for Techbridge Girls @</value>
</labels>
<labels>
<fullName>C501_RegSite_Continue</fullName>
<language>en_US</language>
<protected>false</protected>
<shortDescription>C501_RegSite_Continue</shortDescription>
<value>Continue</value>
</labels>
<labels>
<fullName>C501_RegSite_EmailConfirmP2</fullName>
<language>en_US</language>
<protected>false</protected>
<shortDescription>C501_RegSite_EmailConfirmP2</shortDescription>
<value>! The programs begins on</value>
</labels>
<labels>
<fullName>C501_RegSite_EmailConfirmP3</fullName>
<language>en_US</language>
<protected>false</protected>
<shortDescription>C501_RegSite_EmailConfirmP3</shortDescription>
<value>with</value>
</labels>
<labels>
<fullName>C501_RegSite_EmailConfirmP4</fullName>
<language>en_US</language>
<protected>false</protected>
<shortDescription>C501_RegSite_EmailConfirmP4</shortDescription>
<value>. Please contact the Techbridge Teacher at your school or community site for any questions.</value>
</labels>
<labels>
<fullName>C501_RegSite_FamilyInformation</fullName>
<language>en_US</language>
Expand Down Expand Up @@ -405,6 +475,13 @@ We may also look at your child’s school information, like attendance and cours
<shortDescription>C501_RegSite_NotProvided</shortDescription>
<value>Not provided</value>
</labels>
<labels>
<fullName>C501_RegSite_ParentContactRequired</fullName>
<language>en_US</language>
<protected>false</protected>
<shortDescription>C501_RegSite_ParentContactRequired</shortDescription>
<value>Please enter a contact method (phone number or email) for the parent. We need to be able to contact you!</value>
</labels>
<labels>
<fullName>C501_RegSite_ParentEmail</fullName>
<language>en_US</language>
Expand Down Expand Up @@ -440,6 +517,27 @@ 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_SelectGrade</fullName>
<language>en_US</language>
<protected>false</protected>
<shortDescription>C501_RegSite_SelectGrade</shortDescription>
<value>Please Select a Grade</value>
</labels>
<labels>
<fullName>C501_RegSite_SelectSchool</fullName>
<language>en_US</language>
<protected>false</protected>
<shortDescription>C501_RegSite_SelectSchool</shortDescription>
<value>Please Select a School</value>
</labels>
<labels>
<fullName>C501_RegSite_SelectState</fullName>
<language>en_US</language>
<protected>false</protected>
<shortDescription>C501_RegSite_SelectState</shortDescription>
<value>Please Select a State</value>
</labels>
<labels>
<fullName>C501_RegSite_SiteRegFormTitle</fullName>
<language>en_US</language>
Expand Down
Loading

0 comments on commit 3c0836c

Please sign in to comment.