Skip to content

Commit

Permalink
added report and dashboard to package, but no luck; phone number vali…
Browse files Browse the repository at this point in the history
…dation
  • Loading branch information
jonsayer committed Jul 16, 2019
1 parent 0d61f47 commit 349ee08
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 10 deletions.
93 changes: 93 additions & 0 deletions src/classes/C501_CTRL_ClassReg_CreateAcct.cls
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ public class C501_CTRL_ClassReg_CreateAcct {
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;
Expand All @@ -245,6 +246,96 @@ public class C501_CTRL_ClassReg_CreateAcct {
noWaiver = false;
}

Boolean phoneFail = false;

// Phone number validation
if(parent.MobilePhone != null){
String NAformat = C501_UTIL_ClassRegUtilities.NAformatPhone(parent.MobilePhone);
if(NAformat != null){
parent.MobilePhone = NAformat;
} else {
phoneFail = true;
parent.MobilePhone.addError(Label.C501_ClassReg_PhoneFailSpecific);
}
}
if(parent.HomePhone != null){
String NAformat = C501_UTIL_ClassRegUtilities.NAformatPhone(parent.HomePhone);
if(NAformat != null){
parent.HomePhone = NAformat;
} else {
phoneFail = true;
parent.HomePhone.addError(Label.C501_ClassReg_PhoneFailSpecific);
}
}
if(parent.OtherPhone != null){
String NAformat = C501_UTIL_ClassRegUtilities.NAformatPhone(parent.OtherPhone);
if(NAformat != null){
parent.OtherPhone = NAformat;
} else {
phoneFail = true;
parent.OtherPhone.addError(Label.C501_ClassReg_PhoneFailSpecific);
}
}
if(child.MobilePhone != null){
String NAformat = C501_UTIL_ClassRegUtilities.NAformatPhone(child.MobilePhone);
if(NAformat != null){
child.MobilePhone = NAformat;
} else {
phoneFail = true;
child.MobilePhone.addError(Label.C501_ClassReg_PhoneFailSpecific);
}
}
if(child.Alternate_Contact_Phone__c != null){
String NAformat = C501_UTIL_ClassRegUtilities.NAformatPhone(child.Alternate_Contact_Phone__c);
if(NAformat != null){
child.Alternate_Contact_Phone__c = NAformat;
} else {
phoneFail = true;
child.Alternate_Contact_Phone__c.addError(Label.C501_ClassReg_PhoneFailSpecific);
}
}
if(child.Emergency_Contact_2_Phone__c != null){
String NAformat = C501_UTIL_ClassRegUtilities.NAformatPhone(child.Emergency_Contact_2_Phone__c);
if(NAformat != null){
child.Emergency_Contact_2_Phone__c = NAformat;
} else {
phoneFail = true;
child.Emergency_Contact_2_Phone__c.addError(Label.C501_ClassReg_PhoneFailSpecific);
}
}
if(child.Authorized_Pickup_1_Phone__c != null){
String NAformat = C501_UTIL_ClassRegUtilities.NAformatPhone(child.Authorized_Pickup_1_Phone__c);
if(NAformat != null){
child.Authorized_Pickup_1_Phone__c = NAformat;
} else {
phoneFail = true;
child.Authorized_Pickup_1_Phone__c.addError(Label.C501_ClassReg_PhoneFailSpecific);
}
}
if(child.Authorized_Pickup_2_Phone__c != null){
String NAformat = C501_UTIL_ClassRegUtilities.NAformatPhone(child.Authorized_Pickup_2_Phone__c);
if(NAformat != null){
child.Authorized_Pickup_2_Phone__c = NAformat;
} else {
phoneFail = true;
child.Authorized_Pickup_2_Phone__c.addError(Label.C501_ClassReg_PhoneFailSpecific);
}
}
if(child.Authorized_Pickup_3_Phone__c != null){
String NAformat = C501_UTIL_ClassRegUtilities.NAformatPhone(child.Authorized_Pickup_3_Phone__c);
if(NAformat != null){
child.Authorized_Pickup_3_Phone__c = NAformat;
} else {
phoneFail = true;
child.Authorized_Pickup_3_Phone__c.addError(Label.C501_ClassReg_PhoneFailSpecific);
}
}

if(phoneFail){
passValidation = false;
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,Label.C501_ClassReg_PhoneFail) );
}

if(passValidation == false){
return null;
}
Expand All @@ -264,6 +355,7 @@ public class C501_CTRL_ClassReg_CreateAcct {
term.Student__c = child.Id;
term.Parent__c = parent.Id;
term.School__c = schoolName;
term.C501_Sign_Up_Source__c = 'Online';

schoolNameText = [Select id,
Name,
Expand All @@ -275,6 +367,7 @@ public class C501_CTRL_ClassReg_CreateAcct {
npe5__Contact__r.LastName
FROM npe5__Affiliations__r
WHERE npe5__Status__c = 'Current'
AND npe5__Role__c = 'Teacher'
)
from Account
where id = :schoolName];
Expand Down
15 changes: 15 additions & 0 deletions src/classes/C501_UTIL_ClassRegUtilities.cls
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,24 @@ public class C501_UTIL_ClassRegUtilities {
public static string cleanInputPhone(String input){
// to do: clean the string to make sure first number is not '1' and that there are 10 digits.
String output = input.replaceAll('[^0-9]', '');
if(output.left(1) == '1'){
output = output.right( output.length()-1 );
}
if(output.length() != 10){
return null;
}
return output;
}

public static string NAformatPhone(String input){
String output = cleanInputPhone(input);
if(output == null){
return null;
} else {
return '('+output.left(3)+') '+output.left(6).right(3)+'-'+output.right(4);
}
}

public static String generateRandomString(Integer len, Boolean includeNumbers,Boolean includeUppers,Boolean includeLowers) {
String chars = '';
if(includeNumbers){
Expand Down
14 changes: 14 additions & 0 deletions src/labels/CustomLabels.labels
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,20 @@ We may also look at your child’s school information, like attendance and cours
<shortDescription>C501_ClassReg_ParentWorkPhone</shortDescription>
<value>Parent/Guardian Work Phone</value>
</labels>
<labels>
<fullName>C501_ClassReg_PhoneFail</fullName>
<language>en_US</language>
<protected>false</protected>
<shortDescription>C501_ClassReg_PhoneFail</shortDescription>
<value>Please check the phone numbers you provided.</value>
</labels>
<labels>
<fullName>C501_ClassReg_PhoneFailSpecific</fullName>
<language>en_US</language>
<protected>false</protected>
<shortDescription>C501_ClassReg_PhoneFailSpecific</shortDescription>
<value>This not a valid phone number.</value>
</labels>
<labels>
<fullName>C501_ClassReg_PhotoVideo</fullName>
<language>en_US</language>
Expand Down
10 changes: 0 additions & 10 deletions src/objects/School_Term__c.object
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,6 @@
<default>true</default>
<label>Paper</label>
</value>
<value>
<fullName>byText</fullName>
<default>false</default>
<label>byText</label>
</value>
<value>
<fullName>byEmail</fullName>
<default>false</default>
<label>byEmail</label>
</value>
<value>
<fullName>Online</fullName>
<default>false</default>
Expand Down
10 changes: 10 additions & 0 deletions src/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@
<members>C501_ClassReg_ParentMobilePhone</members>
<members>C501_ClassReg_ParentWorkPhone</members>
<members>C501_ClassReg_ParentWorkPhone</members>
<members>C501_ClassReg_PhoneFail</members>
<members>C501_ClassReg_PhoneFailSpecific</members>
<members>C501_ClassReg_PhotoVideo</members>
<members>C501_ClassReg_PhotoVideoLabel</members>
<members>C501_ClassReg_PhotoVideoP1</members>
Expand Down Expand Up @@ -207,6 +209,10 @@
<members>TwilioConfig__c</members>
<name>CustomObject</name>
</types>
<types>
<members>Class_Registration_data</members>
<name>Dashboard</name>
</types>
<types>
<members>Account.C501_Class_Registration_Site_HH_Acct</members>
<members>Contact.C501_Class_Registration_Site_Child</members>
Expand All @@ -223,6 +229,10 @@
<members>School_Term__c.X2016_17_School_Terms</members>
<name>ListView</name>
</types>
<types>
<members>Class_Reg_s_by_Signup_Method_This_Year</members>
<name>Report</name>
</types>
<types>
<members>techbridgeLogo</members>
<name>StaticResource</name>
Expand Down

0 comments on commit 349ee08

Please sign in to comment.