Well, I apologize in advance for the amount of code that is to come. But, this email is the culmination of a five page wizard with a lot of information. I'm using mysql, php 5 & xsl/xml plus front-end (css/javascript/etc)
Once the data on the last form page is saved to the database, it goes to the function below:
function email_params(){
$candidate = new candidate;
$candidate->load($_REQUEST['id_candidate']);
$legal = $REQUEST['show_legal'];
$legal_boo = $REQUEST['legal_boo'];
$notify_cp = $REQUEST['show_notify_cp'];
$notify_hr = $REQUEST['show_notify_hr'];
$notify_person = $REQUEST['show_notify_person'];
$notify_prod = $REQUEST['show_notify_prod'];
$notify_finance = $REQUEST['show_notify_finance'];
$cc_notes = $REQUEST['cc_notes'];
$action = $candidate->get_prop('action');
$process_email = $candidate->get_prop('process_email');
$cmd = new c_get_employees;
$emparray = $cmd->process();
$test = 1;
if($test){
header('content-type:text');
}
$cp_list = $test? '#TVA-NewHire-CurrentProgrammingT@email.disney.com' : '#TVA-NewHire-CurrentProgramming@email.disney.com';
$hr_list = $test? '#TVA-NewHire-HumanResourcesT@email.disney.com' : '#TVA-NewHire-HumanResources@email.disney.com';
$legal_list = $test? '#TVA-NewHire-LegalT@email.disney.com' : '#TVA-NewHire-Legal@email.disney.com';
$op_list = $test? 'TVA-OperationsT@email.disney.com' : 'TVA-Operations@email.disney.com';
$prod_list = $test? '#TVA-NewHire-ProductionT@email.disney.com' : '#TVA-NewHire-Production@email.disney.com';
$tech_list = $test? 'TVA-TechnologyTeamT@email.disney.com' : 'TVA-TechnologyTeam@email.disney.com';
$newhire_list = $test? 'TVA-NewHire_TermT@email.disney.com' : 'TVA-NewHire_Term@email.disney.com';
$finance_list = $test? '#TVA-NewHire-ProductionFinanceT@email.disney.com' : '#TVA-NewHire-ProductionFinance@email.disney.com';
$paraperson = $test? 'adam.haley@disney.com' : 'suzanne.prescott@email.disney.com';
mysql_select_db('tag');
$emp = new employee;
$emp->load($candidate->get_prop('id_prepared_by'));
$name = $emp->get_prop('name_first');
$name = $name." ".$emp->get_prop('name_last');
$from = $emp->get_prop('email');
$dept = $emp->get_prop('department');
mysql_select_db('new_hire');
$to = $from . ','; // start with the originators email
//BUILD EMAIL TO LIST
$type ='';// email type toggle
if($legal == 'on'){
$type = 'legal';
}
if($legal =='on'){
$to .= $legal_list . ',';
}else{
if($REQUEST['action'] == 'Completed'){
if($REQUEST['legal_boo'] == false){
$to .= $newhire_list . ',';
}
}
if($notify_cp == 'on'){
$to .= $cp_list . ',';
}
if($notify_hr == 'on'){
$to .= $hr_list . ',';
}
if($notify_person == 'on'){
$to .= $paraperson . ',';
}
if($notify_prod == 'on'){
$to .= $prod_list . ',';
}
if($notify_finance == 'on'){
$to .= $finance_list . ',';
}
//if($cc_notes != ''){
//$to .= $cc_notes . ',';
//}
}
//END BUILD EMAIL TO LIST
//$to = preg_replace("/,$/","",$to);
$to .= $op_list . "," . $tech_list;
if($test){
echo $to . "\nCC:$cc_notes\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
}
//take user home
//echo "from: $from \n\n\n\n";
$action = $_REQUEST['action'];
$body = $this->build_email($candidate,$emp,$type,$action);
//echo "body: $body \n\n\n\n\n";
if($action == 'In Process'){
$subject = 'Potential New Hire Notification';
}else if($action == 'Completed'){
$subject = 'New Hire Verification';
//if($_REQUEST['legal_boo'] == false){
//$to .= $newhire_list . ',';
//}
}else{
$subject = 'New Hire Denied';
}
if($legal_boo){
$subject = 'The following deal has been closed.';
}
if($type =='legal'){
$subject .= " - Legal Action Required";
}
//send email
$this->send_mail($from,$name,$to,$cc_notes,$subject,$body);
if(!$test){
header('Location:index.php?c=home');
}
}
function build_email($candidate,$employee,$type,$action){
$body .= '<p style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size:12px;"><br />';
if($action == 'In Process'){
$body .= 'This email is to notify you of the following new hire.<br /><br />';
if($_REQUEST['work'] == 'Yes'){
$body .= 'Work eligibility has been met.<br/><br/>';
}
}
else if($action == 'Completed'){
$body .= 'This email is to notify you the following new hire has been verified.<br /><br /> ';
}
else{
$body .= 'This email is to notify you the following new hire has been denied.<br/><br/>';
}
if($REQUEST['legal_boo']){
if($REQUEST['action'] == 'Denied'){
$body .= "Deal Denied.<br/><br/>";
}else if($REQUEST['show_w_eligible'] == 'on' && $action != 'Completed'){
$body .= "Work eligibility needs to be verified.<br /><br />";
}else if($REQUEST['work'] == 'Yes'){
$body .= "Work eligibility has been met.<br /><br />";
}else{
$body .= "Work eligibility does NOT need to be verified.<br /><br />";
}
}
if($_REQUEST['legal_notes']){
$body .= 'Legal Notes: ' . $_REQUEST['legal_notes'] . "<br /><br />";
}
if($_REQUEST['id_position_type'] == '2'){
$body .= 'This is a single assignment.<br/><br/>';
}
else{
$body .= '<br/><br/>';
}
$body .= '<b>Name:</b> ' . $candidate->get_prop('name_first') . ' ' . $candidate->get_prop('name_last') . '<br/>';
$body .= '<b>New Hire Database ID #:</b> ' . $candidate->get_prop('id_candidate') . '<br/>';
$body .= '<b>Title of Series or Project:</b> '.$candidate->get_prop('project') . '<br/>';
$body .= '<b>Title of Position:</b> ' . $candidate->get_prop('title') . '<br/>';
$body .= '<b>Start Date:</b> ' . $candidate->get_prop('a_start_date') . '<br/>';
$body .= '<b>Requestor:</b> ' . $employee->get_prop('name_first') . ' ' . $employee->get_prop('name_last') . '<br/><br/>';
$body .= "<b>OPERATIONS INFORMATION</b><br /><br />";
$body .= '<b>Office Type:</b> ' . $candidate->get_prop('office_type') . '<br/>';
$body .= '<b>Building:</b> ' . $candidate->get_prop('building') . '<br/>';
$body .= '<b>Specialty Furniture:</b> ' . $candidate->get_prop('spec_furn') . '<br/>';
$body .= '<b>Specialty Supplies:</b> ' . $candidate->get_prop('spec_supp') . '<br/>';
$body .= '<b>Additional Office Equipment:</b> ' . $candidate->get_prop('addl_equip') . '<br/>';
$body .= '<b>Phone:</b> ' . $candidate->get_prop('c_phone') . '<br/>';
$body .= '<b>Speaker Phone:</b> ' . $candidate->get_prop('s_phone') . '<br/>';
$body .= '<b>Display Phone:</b> ' . $candidate->get_prop('d_phone') . '<br/>';
$body .= '<b>Call Locations:</b> ' . $candidate->get_prop('call_loc') . '<br/>';
$body .= '<b>Location #:</b> '.$candidate->get_prop('location_num') . '<br/>';
$body .= '<b>Intercom:</b> ' . $candidate->get_prop('intercom') . '<br/>';
$body .= '<b>Additional Extensions:</b> ' . $candidate->get_prop('add_ext') . '<br/>';
$body .= '<b>Cube Setup:</b> ' . $candidate->get_prop('cube_set') . '<br/>';
$body .= '<b>Intercom:</b> ' . $candidate->get_prop('intercom') . '<br/>';
$body .= '<b>Office Notes:</b> ' . $candidate->get_prop('off_notes') . '<br/><br />';
$body .= "<b>TECHNOLOGY INFORMATION</b><br /><br />";
$body .= '<b>Computer System Required:</b> ';
$body .= $candidate->get_prop('comp_sys')? $candidate->get_prop('comp_sys') : 'None';
$body .= '<br/>';
if($_REQUEST['action'] == 'In Process'){
if($type == 'legal'){
$body .= '<br/>Legal action is required in order for this application to move forward. The ';
}else{
$body .= '<br/>This ';
}
$body .= 'application can be viewed <a href="http://tva.disney.pvt/tag/new_hire/index.php?c=create_record&id_candidate=' . $candidate->get_prop('id_candidate') . '">here</a>.<br/><br/><br/>';
}
$body .= '<br/><br/>THIS IS AN AUTOMATICALLY GENERATED EMAIL.</p>';
return $body;
}
function send_mail($from, $name, $to, $cc_notes, $subject, $body){
// to send email
ini_set('SMTP', 'yu-cala-hga1.swna.wdpr.disney.com');
ini_set('sendmail_from', $from);
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: ' . $name . '<'. $from . ">\r\n";
$headers .= 'Cc: ' . $cc_notes . "\r\n";
$headers .= 'Reply-To:' . $from . "\r\n";
mail($to, $subject, $body, $headers);
}