-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
286 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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){ | ||
|
@@ -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 { | ||
|
@@ -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(); | ||
|
@@ -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; | ||
} | ||
|
@@ -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; | ||
} | ||
|
@@ -264,9 +316,4 @@ public class C501_CTRL_ClassReg_CreateAcct { | |
return schoolOptions; | ||
} | ||
|
||
/*public map<string,list<SelectOption>> contactFieldName2Options(){ | ||
}*/ | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'); | ||
|
@@ -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'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
} | ||
|
||
|
@@ -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]; | ||
|
||
|
@@ -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; | ||
} | ||
|
||
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.