<?php

  if($_REQUEST['vacid']!=''){
 if(DB_query("DELETE FROM hr_applcnt_rgstn WHERE id='".$_REQUEST['vacid']."' and status='pending'",$db)){
  DB_query("DELETE FROM hr_applcnt_rgstn_experience WHERE hr_applcnt_rgstn_id='".$_REQUEST['vacid']."'",$db);
   DB_query("DELETE FROM hr_applcnt_rgstn_ref WHERE hr_applcnt_rgstn_id='".$_REQUEST['vacid']."'",$db);
   $s->pageLocation("index.php?route=HRModule/Master/application_registrartion_index".$rurl);
 }
}

//$s->DeleteRecord(hr_applcnt_rgstn,$condition);
?>

<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div"> 
<h1>Applicant Registration</h1>	
<p align="left"><a href="<?php //echo "index.php?route=HRModule/Master/application_registration".$rurl ?>"> </a><div id="b2" style="text-align:left" ><button type="button" id="button2" >Add Applicant</button></div>
<div id="b1" style="text-align:left;display: none;" ><button type="button" id="button1"  >Back</button></div>
</p>
<div id="job_created" style="display: none;">
<table width="100%" cellpadding="3" cellspacing="0" border="1" style="border:#808080 1px solid;">
<tr>
        <th width="3%"><strong>S. No.</strong></th>
        <th><strong>Branch</strong></th>
        <th width="12%"><strong>Designation</strong></th>
        <th width="12%"><strong>Department</strong></th>
        <th width="8%"><strong>Job Type</strong></th>
        <th width="10%"><strong>Vacancy Code</strong></th>
        <th width="10%"><strong>Job Post Code</strong></th>
        <th width="7%"><strong>Job Posted Date</strong></th>
        <th width="5%" style="text-align:center;"><strong>Action</strong></th>
        <th width="5%" style="text-align:center;"><strong>Print</strong></th>       
</tr>
<tr>
<!--<tr><th colspan="5"></th><td><table><tr><th>Designation</th><th>Department</th><th>Required</th></tr></table></td></tr>-->
</tr>
<?php $i=0; 

//$SQL=DB_query("SELECT a.id as ids,a.vacancy_code,a.branch,a.job_type,b.* FROM hr_job_created a, hr_job_created_details b where b.posting_status='y' and a.id=b.parentid and a.schedule_status='1'",$db);
$SQL=DB_query("SELECT a.id as ids,a.vacancy_code,a.branch,a.job_type,b.* FROM hr_job_created a, hr_job_created_details b where b.posting_status='y' and a.id=b.parentid",$db);


if(DB_num_rows($SQL)>0){
while($GetRec=DB_fetch_array($SQL)) {?>
<?php if($GetRec['schedule_status']=='1') $p="#f0fff5"; else $p="#fff6e9";?>
<tr style="background-color: <?php echo $p; ?>">
    <td><?php echo $i+1; ?></td>
    <td><?php echo $sitename=$s->GetFieldValue('locations',"loccode='".$GetRec['branch']."'",'locationname'); ?></td>
    <td><?php $desig= DB_fetch_assoc(DB_query("select * from desigmaster where id='".$GetRec['designation']."' ",$db)); echo $desig['designame'];?></td>
    <td><?php $dept= DB_fetch_assoc(DB_query("select * from deptmaster where id='".$desig['mst_departmentid']."' ",$db)); echo $dept['deptname']; ?></td>
    <td><?php if($GetRec['job_type']=="p"){ echo "Permanent"; } else if($GetRec['job_type']=="c"){ echo "Contract" ;} ?></td>
    <td><?php echo $GetRec['vacancy_code']; ?></td>
    <td><?php echo $GetRec['job_number']; ?></td>
    <td><?php echo ConvertSQLDate($GetRec['posting_date']); ?></td>
    <td style="text-align:center;"><a href="<?php echo "index.php?route=HRModule/Master/application_registration".$rurl."&design=".$GetRec['designation']."&dept=".$desig['mst_departmentid']; ?>&jobpoid=<?php echo $GetRec['ids']; ?>" target="_blank" title="Vacancy Profile">ADD</a></td>
    <td style="text-align:center;"><a href="print_job_posting.php?post_vac=<?php echo $GetRec['ids'] ?>" target="_blank" title="Vacancy Profile"><img src="images/icon_print.jpg" width="22" height="22"></a></td>
        <!--<td width="35%"><table border="1" width="100%">
    <?php // $detsql=DB_query("select * from hr_job_created_details where parentid='".$GetRec['id']."' ",$db);  
    //  while($detres=DB_fetch_assoc($detsql)){?>
                <tr><td><?php $desig= DB_fetch_assoc(DB_query("select * from desigmaster where id='".$detres['designation']."' ",$db)); echo $desig['designame'];?></td>
                    <td><?php $dept= DB_fetch_assoc(DB_query("select * from deptmaster where id='".$desig['mst_departmentid']."' ",$db)); echo $dept['deptname']; ?></td>
                    <td><?php echo $detres['required']; ?></td>
                    <td><input type="button" value="Job Post"></td>
                </tr> 
      <?php // } ?>
            </table></td>-->
</tr>
<?php $i++;} }else{?>
<tr>
    <td colspan="5">No Result Found.</td>
</tr>
<?php } ?>
</table>
</div>
<div id="appareg">

 <form name="search" action="" method="post">
<table width="100%" cellspacing="0" cellpadding="3" border="0" align="center">
  <tbody><tr class="row1">
    <td width="15%"><strong>Department</strong></td>
    <td width="35%"><select id="dept" name="dept" onchange="getdesign(this.value)">
    <option value="0">Select Department</option>
       <?php  $dept1=DB_query("SELECT * FROM `deptmaster` order by deptname",$db);?>
                 <?php   while($DeptRec1=DB_fetch_array($dept1)) { ?>
          <option value="<?php echo $DeptRec1['id']; ?>" <?php if($_REQUEST['dept']==$DeptRec1['id']){ echo "selected" ;} ?>><?php echo $DeptRec1['deptname']; ?></option>
          <?php } ?>
      </select></td>
    <td width="15%"><strong>Designation</strong></td>
    <td> 
      <select id="design" name="design">              
      <option value="0">Select Designation</option>
      <?php  $design1=DB_query("SELECT * FROM `desigmaster` order by designame",$db);?>
                 <?php   while($designRec1=DB_fetch_array($design1)) { ?>
          <option value="<?php echo $designRec1['id']; ?>" <?php if($_REQUEST['design']==$designRec1['id']){ echo "selected"; } ?>><?php echo $designRec1['designame']; ?></option>
          <?php } ?>
        
         </select>
      </td>
    </tr>
    <tr class="row1">
  <td><strong>From</strong></td>
   <td class="demo"><input type="text"  placeholder="from Date 10/12/2015" value="<?php echo $_REQUEST['from_date']; ?>" class="datepicker" name="from_date" id="from_date"></td>
   <td><strong>To</strong></td>
   <td><input type="text" value="<?php echo $_REQUEST['to_date']; ?>" placeholder="To Date 10/12/2015" class="datepicker" name="to_date" id="to_date"></td>
</tr>
<tr class="row1">
  <td><strong>Experience</strong></td>
   <td class="demo"><input type="text" value="<?php echo $_REQUEST['exper']; ?>"  placeholder="Experience" name="exper" id="exper"></td>
   <td> <strong>Email id</strong></td>
   <td><input type="text" value="<?php echo $_REQUEST['email']; ?>"  placeholder="emailid" name="email" id="email" ></td>
</tr>
<tr class="row1">
  <td><strong>Keyword</strong></td>
   <td class="demo"><input type="text" value="<?php echo $_REQUEST['key_word']; ?>"  placeholder="keyword" name="key_word" id="key_word"></td>
   <td></td>
   <td></td>
</tr>
<tr class="row1">
  <td style="text-align:center;" colspan="4"><input type="submit" value="Search" class="search" name="Search">
  </td>
</tr>
</tbody></table>
</form>

<table width="100%" cellpadding="3" cellspacing="0" border="1">
<tr>
  <th width="3%"><strong>S. No.</strong></th>
	<th><strong>Name</strong></th>
  <th width="15%"><strong>Email</strong></th>
  <th width="8%"><strong>Application Date</strong></th>
  <th width="7%"><strong>Experience</strong></th>
  <th width="7%"><strong>Date of Birth</strong></th>
  <th width="12%"><strong>Department</strong></th>
	<th width="12%"><strong>Designation</strong></th>
  <th colspan="2" style="text-align:center;"><strong>Action</strong></th>       
</tr>
 


<?php

if($_REQUEST['Search']!=''){

  $filter[]="1=1";
if($_REQUEST['dept']!='0')
  {
  $filter[]="department='".$_REQUEST['dept']."'";
  }
  if($_REQUEST['design']!='0' && $_REQUEST['design']!='')
  {
  $filter[]="designation='".$_REQUEST['design']."'";
  }
  if($_REQUEST['exper']!='')
  {
  $filter[]="total_experience >='".$_REQUEST['exper']."'";
  }

if($_REQUEST['email']!='')
  {
  $filter[]="email1 ='".$_REQUEST['email']."'";
  }
  if($_REQUEST['key_word']!='')
  {
  $filter[]="document LIKE '%".$_REQUEST['key_word']."%'";
  }
  if($_REQUEST['from_date']!='' && $_REQUEST['to_date']!='')
  $filter[]="created_date between '".FormatDateForSQL($_REQUEST['from_date'])."' and '".FormatDateForSQL($_REQUEST['to_date'])."'";
  }

if(!empty($filter))
  {
  
    $filter1 = implode(" and ",$filter);

    $SQL=DB_query("SELECT id,first_name,middle_name,email1,last_name,created_date,dob,department,designation,total_experience FROM hr_applcnt_rgstn where  $filter1 and companyid='".$_SESSION['ACGCompanyId']."' ",$db);
}else{

   $SQL=DB_query("SELECT id,first_name,middle_name,last_name,created_date,dob,department,designation,total_experience,email1 FROM hr_applcnt_rgstn where  companyid='".$_SESSION['ACGCompanyId']."' ",$db);
}

 $i=0; 
if(DB_num_rows($SQL)>0){
while($GetRec=DB_fetch_array($SQL)) {?>
<tr>
	<td><?php echo $i+1; ?></td>
	<td><?php echo $GetRec['first_name'] .' '.$GetRec['middle_name'].' '.$GetRec['last_name']; ?></td>
  <td><?php echo $GetRec['email1'] ; ?></td>
  <td><?php echo ConvertSQLDate($GetRec['created_date']); ?></td>
  <td><?php echo $GetRec['total_experience']; ?></td>
  <td><?php echo ConvertSQLDate($GetRec['dob']); ?></td>
  <td><?php  $dept= DB_fetch_assoc(DB_query("select * from deptmaster where id='".$GetRec['department']."' ",$db)); echo $dept['deptname'];  ?></td>
  <td><?php  $desig= DB_fetch_assoc(DB_query("select * from desigmaster where id='".$GetRec['designation']."' ",$db)); echo $desig['designame'];?></td>
  <td style="text-align:center;"><a href="index.php?route=HRModule/Master/application_registration_edit&modid=<?php echo $_REQUEST['modid'] ?>&frmid=<?php echo $_REQUEST['frmid'] ?>&vacid=<?php echo $GetRec['id'] ?>"><img width="15" height="15" title="Edit Document" src="images/icon-edit.png"></a></td>
  <td style="text-align:center;">
    <a href="index.php?route=HRModule/Master/application_registrartion_index&modid=<?php echo $_REQUEST['modid'] ?>&frmid=<?php echo $_REQUEST['frmid'] ?>&vacid=<?php echo $GetRec['id'] ?>&action=delete"><img width="15" height="15" title="Delete Document" src="images/Icon_Delete.png"></a>
  </td>        
</tr>
<?php $i++;} }else{?>
<tr>
    <td colspan="5">No Result Found.</td>
</tr>
<?php } ?>
</table>
</div>
</div>
</div>
<script>
$(function() {
$("#button2").click(function(){
//alert();
   $("#appareg").hide();
     //$('#job_created').css('display', 'none');
    // $('#appareg').css('display', 'block');
   $("#job_created").show();
   $("#b1").show();
   $("#b2").hide();
});

$("#button1").click(function(){

//alert();
   $("#appareg").show();
     //$('#job_created').css('display', 'none');
    // $('#appareg').css('display', 'block');
   $("#job_created").hide();
   $("#button2").show();
   $("#b2").show();
   $("#b1").hide();

});

});


function getdesign(str)
{
 //alert(str);
   $.ajax({
       url:"ajax_get_designation.php",
       type:"GET",
       //data:{aCatId:aCatId,compId:compId,areaId:areaId,topicId:topicId},
       data:{t:str},
       success:function(resultold_question){
            $("#design").html(resultold_question);
       }

   });
}
</script>