<?php
if(!isset($_REQUEST['jobs'])) {
	$jobs = array();
	$jobs['job_cat_id'] = "";
	$jobs['Location'] = "";
	$jobs['Conditions'] = "";
	$jobs['posted'] = "all";
	$jobs['limit'] = "20";
	$jobs['search'] = "no";
}

if(!isset($_REQUEST['cv'])) {
	$cv = array();
	$cv['job_cat_id'] = "";
	$cv['JobLocation'] = "";
	$cv['posted'] = "all";
	$cv['limit'] = "20";
	$cv['search'] = "no"; 
}

$locations = array("Nicosia", "Limassol", "Larnaca", "Paphos", "Famagusta");

?>
<?php
if(!isset($jobs_css_file_loaded)) {
	?>
	<link rel="stylesheet" href="<?php echo $path?>modules/jobs_ext.css">
	<?php
}
?>
<div id="jobs_res_srch_container">
	<div id="jobs_srch_container">
		<div class="jobs_srch_label"><?php echo '<h1>', 'Job Seekers', '</h1>';?></div>
		<div class="main_jobs_search">
			
			<form method="post" action="index.php" name="jobs_search_frm" id="jobs_search_frm">
			<table cellpadding="0" cellspacing="0" border="0" width="100%">
				<tr>
					<td class="itdh"><?php echo 'Job Category';?></td>
				</tr>
				<tr>
					<td class="itd">
						<select name="jobs[job_cat_id]" class="setwidth">
							<option value=""><?php echo 'Select Category';?></option>
							<?php
							$qexl = "select * from job_cat where active='yes' order by order_seq asc;";
							$rexl = @mysql_query($qexl);
							if($rexl && mysql_num_rows($rexl) > 0) {
								while ($rowexl = mysql_fetch_assoc($rexl)){
									$selected = '';
									if($jobs['job_cat_id'] == $rowexl['job_cat_id']) $selected = ' selected="selected"';
									echo '<option value="',trim($rowexl['job_cat_id']),'" ',$selected,'>', stripslashes($rowexl['title_en']), '</option>';
								}
							}
							?>
						</select>
					</td>
				</tr>
				
				<tr>
					<td class="itdh" nowrap="nowrap"><?php echo 'Job Location';?></td>
				</tr>
				<tr>
					<td class="itd">
						<?php
						?>
						<select name="jobs[Location]" class="setwidth">
							<option value=""><?php echo 'Any'?></option>
							<?php
							foreach ($locations as $loc) {
								$selected = '';
								if($jobs['Location'] == $loc) $selected = 'selected="selected"';
								echo '<option value="',$loc,'" ',$selected,'>', $loc, '</option>';
							}
							?>
						</select>
					</td>
				</tr>
				
				<tr>
					<td class="itdh" nowrap="nowrap"><?php echo 'Job Type';?></td>
				</tr>
				<tr>
					<td class="itd">
						<?php
						$all_commitment = array(
							"full-time" 	=> "Full Time",
							"part-time"		=> "Part Time",
							"contract"		=> "Contract",
							"temp"			=> "Temporary",
							"internship"	=> "Internship",
							"other"			=> "Other"
						);
						?>
						<select name="jobs[Conditions]" class="setwidth">
							<option value=""><?php echo 'Any';?></option>
							<?php
							foreach ($all_commitment as $ctype=>$ctype_title) {
								$selected = '';
								if($jobs['Conditions'] == $ctype) $selected = 'selected="selected"';
								echo '<option value="',$ctype,'" ',$selected,'>', $ctype_title, '</option>';
							}
							?>
						</select>
					</td>
				</tr>
				
				<tr>
					<td class="itdh" nowrap="nowrap"><?php echo 'Posted';?></td>
				</tr>
				<tr>
					<td class="itd">
						<select name="jobs[posted]" class="setwidth">
							<option value="all" selected="selected">Any Time</option>
							<?php
							$posted_vals = array(
								'0' => 'Today',
								'1' => 'Yesterday',
								'7'	=> 'Last 7 Days',
								'30'=> 'Last 30 Days'
								
							);
							
							foreach ($posted_vals as $pv=>$pv_title) {
								$selected = '';
								if(isset($jobs['posted']) && $jobs['posted'] != "all" && $jobs['posted'] == $pv) $selected = 'selected="selected"';
								echo '<option value="',$pv,'" ',$selected,'>', $pv_title, '</option>';
							}
							?>
						</select>
					</td>
				</tr>
				<tr>
					<td align="left" class="itd">
						<?php
						echo 'Show', ' ';
						echo '<select name="jobs[limit]" style="vertical-align:middle;">';
						$limit_ar = array('10', '15', '20', '25', '30', '50');
						foreach ($limit_ar as $lt) {
							$selected = '';
							if(strval($jobs['limit']) == $lt) $selected = 'selected="selected"';
							echo '<option value="',$lt,'" ',$selected,'>',$lt,'</option>';
						}
						echo '</select> ', 'results per page';
						?>
					</td>
				</tr>
				<tr>
					<td align="center" class="footer">
						<input type="submit" value="Search Jobs" class="jobs_search_submit">
					</td>
				</tr>
			</table>
			
			<input type="hidden" name="from" value="0">
			<input type="hidden" name="module_page" value="my_jobs">
			<input type="hidden" name="jobs_step" value="jobs_job_list"/>
			<input type="hidden" name="jobs[search]" value="yes"/>
			</form>
			
			
		</div>
		<div class="advertize_resumes">
			<div class="adv_container_resumes">
				<p class="title"><?php echo 'Be discovered!';?></p>
				<?php
				if(!isset($_SESSION['member_id'])) {
					?>
					<p><?php echo 'Log In or ', '<a href="index.php?module_page=add_member">', 'Sign Up', '</a> ', 'to post your Resume.';?></p>
					<?php
				}
				else {
					?>
					<p><?php echo '<a href="index.php?module_page=my_jobs&amp;jobs_step=jobs_add_cv">', 'Post Resume!', '</a> '; ?></p>
					<?php
				}
				?>
				<p class="slogan"><?php echo "It's easy and <strong>FREE</strong>!";?></p>
			</div>
		</div>
	</div>
	<div id="resumes_srch_container">
		
		<div class="resumes_srch_label"><?php echo '<h1>', 'Employers', '</h1>';?></div>
		<div class="main_jobs_search main_resumes_search">
			
			<form method="post" action="index.php" name="resumes_search_frm" id="resumes_search_frm">
			<table cellpadding="0" cellspacing="0" border="0">
				<tr>
					<td class="itdh" width="50%"><?php echo 'Job Category';?></td>
				</tr>
				<tr>
					<td class="itd">
						<select name="cv[job_cat_id]" class="setwidth">
							<option value=""><?php echo 'Select Category';?></option>
							<?php
							$qexl = "select * from job_cat where active='yes' order by order_seq asc;";
							$rexl = @mysql_query($qexl);
							if($rexl && mysql_num_rows($rexl) > 0) {
								while ($rowexl = mysql_fetch_assoc($rexl)){
									$selected = '';
									if($cv['job_cat_id'] == $rowexl['job_cat_id']) $selected = ' selected="selected"';
									echo '<option value="',trim($rowexl['job_cat_id']),'" ',$selected,'>', stripslashes($rowexl['title_en']), '</option>';
								}
							}
							?>
						</select>
					</td>
				</tr>
				
				<tr>
					<td class="itdh" width="50%" nowrap="nowrap"><?php echo 'Location';?></td>
				</tr>
				<tr>
					<td class="itd">
						<select name="cv[JobLocation]" class="setwidth">
							<option value=""><?php echo 'Any'?></option>
							<?php
							foreach ($locations as $loc) {
								$selected = '';
								if($cv['JobLocation'] == $loc) $selected = 'selected="selected"';
								echo '<option value="',$loc,'" ',$selected,'>', $loc, '</option>';
							}
							?>
						</select>
					</td>
				</tr>
				<tr>
					<td class="itdh" width="50%" nowrap="nowrap"><?php echo 'Posted';?></td>
				</tr>
				<tr>
					<td class="itd">
						<select name="cv[posted]" class="setwidth">
							<option value="all" selected="selected">Any Time</option>
							<?php
							$posted_vals = array(
								'0' => 'Today',
								'1' => 'Yesterday',
								'7'	=> 'Last 7 Days',
								'30'=> 'Last 30 Days'
								
							);
							foreach ($posted_vals as $pv=>$pv_title) {
								$selected = '';
								if($cv['posted'] != "all" && $cv['posted'] == $pv) $selected = 'selected="selected"';
								echo '<option value="',$pv,'" ',$selected,'>', $pv_title, '</option>';
							}
							?>
						</select>
					</td>
				</tr>
				
				<tr>
					<td class="itdh" width="50%" nowrap="nowrap">&nbsp;</td>
				</tr>
				<tr>
					<td class="itd">
						&nbsp;
					</td>
				</tr>
				
				<tr>
					<td align="left" class="itd">
						<?php
						echo 'Show', ' ';
						echo '<select name="cv[limit]" style="vertical-align:middle;">';
						$limit_ar = array('10', '15', '20', '25', '30', '50');
						foreach ($limit_ar as $lt) {
							$selected = '';
							if(strval($cv['limit']) == $lt) $selected = 'selected="selected"';
							echo '<option value="',$lt,'" ',$selected,'>',$lt,'</option>';
						}
						echo '</select> ', 'results per page';
						?>
					</td>
				</tr>
				<tr>
					<td align="center" class="footer">
						<input type="submit" value="Search Resumes" class="jobs_search_submit">
					</td>
				</tr>
			</table>
			
			<input type="hidden" name="from" value="0">
			<input type="hidden" name="module_page" value="my_jobs">
			<input type="hidden" name="jobs_step" value="jobs_cv_list"/>
			<input type="hidden" name="cv[search]" value="yes"/>
			</form>
			
		</div>
		<div class="advertize_resumes advertize_jobs">
			<div class="adv_container_jobs">
				<p class="title"><?php echo 'Have job openings?';?></p>
				<?php
				if(!isset($_SESSION['member_id'])) {
					?>
					<p><?php echo 'Log In or ', '<a href="index.php?module_page=add_member">', 'Sign Up', '</a> ', 'to post your jobs.';?></p>
					<?php
				}
				else {
					?>
					<p><?php echo '<a href="index.php?module_page=my_jobs&amp;jobs_step=jobs_add">', 'Post Jobs!', '</a> '; ?></p>
					<?php
				}
				?>
				
				
				<p class="slogan"><?php echo "It's easy and <strong>FREE</strong>!";?></p>
			</div>	
		</div>
	</div>
	<div style="clear:both;"></div>
</div>