/home/mip/public_html_/old-website/brokerxxx/manage_job_order1.php
<?
session_start();
require_once("func_all.php");

if($msg) echo "<script>alert('$msg')</script>";
	do_html_header("Sourcing Survey");
	

	$principal = getdata("select * from principals where broker_id=" . $myprincipalid . " order by name");
	?> 
	<form method=post action='<?=$PHP_SELF?>' name='form_source_survey'">
  <tr height=100%><td valign="top"><br>
	<table align=center width=100%>
	<tr class=white height=30>
			<td align=center>
			<table border=0 cellpadding='0' cellspacing='0'>
					<tr>
					<td>
					<b>Select Principal :</b>
					<select name="principal_id" onchange="form.submit()">
					<option value="0">-- Select Principal --
					<?selectcode($principal, $principal_id, "principal_id","name")?></select>
					<!--<br>
					<b>Gender :</b> <input class="radio2" type=radio name=gender value="" <?=(!$gender)? "checked" : ""?>>any 
								 <input class="radio2" type=radio name=gender value="M" <?=($gender=='M')? "checked" : ""?>>Male 
								 <input class="radio2" type=radio name=gender value="F" <?=($gender=='F')? "checked" : ""?>>Female
					&nbsp;&nbsp;&nbsp;			  
					<b>Age :</b> Min <input type=text name="min_age" size=4 maxlength=2 value="<?=$min_age?>" onfocus="select()">&nbsp;&nbsp;
							Max <input type=text name="max_age" size=4 maxlength=2 value="<?=$max_age?>" onfocus="select()">
					&nbsp;&nbsp;
					<input type=submit value="Get Applicants">-->
					</td></tr>
					</table>
			</td>
	</tr>
	
<?
if($gender) $sql_gender = "AND p.sex='$gender'"; // gender
		  
if($min_age){
	  $min_date = get_date($sqltoday,-$min_age);
		$sql_min_age = "and p.birthdate > 0 and p.birthdate <= '$min_date'";
}
	
if($max_age){
	  $max_date = get_date($sqltoday,-($max_age+1));
		$sql_max_age = "and p.birthdate >= '$max_date'";
}
	
$sql_age = "$sql_max_age $sql_min_age"; // age
	
if($principal_id)
{
	
	if($sort_by){
	  $old_sort_order = $sort_order;
		$sort_order = ($old_sort_order=="asc")? "desc" : "asc";
		$sql_sort_by = "p.$sort_by";
		if($sort_by == 'position1_yrsofexp')  $add_sort = ",position1_mosofexp $sort_order";  			 
	}
  else{
	  $sql_sort_by = "p.lname";
		$sort_order = "asc";
	}	
	
	$result = getdata("SELECT distinct(p.applicant_id),
														p.birthdate,
														p.picture,
														p.sex,
														p.video,
														p.height1,p.height2,
														p.weight1,p.weight2,	
														p.position1_yrsofexp,
														p.position1_mosofexp,
														concat(p.lname,', ',p.fname,' ',left(p.mname,1),'.') as name																							                          																						
										 FROM   personal as p
										 WHERE  p.position_id1 = '$principal_id'										     
										 AND    p.status = 'On Pool'
										 $sql_gender				
										 $sql_age						 						 
										 ORDER BY $sql_sort_by $sort_order $add_sort");
  $found = count($result);
  echo mysql_error();

if($found){ ?> 
			<tr><td bgcolor="#d4d0c8">
			</form>
			  <table border=0>

			  <tr><td><font color=red>Note:</font></td><td>Click the Applicant Name, Age, Yrs. of Experience to sort the applicants.</td></tr>
				<tr><td>&nbsp;</td><td>To view the resume of an applicant, click on the Applicant No.</td></tr>
				<tr><td>&nbsp;</td><td>To reserve applicant(s), click on the checkbox and click "Reserve" button.</td></tr>
				</table>
			</td></tr>			 	
			<tr><td>
			<table border="0" cellpadding="0" cellspacing="0" width=100%>
			<tr><td><img src="img/topleft-login.gif" border="0"></td>
					<td background="img/toptile-login.gif"><img src="img/toptile-login.gif" border="0"></td>
					<td><img src="img/topright-login.gif" border="0"></td></tr>
			<tr><td background="img/midleft-login.gif"><img src="img/midleft-login.gif" border="0"></td>
					<td width="100%" align="center" bgcolor="#dbdee3">
					<table width="100%" cellpadding='3' cellspacing='3' border=0>
   				<tr>
			    		
							<td width=1%>&nbsp;</td>
							<td width=10% align=center><b>Job Order No.</td>
							<td width=30% align=center><b>Position</td>
							<td width=4% align=center><b>Male</b></td>							
							<td width=4% align=center><b>Female</b></td>
							<td width=7% align=center><b>M/F</b></td>
							<td width=10% align=center><b>Proposed Wage</b></td>				
							<td width=15% align=center><b>No. Of Applicants</td>
							<td width=10% align=center><b>Yrs. of Experience</b></td>								
							
					</tr>
			<form name='thisOnly' action='sqlupdate.php?what=status' method='get'>
						<input type="hidden" name="what" value="<?=status?>">
						<input type="hidden" name="gender" value="<?=$gender?>">
						<input type="hidden" name="age_min" value="<?=$age_min?>">
						<input type="hidden" name="age_max" value="<?=$age_max?>">
						<input type="hidden" name="position_id" value="<?=$principal_id?>">
						<input type="hidden" name="principal_id" value="<?=$myprincipalid?>">
						
			<? 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");
						
						
						print "<tr>";
    				print "<td class=box align='center' valign='top'><input type='checkbox' name='reserve[]' value='$applicant_id' class='radio'></td>";
						print "<td class=box align=right valign=top>$i.&nbsp;</td>";
						print "<td class=box valign=top><a href=\"report_applicant3.php?applicant_id=".$applicant_id."\" target=\"page$applicant_id\">".$applicant_id."</a></td>";
						print "<td class=box valign=top>".$result[$i]["name"]."</td>";    				
    				print "<td class=box align=center valign=top>".$result[$i]["sex"]."</td>";
						print "<td class=box align=center valign=top>".get_age($result[$i]["birthdate"])."</td>";						
						print "<td valign=top class=box align=center>";
						print ($result[$i]["height1"])? $result[$i]["height1"]." ".$result[$i]["height2"] : "";
						print "</td>";
						print "<td valign=top class=box align=center>";
						print ($result[$i]["weight1"])? $result[$i]["weight1"]." ".$result[$i]["weight2"] : "";
						print "</td>";    									
						print "<td  class=box valign=top>".$educ[1]["education"]."</td>";						
						//print "<td class=box align=center valign=top>".get_yrs_exp($applicant_id)."</td>";
						print "<td class=box align=left valign=top>";
						print ($result[$i]["position1_yrsofexp"])? ($result[$i]["position1_yrsofexp"])."yrs" : "";
						print ($result[$i]["position1_yrsofexp"] && $result[$i]["position1_mosofexp"])? " & " : "";
						print ($result[$i]["position1_mosofexp"])? ($result[$i]["position1_mosofexp"])."mos" : "";
						print "</td>";
						print "<td class='box' align='left'>";
						
						print "<a href=\"report_applicant3.php?applicant_id=".$applicant_id."\" target=\"page$applicant_id\">>Resume</a><br>"; 
						if($result[$i]["picture"]){?>
						     <a href=# onclick="window.open('<?=$pic_dir1.$result[$i][picture]?>', 'picture', 
										             config='height=300, width=300, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, directories=no, status=no, copyhistory=no')">>Picture</a><br>
						<?}
						if($result[$i]["video"]){ ?>
						<a href=# onclick="window.open('display_video.php?path=<?=$video_dir.$result[$i][video]?>&title=<?=$name?>', 'video', 
										             config='height=400, width=400, toolbar=no, menubar=no, scrollbars=no, resizable=yes,location=no, directories=no, status=no, copyhistory=no')">>Video</a>
					  <?}
						print "</td></tr>";			
						
      } // end of for loop
	          print "<tr><td><input type='submit' value='Reserve'></td></tr>"; 		
			?> </table>
			
		</td>
		
		
		<td background="img/midright-login.gif"><img src="img/midright-login.gif" border="0"></td></tr>
		<tr><td><img src="img/botleft-login.gif" border="0"></td>
		<td background="img/bottile-login.gif"><img src="img/bottile-login.gif" border="0"></td>
		<td><img src="img/botright-login.gif" border="0"></td></tr>
		</table>			
	</td>
	
	</tr>
	<!--additional -->
	
	<!--additional -->
			<?
  } // end of if there is a result in search
	else{?>	
	<tr><td height="25" align=center><font color=red>There is no on pool applicants under the above criteria(s).</font></td></tr>
	<?	
	} 
}// end of if there is position_id
?>
</table>
</td></tr>
</form>
<?
do_html_footer();
?>