";
// need these variables to push a completion into the database.
echo "
";
// draw the letter for printing.
if($var_RegisteredMail_Instructions)
{
echo "
";
// echo "registered is $var_RegisteredMail regular is $var_RegularMail";
if($var_RegisteredMail == 'Yes')
echo "** SENT VIA REGISTERED MAIL **";
elseif($var_RegularMail == 'Yes')
echo "** SENT VIA REGULAR MAIL **";
echo "
$var_To_Names
";
// textareas use legacy newlines, php uses html.
// to solve this quandry, we've broken the text into an array
// split on newlines. So for each line, write it, then use where there was
// a \n.
foreach($arr_Content_by_Line as $Line)
{
echo $Line;
echo " ";
}
echo "
$var_Parting
";
if($var_Contact_Name)
{
echo "
$var_Contact_Name
";
}
if($var_Contact_Suffix)
{
echo "
$var_Contact_Suffix
";
}
if($var_Vendor)
{
echo "
$var_Vendor
";
}
elseif($var_CompanyName)
{
echo "
$var_CompanyName
";
}
echo "
";
if($var_Per_Section == "show")
{ echo "
Per:
$LoggedInUser
$var_cc_String";
}
echo "
";
}
// if we have a letter to print (this is letter step 2)
if($_REQUEST['PostLetter']=="Print Letter")
{
// print_r($_REQUEST);
// pipe the data to the create pdf page.
echo "";
}
// if we have an email to send (NOT VALIDATING)
if(( $_REQUEST['PostEmail'] == 'Send Email')&&($_REQUEST['var_Type'] != "Validate Email"))
{
// echo "in !Type
";
$var_From = $_REQUEST['var_email_From'];
$var_To = $_REQUEST['var_email_To'];
$var_Subject = $_REQUEST['var_Subject'];
$var_Body = $_REQUEST['var_Content'];
$var_CompletedDate = date("Y-m-d");
// keep the smtp server happy
$Body = str_replace("\n.", "\n..", $Body);
// cross your fingers.
// mail returns a boolean so lets use it to decide success/failure.
$var_Push = SendMailVince($var_From, '', $var_To, '', $var_Subject, $var_Body, '','');
// if our mail went out, update the database.
if($var_Push)
{
// get the ContactAutoID for the record we're about to modify.
// we only want the last row of data.
$sql = "Select col_ContactAutoID
from tb_Contact
where col_Centre='$var_Centre'
and col_Phase='$var_Phase'
and col_Lot='$var_Lot'
and col_Type='$var_Type'
and col_Method='$var_Method'
ORDER BY col_ContactAutoID DESC
LIMIT 1;
";
if($result = mysql_query($sql,$db))
{
$myrow = mysql_fetch_array($result);
$var_ContactAutoID = $myrow['col_ContactAutoID'];
}
// push completion to database.
$push_sql= "
update tb_Contact set
col_Status = 'Completed On',
col_CompletedOn = '$var_CompletedDate'
where col_ContactAutoID='$var_ContactAutoID';
";
// echo $push_sql;
$result = mysql_query($push_sql,$db);
if(!$result)
{
echo "generate error here";
}
else
// if everything has gone smoothly, close the page.
echo "";
}
// otherwise, tell the user about it and leave the db alone.
else
{
echo "
send failed. ";
}
$var_Suppress = 1;
}
// if we have an email address to validate
if(( $_REQUEST['PostEmail'] == 'Send Email')&&($_REQUEST['var_Type'] == "Validate Email"))
{
// print_r($_REQUEST);
// get the variables
$var_From = $_REQUEST['var_email_From'];
$var_To = $_REQUEST['var_email_To'];
$var_Subject = $_REQUEST['var_Subject'];
$var_Body = $_REQUEST['var_Content'];
$var_ICameFrom = $_REQUEST['var_ICameFrom'];
$var_Centre = $_REQUEST['var_Centre'];
$var_Phase = $_REQUEST['var_Phase'];
$var_Lot = $_REQUEST['var_Lot'];
$var_ID = $_REQUEST['var_ID'];
$var_page_type = $_REQUEST['var_selected_app'];
// echo $var_Body;
// echo "
called with from: $var_From,'',$var_To,'',$var_Subject,'',$var_Body,''";
// $From,$FromName,$To,$ToName,$Subject,$Text,$Html,$AttmFiles
$Success = SendMailVince($var_From,'',$var_To,'',$var_Subject, '', $var_Body,'');
// if email went off, push record to database
if($Success)
{
// get the latest entry for this id
$sql="
select col_SentItemID
from tb_SentItem
where col_ID='$var_ID'
order by col_SentItemID desc limit 1";
$result = mysql_query($sql,$db);
$myrow = mysql_fetch_array($result);
$var_SentItemID = $myrow['col_SentItemID'];
$sql="
update tb_SentItem
set col_SentTo = '$var_To',
col_SentFrom = '$LoggedInUser',
col_Type = 'Email Confirm'
where col_SentItemID = $var_SentItemID;
";
mysql_query($sql,$db);
}
else
{
echo "send failed.";
}
// then send the user back to the referring page. Now that we're spanning directories
// we need to reform the ICameFrom variable.
if($var_ICameFrom=="AEContact.php")
{
$var_ICameFrom = "../_gen/AEContact.php";
}
elseif($var_ICameFrom == "HSPurchaserInfo.php3")
{
$var_ICameFrom = "../_gen/HSPurchaserInfo.php3";
}
// $var_ICamefrom?var_ID=$var_ID&var_Centre=$var_Centre&var_Phase=$var_Phase&var_Lot=$var_Lot
echo "";
$var_Suppress = 1;
}
/********************************* END REQUEST LOOP *****************************************/
/********************************* BEGIN MAIN CODEBLOCK *************************************/
// print_r($_REQUEST);
$var_ID = $_REQUEST['var_ID'];
$var_Comms_Method = $_REQUEST['var_Method'];
$var_Comms_Type = $_REQUEST['var_Type'];
$var_Centre = $_REQUEST['var_Centre'];
$var_Phase = $_REQUEST['var_Phase'];
$var_Lot = $_REQUEST['var_Lot'];
$var_CompletedDate = $_REQUEST['var_CompletedDate'];
// echo "Comms type is $var_Comms_Type";
// echo "site path is $PathToFiles";
// output City, Province
$var_co_CityProv = "$ThisCompanyCity". ", " ."$ThisCompanyProvince";
// get the security level and email address for this user.
$sql = "select col_AccessLevelCorrespondence,
col_EmailAddress
from tb_Users
where col_UsersName = '$LoggedInUser';";
$result = mysql_query($sql,$db);
$myrow = mysql_fetch_array($result);
$var_UserSecLevel = $myrow['col_AccessLevelCorrespondence'];
$var_UserEmail = $myrow['col_EmailAddress'];
// include the verbiage file.
// get the filenames.
// echo "path to files is: $PathToFiles ";
if($var_Comms_Type == 'validate_Email')
$var_Comms_Type = "Validate Email";
$sql = "
select col_MiscValue
from tb_Lists
where col_Value = '$var_Comms_Type'
";
// echo $sql;
$myrow = mysql_fetch_array(mysql_query($sql));
$var_Filename = $myrow['col_MiscValue'];
// echo "got $var_FileName from db. ";
if(file_exists($PathToFiles .'_builder/' .$var_BuilderPrefix.$var_Filename))
$var_UseThisFile = $PathToFiles .'_builder/' . $var_BuilderPrefix.$var_Filename;
else
$var_UseThisFile = $PathToFiles.'_builder/'.$var_Filename;
// echo "going to use $var_UseThisFile ";
// die();
// ensure file exists, tell user if not.
if(file_exists($var_UseThisFile))
{
// echo $var_UseThisFile;
// die();
include $var_UseThisFile;
}
else
{
echo "File does not exist. Please contact Builder Software Tools at 1-877-788-9988 or support@BuildersIT.com";
die;
}
// if we're not rendering the page on a $_REQUEST
if(!$var_Suppress)
{
// get the names for this prospect.
$sql = "
Select col_Name1, col_Name2
From tb_Worksheet
Where col_ID = '$var_ID'
";
if($result = mysql_query($sql,$db))
{
while ($myrow = mysql_fetch_array($result))
{
$var_Name1 = $myrow['col_Name1'];
$var_Name2 = $myrow['col_Name2'];
// escape apostrophes in the names if there are any.
$var_Name1 = str_replace("'", "\'", $var_Name1);
$var_Name2 = str_replace("'", "\'", $var_Name2);
}
// if we get names, get the rest of the details from tb_Prospect.
$sql = "
Select col_City,
col_Province,
col_PhoneRes,
col_Address,
col_PostalCode
From tb_Prospect
Where col_ID = '$var_ID'
";
if($result = mysql_query($sql,$db))
{
while ($myrow = mysql_fetch_array($result))
{
$var_To_City = $myrow['col_City' ];
$var_To_Province = $myrow['col_Province' ];
$var_To_PhoneRes = $myrow['col_PhoneRes' ];
$var_To_Address = $myrow['col_Address' ];
$var_To_PostalCode = $myrow['col_PostalCode'];
}
}
} // closes if result
// get the names string.
$var_Names = Str_Generate_Names($var_Name1, $var_Name2);
// if we're being asked to render a letter
if($var_Comms_Method == "Letter")
{
echo "