#!/usr/bin/perl
# Kasra Meshkin May 1998 For HSL

require "cgi-lib.pl";

$time = localtime();
@tt = split(/ /,$time);
@pp = split(/:/,$tt[3]);

 
###&ReadParse(*cgi);
&parse_form;

$results = &PrintVariables(%cgi);
sub parse_form {

   # Get the input
   read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

   # Split the name-value pairs
   @pairs = split(/&/, $buffer);

   foreach $pair (@pairs) {
      ($name, $value) = split(/=/, $pair);

      $value =~ tr/+/ /;
      $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

      $cgi{$name} = $value;
   }
}
# load in the form contents

($agentname = $cgi{'agentname'}) =~ s/\n/ /g;
($amortization = $cgi{'amortization'}) =~ s/\n/ /g;
($amount = $cgi{'amount'}) =~ s/\n/ /g;
($borrowerfirstname = $cgi{'borrowerfirstname'}) =~ s/\n/ /g;
($RHLastName = $cgi{'RHLastName'}) =~ s/\n/ /g;
($borrowersin = $cgi{'borrowersin'}) =~ s/\n/ /g;
($borroweraddress= $cgi{'borroweraddress'}) =~ s/\n/ /g;
($borrowercity = $cgi{'borrowercity'}) =~ s/\n/ /g;
($borrowerprovince = $cgi{'borrowerprovince'}) =~ s/\n/ /g;
($secaddress = $cgi{'secaddress'}) =~ s/\n/ /g;
($dischargedmonth = $cgi{'dischargedmonth'}) =~ s/\n/ /g;
($dischargedday = $cgi{'dischargedday'}) =~ s/\n/ /g;
($dischargedyear = $cgi{'dischargedyear'}) =~ s/\n/ /g;
($JOFirstName = $cgi{'JOFirstName'}) =~ s/\n/ /g;
($JOLastName = $cgi{'JOLastName'}) =~ s/\n/ /g;
($coborrower = $cgi{'coborrower'}) =~ s/\n/ /g;
($corrowersin = $cgi{'JOSIN'}) =~ s/\n/ /g;
($corroweraddress = $cgi{'corroweraddress'}) =~ s/\n/ /g;
($corrowercity = $cgi{'corrowercity'}) =~ s/\n/ /g;
($corrowerprovince = $cgi{'corrowerprovince'}) =~ s/\n/ /g;
($JOHomePhArea = $cgi{'JOHomePhArea'}) =~ s/\n/ /g;
($JOHomePhPrefix = $cgi{'JOHomePhPrefix'}) =~ s/\n/ /g;
($JOHomePhPost = $cgi{'JOHomePhPost'}) =~ s/\n/ /g;
($downpayment = $cgi{'downpayment'}) =~ s/\n/ /g;
($title = $cgi{'RHTitle'}) =~ s/\n/ /g;
#($repname= $repname) =~ s/\n/ /g;
($interestrate= $cgi{'interestrate'}) =~ s/\n/ /g;

$repname = "other";

($RHHomePhArea = $cgi{'RHHomePhArea'}) =~ s/\n/ /g;
($RHTitle = $cgi{'RHTitle'}) =~ s/\n/ /g;

($RHHomePhPrefix = $cgi{'RHHomePhPrefix'}) =~ s/\n/ /g;
($RHHomePhPost = $cgi{'RHHomePhPost'}) =~ s/\n/ /g;
($RHDBmonth = $cgi{'RHDBmonth'}) =~ s/\n/ /g;
($RHDBday = $cgi{'RHDBday'}) =~ s/\n/ /g;
($RHDByear = $cgi{'RHDByear'}) =~ s/\n/ /g;
($RHAddress = $cgi{'RHAddress'}) =~ s/\n/ /g;
($RHApt = $cgi{'RHApt'}) =~ s/\n/ /g;
($RHCity = $cgi{'RHCity'}) =~ s/\n/ /g;
($RHPCode = $cgi{'RHPCode'}) =~ s/\n/ /g;
($RHSIN = $cgi{'RHSIN'}) =~ s/\n/ /g;
($JOTitle = $cgi{'JOTitle'}) =~ s/\n/ /g;



($RHFirstName = $cgi{'RHFirstName'}) =~ s/\n/ /g;
($RHLastName = $cgi{'RHLastName'}) =~ s/\n/ /g;

($JOHomePhArea = $cgi{'JOHomePhArea'}) =~ s/\n/ /g;
($JOHomePhPrefix = $cgi{'JOHomePhPrefix'}) =~ s/\n/ /g;
($JOHomePhPost = $cgi{'JOHomePhPost'}) =~ s/\n/ /g;
($JODBmonth = $cgi{'JODBmonth'}) =~ s/\n/ /g;
($JODBday = $cgi{'JODBday'}) =~ s/\n/ /g;
($JODByear = $cgi{'JODByear'}) =~ s/\n/ /g;
($JOSIN = $cgi{'JOSIN'}) =~ s/[\r\n]/ /g;
($JOAddress = $cgi{'JOAddress'}) =~ s/\n/ /g;
($dicamount = $cgi{'dicamount'}) =~ s/\n/ /g;
($codamount = $cgi{'codamount'}) =~ s/\n/ /g;
($certificate = $cgi{'certificate'}) =~ s/\n/ /g;
($interestrate = $cgi{'interestrate'}) =~ s/\n/ /g;
($corroweraddress = $cgi{'JOAddress'}) =~ s/\n/ /g;
($corrowercity = $cgi{'JOCity'}) =~ s/\n/ /g;
($JOPCode = $cgi{'JOPCode'}) =~ s/\n/ /g;
($agree = $cgi{'yes'}) =~ s/\n/ g/;





@SIN = split(//,$RHSIN);


$B1 = $SIN[1] + $SIN[1];$B2 = $SIN[3] + $SIN[3];$B3 = $SIN[5] + $SIN[5];$B4 = $SIN[7] + $SIN[7];if($B1 < 9) { 	$X1 = $B1;} elsif(2>1) {	$X1 = $B1 - 9;}if($B2 < 9) { 	$X2 = $B2;} elsif(2>1) {	$X2 = $B2 - 9;}if($B3 < 9) { 	$X3 = $B3;} elsif(2>1) {	$X3 = $B3 - 9;}if($B4 < 9) { 	$X4 = $B4;} elsif(2>1) {	$X4 = $B4 - 9;}$SUM = $SIN[0]+$SIN[2]+$SIN[4]+$SIN[6]+$X1+$X2+$X3+$X4;

$KUM = $SUM + 0;
$SUM = 10 - $SUM;$SUM = $SUM %10;if($SUM !~ $SIN[8]) {
        &myerror("S.I.N NUMBER $borrowersin is Invalid.\n");



# if the SIN is more than 0 and less than 9 means any digit check and report error } elsif((length($borrowersin) < 9) && (length($borrowersin) > 0 )){
        &myerror("Social Insurance Number must be nine digits.\n");
}


#==========================================


@SON = split(//,$JOSIN);


$Bk1 = $SON[1] + $SON[1];$Bk2 = $SON[3] + $SON[3];$Bk3 = $SON[5] + $SON[5];$Bk4 = $SON[7] + $SON[7];if($Bk1 < 9) { 	$Xk1 = $Bk1;} elsif(2>1) {	$Xk1 = $Bk1 - 9;}if($Bk2 < 9) { 	$Xk2 = $Bk2;} elsif(2>1) {	$Xk2 = $Bk2 - 9;}if($Bk3 < 9) { 	$Xk3 = $Bk3;} elsif(2>1) {	$Xk3 = $Bk3 - 9;}if($Bk4 < 9) { 	$Xk4 = $Bk4;} elsif(2>1) {	$Xk4 = $Bk4 - 9;}$SkUM = $SON[0]+$SON[2]+$SON[4]+$SON[6]+$Xk1+$Xk2+$Xk3+$Xk4;

$KkUM = $SkUM + 0;
$SkUM = 10 - $SkUM;$SkUM = $SkUM %10;







# do any error checking here
if(($cgi{'individual'}=~/agent/) && ( length($agentname) < 1 )){
        &myerror("You didn't enter Agent Information.\n");




} elsif(length($RHFirstName) < 1){
        &myerror("First Name is missing.\n");

} elsif(length($RHLastName) < 1){
        &myerror("Last Name is missing.\n");

} elsif(length($RHHomePhArea) < 1){
        &myerror("Residence Telephone Area Code is missing.\n");

} elsif(length($RHHomePhPrefix) < 3){
        &myerror("Residence Telephone first three digits are missing.\n");

} elsif(length($RHHomePhPost) < 4){
        &myerror("Residence Telephone last four digits are missing.\n");



} elsif(length($RHDBmonth) < 1){
        &myerror("You did not enter Birth Month.\n");

} elsif(length($RHDBday) < 1){
        &myerror("You did not enter Birth Day.\n");

} elsif(length($RHDByear) < 1){
        &myerror("You did not enter Birth Year.\n");


# ============================================================
# check for correct birtday year. 1- can not be less than four digits 2- can no be in the future 3- can not be less than 1848
# =============================================================
} elsif(length($RHDByear) < 4){
        &myerror("Birthday Year must be four digits.\n");

} elsif ($RHDByear > 1998) {
        &myerror("Birth Year can not be in the future\n");

} elsif ($RHDByear < 1848) {
        &myerror("Birth Year can not be less than 1848 - NOT on Earth :-).\n");

# ============================================================
# check month - can not be less than 1 and more than 12
# ============================================================

} elsif($RHDBmonth < 1){
        &myerror("Month of birth can not be 0.\n");
} elsif($RHDBmonth > 12){
        &myerror("Month of birth is invalid.\n");

# ============================================================
# check day - can not be less than 1 and more that 31
# ============================================================

} elsif($RHDBday < 1){
        &myerror("Day of birth can not be 0.\n");
} elsif($RHDBday > 31){
        &myerror("Day of birth is invalid.\n");



} elsif(length($RHSIN) < 1){
        &myerror("Social Insurance Number is missing.\n");


} elsif(length($RHAddress) < 1){
        &myerror("Address is missing.\n");


} elsif(length($RHCity) < 1){
        &myerror("Borrower's City is missing.\n");



} elsif(length($RHDBmonth) < 1){
        &myerror("You did not enter Birth Month.\n");

} elsif(length($RHDBday) < 1){
        &myerror("You did not enter Birth Day.\n");

} elsif(length($RHDByear) < 1){
        &myerror("You did not enter Birth Year.\n");


} elsif(($cgi{'coborrower'}=~/on/) && (length($JOFirstName) < 1)){
        &myerror("CONTRIBUTOR First Name is missing.\n");

} elsif(($cgi{'coborrower'}=~/on/) && (length($JOLastName) < 1)){
        &myerror("CONTRIBUTOR Last Name is missing.\n");


} elsif(($cgi{'coborrower'}=~/on/) && (length($JOHomePhArea) < 1)){
        &myerror("CONTRIBUTOR'S Residence Telephone Area Code is missing.\n");

} elsif(($cgi{'coborrower'}=~/on/) && (length($JOHomePhPrefix) < 3)){
        &myerror("CONTRIBUTOR'S Residence Telephone first three digits are missing.\n");

} elsif(($cgi{'coborrower'}=~/on/) && (length($JOHomePhPost) < 4)){
        &myerror("CCONTRIBUTOR'S Residence Telephone last four digits are missing.\n");



} elsif(($cgi{'coborrower'}=~/on/) && (length($corrowersin) < 1)){
        &myerror("CONTRIBUTOR  Social Insurance Number is missing.\n");

} elsif(($SkUM !~ $SON[8]) && ($cgi{'coborrower'}=~/on/)){
        &myerror("CONTRIBUTOR  S.I.N NUMBER $corrowersin is Invalid.\n");



} elsif(($cgi{'coborrower'}=~/on/) && (length($corrowersin) < 9)){
        &myerror("CONTRIBUTOR  Social Insurance Number must be nine $skUM digits.\n");



} elsif(($cgi{'coborrower'}=~/on/) && (length($corrowersin) < 1)){
        &myerror("CONTRIBUTOR  Social Insurance Number is missing.\n");



} elsif(($cgi{'coborrower'}=~/on/) && (length($JODBmonth) < 1)){
        &myerror("CONTRIBUTOR 's Birth Month is missing.\n");


} elsif(($cgi{'coborrower'}=~/on/) && (length($JODBday) < 1)){
        &myerror("CONTRIBUTOR 's Birth Day is missing.\n");

} elsif(($cgi{'coborrower'}=~/on/) && (length($JODByear) < 1)){
        &myerror("CONTRIBUTOR 's Birth Year is missing.\n");


# ============================================================
# check for correct birtday year. C0-BORROWER
# =============================================================
} elsif(($cgi{'coborrower'}=~/on/) && ($JODByear < 4)){
        &myerror("CONTRIBUTOR 's Birthday Year must be four digits.\n");

} elsif(($cgi{'coborrower'}=~/on/) && ($JODByear > 1998)){
        &myerror("CONTRIBUTOR 's Birth Year can not be in the future\n");

} elsif(($cgi{'coborrower'}=~/on/) && ($JODByear < 1848)){
        &myerror("CONTRIBUTOR 's Birth Year can not be less than 1848 - NOT on Earth :-).\n");

# ============================================================
# check month - can not be less than 1 and more than 12 C0-BORROWER
# ============================================================

} elsif(($cgi{'coborrower'}=~/on/) && ($JODBmonth < 1)){
        &myerror("CONTRIBUTOR 's Month of birth can not be 0.\n");

} elsif(($cgi{'coborrower'}=~/on/) && ($JODBmonth > 12)){
        &myerror("CONTRIBUTOR 's Month of birth is invalid.\n");


# ============================================================
# check day - can not be less than 1 and more that 31 C0-BORROWER
# ============================================================

} elsif(($cgi{'coborrower'}=~/on/) && ($JODBday < 1)){
        &myerror("CONTRIBUTOR 's Day of birth can not be 0.\n");

} elsif(($cgi{'coborrower'}=~/on/) && ($JODBday > 31)){
        &myerror("CONTRIBUTOR 's Day of birth is invalid.\n");

# ========================================


} elsif(($cgi{'coborrower'}=~/on/) && (length($corroweraddress) < 1)){
        &myerror("CONTRIBUTOR'S Address is missing.\n");


} elsif(($cgi{'coborrower'}=~/on/) && (length($corrowercity) < 1)){
        &myerror("CONTRIBUTOR'S City is missing.\n");






} elsif(length($amount) < 1){
        &myerror("You did not enter Amount.\n");

} elsif($amount < 1){
       &myerror("Amount can not be 0\n");

} elsif($amount < 1000){
       &myerror("Amount can not be less than 1000.00\n");

} elsif($amount > 60000){
       &myerror("Amount can not be more than 60000.00\n");


} elsif(length($interestrate) < 1){
        &myerror("You did not enter Interest Rate.\n");

} elsif($interestrate < 1){
       &myerror("Interest Rate can not be 0\n");




#===================================
# Agree sign
#======================================


} elsif($cgi{'agree'}!~/yes/){
        &myerror("You must agree to the Terms And Conditions before you submit this form.<br>Please read them carefully and resubmit the form.\n");




}
sub myerror {
   
     $errstr = shift @_;
        printf("%s", &PrintHeader);
	
     # print "testing $RHDBysplit";  

print <<EOF;

<center>
<h2><font color=#ff0000> The following information is required to process your application</h2></font>
<hr>
<table border=2 bgcolor=#fffddf cellpadding=5 cellborder=0><tr><td align=center>
<font face=arial color=blue>
<b>$errstr</b>
</font>
</td></tr></table>
<p>
Please close this window to return to the application form and complete all of the required information.  Thank you.
</center>
EOF

        exit;
}



# ====St. cath===========================================================================

if(($cgi{'branch'}=~/stcatharines/) && ($cgi{'individual'}!~/agent/)) {

#===================================================
# Now display info on the screen
#===================================================
printf("%s", &PrintHeader);
printf("<BODY bgcolor=\"#ffffff\"> \n");
printf("<center><H2> \n");


printf("<h2>Thank you $title. $RHFirstName $RHLastName.</h2> \n");
printf("<h4>Your application has been submitted to Home Savings & Loan Corp., St.Catharines.</h4>\n");
printf("<BR>\n");


if($cgi{'renewal'}=~/on/){
printf("<h4>15 day rate guarantee - The effective interest rate will be the higher of the rate on the\n");
printf("interest rate sheet that you have received or will receive, or the rate in effect on the day of maturity</h4>\n");
}

print "$mas<br>";
print "Your Reference Number is <font size=+1 color=#ff0000>$pp[0]RRSP$pp[1]$pp[2]</font><br>";
print "<h4>Should you need to correspond with us please refer to this number</h4>";
print "<h3>Please send your cheque along with your reference number to:<br></h3>";

print "<h4>";
print "Home Savings & Loan<br>"; 
print "15 Church Street, Suite 100<br>";
print "P.O. Box 1554<br>";
print "St. Catharines, Ontario<br>";
print "L2R 7J9<br><br>";

print "For mail-in applications, these rates remain active up to two business days from the Submission date<br>"; 
printf("<h4>Submission Date: $tt[1]-$tt[2]-$tt[4]</h4>\n");
print "<h4>To check the status of your application please contact:<br></h4>";

print "Telephone: 905-688-3131<br>";
print "Fax: 905-688-0534<br>";
print "Your Representative is <font size=+1 color=#ff0000> Donna Anderson</font>";
print "</font>";

}



# =====Hamilton======================================================================================


elsif(($cgi{'branch'}=~/hamilton/) && ($cgi{'individual'}!~/agent/)) {  

#===================================================
# Now display info on the screen
#===================================================
printf("%s", &PrintHeader);
printf("<BODY bgcolor=\"#ffffff\"> \n");
printf("<center><H2> \n");

printf("<h2>Thank you $title. $RHFirstName $RHLastName.</h2> \n");
printf("<h4>Your application has been submitted to Home Savings & Loan Corp., Hamilton.</h4>\n");
printf("<BR>\n");


if($cgi{'renewal'}=~/on/){
printf("<h4>15 day rate guarantee - The effective interest rate will be the higher of the rate on the\n");
printf("interest rate sheet that you have received or will receive, or the rate in effect on the day of maturity</h4>\n");
}
print "$mas<br>";
print "Your Reference Number is <font size=+1 color=#ff0000>$pp[0]RRSP$pp[1]$pp[2]</font><br>";
print "<h4>Should you need to correspond with us please refer to this number</h4>";
print "<h3>Please send your cheque along with your reference number to:<br></h3>";

print "<h4>";
print "Home Savings & Loan<br>"; 
print "CIBC Phase II<br>";
print "21 King Street West, Suite 800<br>";
print "Hamilton, Ontario<br>";
print "L8P 4W7<br><br>";

print "For mail-in applications, these rates remain active up to two business days from the Submission date<br>"; 
printf("<h4>Submission Date: $tt[1]-$tt[2]-$tt[4]</h4>\n");
print "<h4>To check the status of your application please contact:<br></h4>";
print "Toll Free: 1-800-944-3419<br>";
print "Telephone: 905-522-0250<br>";
print "Fax: 905-522-1888 <br>";
print "Your Representative is <font size=+1 color=#ff0000> Maria Ongaro</font>";
print "</font>";

}

# =====Toronto======================================================================================


elsif(($cgi{'branch'}=~/toronto/) && ($cgi{'individual'}!~/agent/)) {         

#===================================================
# Now display info on the screen
#===================================================
printf("%s", &PrintHeader);
printf("<BODY bgcolor=\"#ffffff\"> \n");



printf("<center><H2> \n");

printf("<h2>Thank you $title. $RHFirstName $RHLastName.</h2> \n");
printf("<h4>Your application has been submitted to Home Savings & Loan Corp., Toronto.</h4>\n");

if($cgi{'renewal'}=~/on/){
printf("<h4>15 day rate guarantee - The effective interest rate will be the higher of the rate on the\n");
printf("interest rate sheet that you have received or will receive, or the rate in effect on the day of maturity</h4>\n");
}

print "$mas<br>";
print "Your Reference Number is <font size=+1 color=#ff0000>$pp[0]RRSP$pp[1]$pp[2]</font><br>";
print "<h4>Should you need to correspond with us please refer to this number</h4>";
print "<h3>Please send your cheque along with your reference number to:<br></h3>";

print"<h4>";
print "Home Savings & Loan<br>"; 
print "145 King Street West, Suite 1910<br>";
print "Toronto, Ontario<br>";
print "M5H 1J8<br>";

print "For mail-in applications, these rates remain active up to two business days from the Submission date<br>"; 
printf("<h4>Submission Date: $tt[1]-$tt[2]-$tt[4]</h4>\n");
print "<h4>To check the status of your application please contact:<br></h4>";
print "Toll Free: 1-800-990-7881<br>";
print "Telephone: 416-360-4663<br>";
print "Fax: 416-363-7611<br>";
print "Your Representative is <font size=+1 color=#ff0000> Marion Samler</font>";


print "</font>";
}


#========================================================

# SECOND OPTION


#====================================================
if($cgi{'individual'}=~/agent/) {  




#===================================================
# Now display info on the screen
#===================================================
printf("%s", &PrintHeader);
printf("<BODY bgcolor=\"#ffffff\"> \n");
printf("<center><H2> \n");


printf("<h2>Thank you $agentname $agentnumber.</h2> \n");

printf("<h4>Submission Date: $tt[1]-$tt[2]-$tt[4]</h4>\n");




if($repname=~/mariao/) {
printf("<h4>Your   application has been submitted to Home Savings & Loan Corp., HAMILTON.</h4>\n");
printf("<BR>\n");

}elsif(($repname=~/other/) && ($cgi{'branch'}=~/hamilton/)){
printf("<h4>Your   application has been submitted to Home Savings & Loan Corp., HAMILTON.</h4>\n");
printf("<BR>\n");



}elsif(($repname=~/other/) && ($cgi{'branch'}=~/toronto/)){
printf("<h4>Your   application has been submitted to Home Savings & Loan Corp., TORONTO.</h4>\n");
printf("<BR>\n");


}elsif(($repname=~/other/) && ($cgi{'branch'}=~/stcatharines/)){
printf("<h4>Your   application has been submitted to Home Savings & Loan Corp., ST. CATH.</h4>\n");
printf("<BR>\n");


}



print "$mas<br>";
print "Your Reference Number is <font size=+1 color=#ff0000>$pp[0]RRSP$pp[1]$pp[2]</font><br>";
print "<h4>Should you need to correspond with us please refer to this number</h4>";
print "<h3>A representative will contact you within one business day from the submission date<br></h3>";

print "<h4>If you need to contact us regarding your application, please contact:<br></h4>"; 



if($repname=~/donnaa/) {


print"<h4>";
print "Home Savings & Loan<br>"; 
print "15 Church Street, Suite 100<br>";
print "P.O. Box 1554<br>";
print "St. Catharines, Ontario<br>";
print "L2R 7J9<br><br>";
print "For mail-in applications, these rates remain active up to two business days from the Submission date<br>"; 
printf("<h4>Submission Date: $tt[1]-$tt[2]-$tt[4]</h4>\n");
print "<h4>To check the status of your application please contact:<br></h4>";
print "Telephone: 905-688-3131<br>";
print "Fax: 905-688-0534<br>";
print "Your Representative is <font size=+1 color=#ff0000> Donna Anderson</font>";
print "</font>";



}elsif(($repname=~/other/) && ($cgi{'branch'}=~/stcatharines/)){

print"<h4>";
print "Home Savings & Loan<br>"; 
print "15 Church Street, Suite 100<br>";
print "P.O. Box 1554<br>";
print "St. Catharines, Ontario<br>";
print "L2R 7J9<br><br>";
print "For mail-in applications, these rates remain active up to two business days from the Submission date<br>"; 
printf("<h4>Submission Date: $tt[1]-$tt[2]-$tt[4]</h4>\n");
print "<h4>To check the status of your application please contact:<br></h4>";
print "Telephone: 905-688-3131<br>";
print "Fax: 905-688-0534<br>";
print "Your Representative is <font size=+1 color=#ff0000> Donna Anderson</font>";
print "</font>";


}elsif(($repname=~/other/) && ($cgi{'branch'}=~/hamilton/)){

print"<h4>";
print "Home Savings & Loan<br>"; 
print "CIBC Phase II<br>";
print "21 King Street West, Suite 800<br>";
print "Hamilton, Ontario<br>";
print "L8P 4W7<br><br>";
print "For mail-in applications, these rates remain active up to two business days from the Submission date<br>"; 
printf("<h4>Submission Date: $tt[1]-$tt[2]-$tt[4]</h4>\n");
print "<h4>To check the status of your application please contact:<br></h4>";
print "Toll Free: 1-800-944-3419<br>";
print "Telephone: 905-522-0250<br>";
print "Fax: 905-522-1888 <br>";
print "Your Representative is <font size=+1 color=#ff0000> Maria Ongaro</font>";
print "</font>";


}elsif(($repname=~/other/) && ($cgi{'branch'}=~/toronto/)){
print"<h4>";
print "Home Savings & Loan<br>"; 
print "145 King Street West, Suite 1910<br>";
print "Toronto, Ontario<br>";
print "M5H 1J8<br>";

print "For mail-in applications, these rates remain active up to two business days from the Submission date<br>"; 
printf("<h4>Submission Date: $tt[1]-$tt[2]-$tt[4]</h4>\n");
print "<h4>To check the status of your application please contact:<br></h4>";
print "Toll Free: 1-800-990-7881<br>";
print "Telephone: 416-360-4663<br>";
print "Fax: 416-363-7611<br>";
print "Your Representative is <font size=+1 color=#ff0000> Marion Samler</font>";


print "</font>";





}

if($repname=~/nickk/){
print "Your Representative is <font size=+1 color=#ff0000> Nick Kyprianou</font>";


}elsif($repname=~/jimh/){
print "Your Representative is <font size=+1 color=#ff0000> Jim Hill</font>";



}

}

#===================================================
# TO ALL
#===================================================

if(($cgi{'branch'}=~/stcatharines/) && ($cgi{'individual'}!~/agent/)) {

open(MAIL, "| /usr/lib/sendmail kasra\@ezenet.com,kasra\@ezenet.com");
printf(MAIL "Subject: $cgi{'RHLastName'} - $tt[1]$tt[2]$tt[4] --- $pp[0]RRSP$pp[1]$pp[2] St-CATH\n");
printf(MAIL "From: RRSP\-ONLINE\@EZENET\n\n");

}elsif(($cgi{'branch'}=~/hamilton/) && ($cgi{'individual'}!~/agent/)) {   

open(MAIL, "| /usr/lib/sendmail kasra\@ezenet.com,kasra\@ezenet.com");
printf(MAIL "Subject: $cgi{'RHLastName'} - $tt[1]$tt[2]$tt[4] --- $pp[0]RRSP$pp[1]$pp[2] HAMILTON\n");
printf(MAIL "From: RRSP\-ONLINE\@EZENET\n\n");

 
}elsif(($cgi{'branch'}=~/toronto/) && ($cgi{'individual'}!~/agent/)) {   
open(MAIL, "| /usr/lib/sendmail kasra\@ezenet.com,kasra\@ezenet.com");
printf(MAIL "Subject: $cgi{'RHLastName'} - $tt[1]$tt[2]$tt[4] --- $pp[0]RRSP$pp[1]$pp[2] TORONTO\n");
printf(MAIL "From: RRSP\-ONLINE\@EZENET\n\n");




}elsif(($repname=~/other/) && ($cgi{'branch'}=~/hamilton/)){

#open(MAIL, "| /usr/lib/sendmail margr\@ezenet.com,kasra\@ezenet.com");
open(MAIL, "| /usr/lib/sendmail kasra\@ezenet.com,kasra\@ezenet.com");
printf(MAIL "Subject: $cgi{'RHLastName'} - $tt[1]$tt[2]$tt[4] --- $pp[0]RRSP$pp[1]$pp[2] HAMILTON-AGENT\n");
printf(MAIL "From: RRSP\-ONLINE\@EZENET\n\n");

# ===================== TORONTO EMAIL


}elsif(($repname=~/other/) && ($cgi{'branch'}=~/toronto/)){

#open(MAIL, "| /usr/lib/sendmail jimh\@ezenet.com,kasra\@ezenet.com");
open(MAIL, "| /usr/lib/sendmail kasra\@ezenet.com,kasra\@ezenet.com");
printf(MAIL "Subject: $cgi{'RHLastName'} - $tt[1]$tt[2]$tt[4] --- $pp[0]RRSP$pp[1]$pp[2] TORONTO-AGENT\n");
printf(MAIL "From: RRSP\-ONLINE\@EZENET\n\n");


# =============== ST.CATH SHOOT 

}elsif(($repname=~/other/) && ($cgi{'branch'}=~/stcatharines/)){
#open(MAIL, "| /usr/lib/sendmail wolfs\@ezenet.com,kasra\@ezenet.com");
open(MAIL, "| /usr/lib/sendmail kasra\@ezenet.com,kasra\@ezenet.com");
printf(MAIL "Subject: $cgi{'RHLastName'} - $tt[1]$tt[2]$tt[4] --- $pp[0]RRSP$pp[1]$pp[2] ST.CATH-AGENT\n");
printf(MAIL "From: RRSP\-ONLINE\@EZENET\n\n");


#}

#}



}

printf(MAIL "==================ONLINE RRSP==================\n\n");
printf(MAIL "Submittion Date: $tt[1]-$tt[2]-$tt[4]\n");
printf(MAIL "REF: $tt[1]$tt[2]$tt[4] --- $pp[0]RRSP$pp[1]$pp[2]\n");

if($cgi{'individual'}=~/agent/){
printf(MAIL "Filled by : AGENT\n AGENT NAME: $agentname\n NUMBER: $cgi{'agentnumber'}\n\n");

}elsif($cgi{'individual'}!~/agent/){
        printf(MAIL "Filled by : INDIVIDUAL\n\n");
}



printf(MAIL "====================APPLICANT'S INFO============================\n\n");







printf(MAIL "APPLICANT: $cgi{'title'} $cgi{'borrowerfirstname'} $cgi{'RHLastName'} \n");
printf(MAIL "DATE OF BIRTH: $RHDBmonth-$RHDBday-$RHDByear (mm/dd/yyyy)\n");
printf(MAIL "Marital status: $cgi{'borrowermaritalstatus'}\n");
printf(MAIL "No. of dependents: $cgi{'borrowerdependents'}\n");
printf(MAIL "Drivers Licence Number: $cgi{'borrowerdriverlic'}\n");
printf(MAIL "Social Insurance Number: $borrowersin\n");
printf(MAIL "Address: $cgi{'borroweraddress'}, $cgi{'borrowercity'}, $cgi{'borrowerprovince'}, $cgi{'borrowerpostal'}\n");
printf(MAIL "How long at address: $cgi{'borrowerhowlong'}\n");
printf(MAIL "Residence telephone: $RHHomePhArea-$RHHomePhPrefix-$RHHomePhPost\n");
printf(MAIL "Business telephone: $cgi{'borrowerbusphone'}\n");
printf(MAIL "Any judgments or legal proceedings? $cgi{'proceedings'}\n");
printf(MAIL "Declared bankruptcy? $cgi{'bankrupty'} - Date Discharged: $cgi{'dischargedmonth'}-$cgi{'dischargedday'}-$cgi{'dischargedyear'}\n\n");

printf(MAIL "==========Employment Information==============\n");
printf(MAIL "Name and address of employer: $cgi{'ename'}\n");
printf(MAIL "Business telephone: $cgi{'enumber'}\n");
printf(MAIL "Years there: $cgi{'eyears'}\n");
printf(MAIL "Occupation/Position: $cgi{'eoccupation'}\n");
printf(MAIL "Present annual salary / wages : $cgi{'eannual'}\n");
printf(MAIL "Other Income: $cgi{'eotherincome'}\n\n");


printf(MAIL "================DETAILS OF RRSP================\n");

printf(MAIL "Term and type: $cgi{'term'}\n");

printf(MAIL "Date funds required by: $cgi{'daterequired'}\n");
printf(MAIL "Amortization: $cgi{'amortization'}\n");

printf(MAIL "Loan amount requested: $cgi{'loanamount'}\n");
printf(MAIL "Interest rate: $cgi{'interestrate'}\n");
printf(MAIL "Nature of RRSP: $cgi{'nature'}\n");
printf(MAIL "Payment frequency: $cgi{'frequency'}\n\n");



printf(MAIL "================CONTRIBUTOR  INFORMATION===============\n");

printf(MAIL "APPLICANT: $cgi{'cotitle'} $cgi{'corrowerfirstname'} $cgi{'coborrowerlastname'} \n");
printf(MAIL "DATE OF BIRTH: $JODBmonth-$JODBBday-$JODByear (mm/dd/yyyy)\n");
printf(MAIL "Marital status: $cgi{'corrowermaritalstatus'}\n");
printf(MAIL "No. of dependents: $cgi{'corrowerdependents'}\n");
printf(MAIL "Drivers Licence Number: $cgi{'corrowerlic'}\n");
printf(MAIL "Social Insurance Number: $cgi{'corrowersin'}\n");
printf(MAIL "Address: $cgi{'corroweraddress'}, $cgi{'corrowercity'}, $cgi{'corrowerprovince'}, $cgi{'corrowerpostal'}\n");
printf(MAIL "How long at address: $cgi{'corrowerhowlong'}\n");

printf(MAIL "Residence telephone: $JOHomePhArea-$JOHomePhPrefix-$JOHomePhPost\n");
printf(MAIL "Business telephone: $cgi{'corrowerbusphone'}\n\n");


printf(MAIL "==========Employment Information==============\n");
printf(MAIL "Name and address of employer: $cgi{'econame'}\n");
printf(MAIL "Business telephone: $cgi{'econumber'}\n");
printf(MAIL "Years there: $cgi{'ecoyears'}\n");
printf(MAIL "Occupation/Position: $cgi{'ecooccupation'}\n");
printf(MAIL "Present annual salary / wages : $cgi{'ecoannual'}\n");
printf(MAIL "Other Income: $cgi{'ecootherincome'}\n\n");


printf(MAIL "============BANK REFRENCE===================\n");
printf(MAIL "Bank Name: $cgi{'bankname'}\n");
printf(MAIL "Branch/Address: $cgi{'bankaddress'}\n");
printf(MAIL "Account Number: $cgi{'accountnumber'}\n");
printf(MAIL "Account Type: $cgi{'accounttype'}\n\n");


printf(MAIL "============FINANCIAL INFORMATION===================\n");
printf(MAIL "ASSETS:\n");

printf(MAIL "Motor Vehicle #1: $cgi{'carmake1'} - Year: $cgi{'caryear1'} - Amount: $cgi{'carvalue1'}\n");
printf(MAIL "Motor Vehicle #2: $cgi{'carmake2'} - Year: $cgi{'caryear2'} - Amount: $cgi{'carvalue2'}\n");
printf(MAIL "Other Real Estate: $cgi{'otherrealestate'} - Amount: $cgi{'otherrealestatevalue'}\n");
printf(MAIL "Stocks: $cgi{'stocks'} - Amount: $cgi{'stocksvalue'}\n");
printf(MAIL "Bonds, Cash: $cgi{'bondscash'} - Amount: $cgi{'bondscashvalue'}\n");
printf(MAIL "Other Assets: $cgi{'otherassets'} - Amount: $cgi{'otherassetsvalue'}\n\n");


printf(MAIL "TOTAL ASSETS: $cgi{'totalassets'}\n\n");

printf(MAIL "LIABILITIES:\n");

printf(MAIL "1\n");
printf(MAIL "Name: $cgi{'lname'}\n");
printf(MAIL "Address: $cgi{'ladd'}\n");
printf(MAIL "Balance: $cgi{'bal'}\n");
printf(MAIL "Monthly Payment: $cgi{'mop'}\n\n");


printf(MAIL "2\n");
printf(MAIL "Name: $cgi{'lname2'}\n");
printf(MAIL "Address: $cgi{'ladd2'}\n");
printf(MAIL "Balance: $cgi{'bal2'}\n");
printf(MAIL "Monthly Payment: $cgi{'mop2'}\n\n");


printf(MAIL "3\n");
printf(MAIL "Name: $cgi{'lname3'}\n");
printf(MAIL "Address: $cgi{'ladd3'}\n");
printf(MAIL "Balance: $cgi{'bal3'}\n");
printf(MAIL "Monthly Payment: $cgi{'mop3'}\n\n");

printf(MAIL "4\n");
printf(MAIL "Name: $cgi{'lname4'}\n");
printf(MAIL "Address: $cgi{'ladd3'}\n");
printf(MAIL "Balance: $cgi{'bal3'}\n");
printf(MAIL "Monthly Payment: $cgi{'mop4'}\n\n");


printf(MAIL "TOTAL LIABILITIES: $cgi{'totalliabilities'}\n\n");


printf(MAIL "============SECURITY===================\n");
printf(MAIL "Property Address: $cgi{'secaddress'}\n");
printf(MAIL "Lot #: $cgi{'seclotnumber'}\n");
printf(MAIL "Plan #: $cgi{'secplannumber'}\n");
printf(MAIL "Lot size: $cgi{'seclotsize1'} - $cgi{'seclotsize2'}\n");
printf(MAIL "Dwelling Size: $cgi{'secdwelling'}\n");
printf(MAIL "Taxes:  $cgi{'sectaxes'}\n");
printf(MAIL "Condo Fees:  $cgi{'seccondofees'}\n");
printf(MAIL "Status: $cgi{'secoccupancy'}\n");
printf(MAIL "Building Income: $cgi{'secincome'}\n");
printf(MAIL "Type: $cgi{'hometype'}\n");
printf(MAIL "Construction: $cgi{'construction'} - Age:$cgi{'constructionage'} - Number of rooms:$cgi{'numberofrooms'} \n");
printf(MAIL "Options: $cgi{'hydro'} $cgi{'munwater'} $cgi{'well'} $cgi{'sewers'} $cgi{'septictank'} $cgi{'pavedroad'} $cgi{'uffi'}\n");




printf(MAIL "Closing Date: $cgi{'closingdate'} - Puchase Price: $cgi{'purchaseprice'}\n");
printf(MAIL "Cash Downpayment: $cgi{'downpayment'}\n");

printf(MAIL "Solicitor: $cgi{'solicitorname'} - Phone:$cgi{'solicitorphone'} - Address:$cgi{'solicitoraddress'}\n\n");

printf(MAIL "==================================================\n");
printf(MAIL "Submittion Date: $tt[1]-$tt[2]-$tt[4]\n");
printf(MAIL "REF: $tt[1]$tt[2]$tt[4] --- $pp[0]RRSP$pp[1]$pp[2]\n");
printf(MAIL "============HSL ONLINE RRSP==================\n\n");


close(MAIL);










