<?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 Report</h1>	
<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 style="width:98%;" 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 style="width:98%;" 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>Name</strong></td>
      <td><input type="text"  placeholder="Name" value="<?php echo $_REQUEST['name']; ?>" style="width:98%;" name="name" id="name"></td>
      <td><strong>Mobile</strong></td>
      <td><input type="text"  placeholder="Mobile" value="<?php echo $_REQUEST['mobile']; ?>" style="width:98%;" name="mobile" id="mobile"></td>
    </tr>
    <tr class="row1">
      <td><strong>Keyword</strong></td>
      <td><input type="text" placeholder="keyword" value="<?php echo $_REQUEST['keyword']; ?>" style="width:98%;" name="keyword" id="keyword"></td>
      <td colspan="2"></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" style="width:100%;" 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" style="width:100%;" 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"style="width:100%;" name="exper" id="exper"></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>

<p align="right"><a target="_blank" href="register_shortlist_report_print.php"><input type="button" value="Print" class="Search"></a></p>

<table width="100%" cellpadding="3" cellspacing="0" border="1" style="border:#808080 1px solid;">
<tr>
  <th rowspan="2" width="3%"><strong>S. No.</strong></th>
	<th rowspan="2"><strong>Name</strong></th>
  <th rowspan="2" width="10%"><strong>Mobile</strong></th>
  <th rowspan="2" width="12%"><strong>Email</strong></th>
  <th rowspan="2" width="12%"><strong>Address</strong></th>
  <th rowspan="2" width="10%"><strong>Department</strong></th>
	<th rowspan="2" width="10%"><strong>Designation</strong></th>
  <th rowspan="2" width="10%"><strong>Final Result</strong></th>
  <th rowspan="2" width="10%"><strong>Created By</strong></th>
  <th colspan="2" style="text-align:center;"><strong>Resume</strong></th>
 <!-- <td class="tabledata"><strong>Action</strong></td>-->       
</tr>
<tr>
  <th width="5%" style="text-align:center;">Download</th>
  <th width="5%" style="text-align:center;">View</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['name']!='')
  {
  $filter[]="first_name LIKE '%".$_REQUEST['name']."%'";
  }
   if($_REQUEST['mobile']!='')
  {
  $filter[]="mobile1 LIKE '%".$_REQUEST['mobile']."%'";
  }
  if($_REQUEST['keyword']!='')
  {
  $filter2[]="first_name LIKE '%".$_REQUEST['keyword']."%'";
  $filter2[]="mobile1 LIKE '%".$_REQUEST['keyword']."%'";
  $filter2[]="key_skill LIKE '%".$_REQUEST['keyword']."%'";
  }

  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);
    if($filter2!=''){
    $filter3 = implode(" or ",$filter2);
    }
    if($filter1=='1=1' && $filter3!=''){
      $filter4=$filter1." and ".$filter3;
    }
    else{
      $filter4=$filter1;
    }
 //echo  $filter4;
   $_SESSION['register']="SELECT id,first_name,middle_name,last_name,mobile1,email1,present_address,department,designation,total_experience,city,state,country,pincode,attach_file,key_skill FROM hr_applcnt_rgstn where  $filter4 and companyid='".$_SESSION['ACGCompanyId']."'";
    $SQL=DB_query("SELECT id,first_name,middle_name,last_name,mobile1,email1,present_address,department,designation,total_experience,city,state,country,pincode,attach_file,key_skill FROM hr_applcnt_rgstn where  $filter4 and companyid='".$_SESSION['ACGCompanyId']."' and status !='pending' ",$db);
}else{

    $_SESSION['register']="SELECT id,first_name,middle_name,last_name,mobile1,email1,present_address,designation,department,city,state,country,pincode,attach_file,key_skill FROM hr_applcnt_rgstn where  companyid='".$_SESSION['ACGCompanyId']."'";
   $SQL=DB_query("SELECT id,first_name,middle_name,last_name,mobile1,email1,present_address,designation,department,city,state,country,pincode,attach_file,key_skill FROM hr_applcnt_rgstn where  companyid='".$_SESSION['ACGCompanyId']."' and status !='pending' ",$db);
}

//print_r($_SESSION['register']);
 $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['mobile1']; ?></td>
  <td><?php echo $GetRec['email1']; ?></td>
  <td><?php echo $GetRec['present_address'].",".$GetRec['city']." ,".$GetRec['state'].", ".$GetRec['country'].", ".$GetRec['pincode']; ?></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><?php $finalresult= DB_fetch_assoc(DB_query("select * from hr_applcnt_rgstn_log_status where awd_application_id='".$GetRec['id']."' and status!='pending' order by id desc limit 0,1 ",$db));
      if($finalresult !=''){
      echo $finalresult['status'];
      }
      if($finalresult['conf_int_app_details_seq']!='' and $finalresult['conf_int_app_details_seq']!=0){
          echo " BY ";
      }
    if($finalresult['conf_int_app_details_seq']!=''){
      $screenby= DB_fetch_assoc(DB_query("select * from conf_interview_app_details where seq_no='".$finalresult['conf_int_app_details_seq']."' order by id desc limit 0,1 ",$db));
      echo  $screenby['approval_name'];
    }
    ?></td>
   <td>
    <?php $createdby= DB_fetch_assoc(DB_query("select * from www_users where id='".$finalresult['created_by']."' order by id desc limit 0,1 ",$db));
    echo $createdby['realname']; ?>
   </td>
    <td style="text-align:center;">
    <?php  $filewidth="uploaded_docs/".$GetRec['attach_file']; ?>
             <a href="uploaded_docs/<?php echo $GetRec['attach_file']; ?>"target="_blank" title="Vacancy Profile"><img src="images/download1.png" height="15" width="15" title="Download" /></a>
             <input type="hidden" id="fileA_<?php echo $i;?>" value="<?php echo $GetRec['attach_file'];?>" >
    </td>
    <td style="text-align:center;"><a href="#"><div class="asd" id="file_<?php echo $i;?>"><img src="images/search.png" height="15" width="15" title="View" /></div></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);
       }

   });
}

$(document).ready(function(){ 
    //var cnt=document.getElementById("count").value;
    $('.asd').click(function(){
    var tt=this.id;
    var tt1=tt.split("_");
    var tt2=tt1[1];
    var resume=document.getElementById("fileA_"+tt2).value;
  //  alert(resume);

   // var LeaveType=document.getElementById("LeaveType_"+tt2).value;
    $("#PickedItems").dialog({

         position: { 
            my: "center center",
            at: "center center",
          of: $('#PickedItems')
        },


        title:'Resume',
        modal: true,
        resizable: false,
        width:1200,
        height:500,
        closeText: 'fechar',
        draggable: true,
        show: 'fade',
        hide: 'fade',
        dialogClass: 'main-dialog-class',
        buttons: {
          
          Exit: function()
          {
            $(this).dialog("close");
          }
        }
        
      });
    ApplyForLeave(resume);
    });
  });


function ApplyForLeave(resume)
{
  if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
  else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
  {

    var data=xmlhttp.responseText.split("__");
    document.getElementById("PickedItems").innerHTML=data[0];
    
  }
  }
  xmlhttp.open("GET","open_doc_file.php?resume="+resume,true);
  xmlhttp.send();
}


</script>
<style>


</style>
<div id="PickedItems"></div>
