<?php
error_reporting(0);
$conn = mysqli_connect('localhost','menahrs_oxy','OxyApp@2023');
        mysqli_select_db($conn,'menahrs_oxy');
$mode = $_POST['mode'];
$posit = $_POST['posit'];
$natio = $_POST['natio'];
$region = $_POST['regi'];
$coun = $_POST['cou'];

/*if($mode==1){
if($positi==13){
echo '<option value="">SELECT</option>';
echo '<option value="1">Diploma</option>';
}else{
echo '<option value="">SELECT</option>';
echo '<option value="2">Bachelors</option>';
}
}*/

if($mode==2){
$rsReg = mysqli_query($conn,"SELECT * FROM cm_wilayat WHERE region_id='$region'");
echo '<option value="">SELECT</option>';
	while($rwReg = mysqli_fetch_array($rsReg))
	{ ?>
		<option value="<?php echo $rwReg['id'];?>"><?php echo $rwReg['wilayat'];?></option>
	<?php } 
}

if($mode==4){
$rsCou = mysqli_query($conn,"SELECT * FROM cm_country WHERE country_id='$coun'");
$rwCou = mysqli_fetch_array($rsCou);
$code = $rwCou['calling_code'];
echo '<input type="text" name="gsm_code" id="gsm_code" value="'.$code.'" size="5">';
}

/*if($mode==3){
$rsDisc = mysqli_query($conn,"SELECT * FROM cm_discipline WHERE joborder_id='$pos'");
echo '<option value="">SELECT</option>';
	while($rwDisc = mysqli_fetch_array($rsDisc))
	{ ?>
		<option value="<?php echo $rwDisc['id'];?>"><?php echo $rwDisc['discipline'];?></option>
	<?php } 
}*/

if($mode==5){
$rsCount = mysqli_query($conn,"SELECT c.title, a.applicant_id FROM candidate a, candidate_joborder b, joborder c WHERE a.candidate_id=b.candidate_id AND a.national_id='$natio' AND b.joborder_id='$posit' AND b.joborder_id=c.joborder_id");
$rwCount = mysqli_fetch_array($rsCount);
$dup_cnt = mysqli_num_rows($rsCount);
if($dup_cnt>=1){
echo $rwCount['title'] . "~" . $rwCount['applicant_id'];
}else {
echo 0;
}
}

/* NEW CODE ADDED ON 03/04/2018 FOR NEW FIELD*/

if($mode==6){

$dept =$_POST['dept'];

$sql =      "	SELECT j.*,d.* FROM joborder j
		JOIN company_discipline d ON d.company_department_id = j.company_discipline_id
		WHERE j.company_department_id = '$dept' group by d.company_department_id  ";
$rsDisc = mysqli_query($conn,$sql);

echo '<option value="">SELECT</option>';
	while($rwDisc = mysqli_fetch_array($rsDisc)){ ?>
		<option value="<?php echo $rwDisc['company_discipline_id'];?>"><?php echo $rwDisc ['name'];?></option>
	<?php } 


}


if($mode==7){

$dept = $_POST['dept'];
$disp = $_POST['disp'];

$sql 	=      "SELECT * FROM joborder where status='Active' AND company_discipline_id ='$disp' AND company_department_id='$dept' ORDER BY seq_id ";
$rsDisc = 	mysqli_query($conn,$sql);

echo '<option value="">SELECT</option>';
	while($rwDisc = mysqli_fetch_array($rsDisc)){ ?>
		<option value="<?php echo $rwDisc['joborder_id'];?>"><?php echo $rwDisc ['title'];?></option>
	<?php } 


}
if($mode == 8){

	$jobid = $_POST['jobid'];
	$attachmentURL ="http://epchiring.com/camp1/rpms/attachments/";
	$sql = mysqli_query($conn,"SELECT * FROM attachment WHERE data_item_id = $jobid");
	while($attach = mysqli_fetch_array($sql)){
	$fileName = $attachmentURL.$attach ['directory_name'].$attach['stored_filename'];
	
	echo '<a href="'.$fileName.'" download="JD PDF" >Download JD</a>';
	}
}

/* END OF CODE*/

?>
                            
                            
                            
                            
                            
                            