/home/mip/public_html_/old-website/employerxxx/email.php
<?php
session_start();
require_once("common_msg.inc");
require_once("func_all.php");
$db = db_connect();

switch($what){
case 'reserved':  
		 				
							$get_email = getdata("Select agency_email,from_email from company");
							$agency_email =  $get_email[1]["agency_email"];
							
							
							$principal = getdata("Select name,email from principals where principal_id=" . $principal_id);
							
							$sql ="select lname, fname, mname,applicant_id,sex, birthdate, height1, height2, weight1, weight2, position1_yrsofexp,position1_mosofexp from personal where applicant_id IN($applicant)";
							
							$result = getdata($sql);
							$found = count($result);
							
							$today =getdate();
							$month = $today["month"];
							$day = $today["mday"];
							$year = $today["year"];
							$today_date = "(" . $month . " " . $day . ", " . $year . ")"; 
							
							$from = $principal[1]["email"];

							if($from==""){
							     $from = $agency_email;
							}
														
							$to = $agency_email;
							
							$subject  = "Reserved applicants for " . $principal[1]["name"];														
							
							$headers  = "MIME-Version: 1.0\r\n";
							$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
							$headers .= "From:$from\r\nX-Priority: 1 (Highest)\r\n";
							
							$message  = "<html><head><title></title><style type='text/css'>";
							$message .=".box {BACKGROUND-COLOR: #FFFFFF; BORDER-BOTTOM: #333333 1px solid; BORDER-LEFT: #333333 1px solid; BORDER-RIGHT: #333333 1px solid; BORDER-TOP: #333333 1px solid; COLOR: black; FONT-FAMILY: verdana; FONT-SIZE: 11px; TEXT-DECORATION: none}";
							$message .=".box1 {BACKGROUND-COLOR: #FFFFFF; BORDER-BOTTOM: #333333 1px solid; BORDER-LEFT: #333333 1px solid; BORDER-RIGHT: #333333 1px solid; BORDER-TOP: #333333 1px solid; COLOR: black; FONT-FAMILY: verdana; FONT-SIZE: 13px; TEXT-DECORATION: none}";
							$message .="</style></head><body>";
							$message .="<table width='100%' cellpadding='2' cellspacing='2' border=0  bgcolor='#F1F1F1'>";
   				    $message .="<tr><td width=1% align=left class='box1' colspan=9><b>Reserved applicants for " . $principal[1]["name"] . " " .$today_date . "</td>";
							$message .="<tr><td width=1% align=center class='box'><b>&nbsp;</td>";
							$message .="<td width=14% align=center class='box'><b>Applicant No.</td>";
							$message .="<td width=24% align=center class='box'><b>Applicant Name</a></td>";
			    		$message .="<td width=8% align=center class='box'><b>Sex</b></td>";
							$message .="<td width=8% align=center class='box'><b>Age</b></a></td>";
							$message .="<td width=7% align=center class='box'><b>Height</b></td>";
							$message .="<td width=7% align=center class='box'><b>Weight</b></td>";
							$message .="<td width=17% align=center class='box'><b>Education</td>";				
							$message .="<td width=10% align=center class='box'><b>Yrs. of Experience</a></td></tr>";
														
					
			
				 
			   for($i=1;$i<=$found;$i++){ 
						$applicant_id = $result[$i]["applicant_id"];
						$educ = getdata("SELECT education FROM education WHERE applicant_id = '$applicant_id' ORDER BY to_date DESC");
						
						
						$message .= "<tr>";
						$message .= "<td class=box align=right valign=top>$i.&nbsp;</td>";
						$message .= "<td class=box valign=top>&nbsp;".$applicant_id."</a></td>";
						$message .= "<td class=box valign=top>&nbsp;".$result[$i]["lname"]. ", " . $result[$i]["fname"]. " " .substr($result[$i]["lname"],0,1). ".</td>";    				
    				$message .= "<td class=box align=center valign=top>&nbsp;".$result[$i]["sex"]."</td>";
						$message .= "<td class=box align=center valign=top>&nbsp;".get_age($result[$i]["birthdate"])."</td>";						
						$message .= "<td valign=top class=box align=center>&nbsp;";
						$message .= ($result[$i]["height1"])? $result[$i]["height1"]." ".$result[$i]["height2"] : "";
						$message .= "</td>";
						$message .= "<td valign=top class=box align=center>&nbsp";
						$message .= ($result[$i]["weight1"])? $result[$i]["weight1"]." ".$result[$i]["weight2"] : "";
						$message .= "</td>";    									
						$message .= "<td  class=box valign=top>&nbsp;".$educ[1]["education"]."</td>";						
						$message .= "<td class=box align=left valign=top>&nbsp;";
						$message .= ($result[$i]["position1_yrsofexp"])? ($result[$i]["position1_yrsofexp"])."yrs" : "";
						$message .= ($result[$i]["position1_yrsofexp"] && $result[$i]["position1_mosofexp"])? " & " : "";
						$message .= ($result[$i]["position1_mosofexp"])? ($result[$i]["position1_mosofexp"])."mos" : "";
						$message .= "</td>";						
						$message .= "</tr>";
      } // end of for loop
			
			      $message .="</table>";
			      $message .="</body></html>";
     					
							
							
					    
							if(mail($to, $subject, $message, $headers)){
							  
									 $result =1;
									 header("Location: edit_source_survey.php?gender=$gender&min_age=$min_age&max_age=$max_age&position_id=$position_id&num_applicant=$num_applicant&msg=$num_applicant applicant(s) reserved");
							}else{
										
							     $result =0;
									 header("Location: edit_source_survey.php?gender=$gender&min_age=$min_age&max_age=$max_age&position_id=$position_id&num_applicant=$num_applicant&msg=$Reservation unsuccessful");
							}
							
							
							     
break;										 


													
}	
?>