<?php 
error_reporting(0);
$PageSecurity = 2;
$_SESSION['modid']=$_REQUEST['modid'];
$_SESSION['frmid']=$_REQUEST['frmid'];
$frmpermission= $px->GetFileAccess($_SESSION['modid'],$_SESSION['frmid'],$_SESSION['ACGRoleId']);
$_SESSION['frmAdd']=$frmpermission[0];
$_SESSION['frmEdit']=$frmpermission[1];
$_SESSION['frmDelete']=$frmpermission[2];
$_SESSION['frmView']=$frmpermission[3];

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['vacid']!=''){

    $dataArr['status']=$_REQUEST['status'];
    $condd="id='".$_REQUEST['vacid']."'";

   // print_r($dataArr);
   // die;
    $s->RecordEdit('hr_applcnt_rgstn',$dataArr,$condd);
    $dataArr1['status']=$_REQUEST['status'];
    $dataArr1['awd_application_id']=$_REQUEST['vacid'];
    $dataArr1['created_by']=$_SESSION['UserID'];    
    $dataArr1['datetime']=date('Y-m-d H:i:s');
    $s->RecordInsert('hr_applcnt_rgstn_log_status',$dataArr1);
    $s->pageLocation('index.php?route=HRModule/Master/applicant_shortlisting&modid='.$_REQUEST['modid'].'&frmid='.$_REQUEST['frmid'].'');

}

//print_r($filter);

 ?>

<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div">
<h1>Applicant Shortlisting</h1>

<div class="new_tab">
<div class="inside_tab">
  <ul>
    <li><a href="index.php?route=HRModule/Master/applicant_shortlisting&modid=<?php echo  $_REQUEST['modid']?>&frmid=<?php echo $_REQUEST['frmid']?>&tab=1&status=pending">Pending</a></li>
   <!-- <li><a href="index.php?route=HRModule/Master/applicant_shortlisting&modid=<?php echo  $_REQUEST['modid']?>&frmid=<?php echo $_REQUEST['frmid']?>&tab=2&status=rejected">Rejected</a></li>-->
      <li><a href="index.php?route=HRModule/Master/applicant_shortlisting&modid=<?php echo  $_REQUEST['modid']?>&frmid=<?php echo $_REQUEST['frmid']?>&tab=3&status=hold">Hold</a></li>
         <!--<li><a href="index.php?route=HRModule/Master/applicant_shortlisting&modid=<?php echo  $_REQUEST['modid']?>&frmid=<?php echo $_REQUEST['frmid']?>&tab=1&status=shortlist">Shortlist</a></li>-->
  </ul>
</div>
</div>


<h3>Application <?php if($_REQUEST[status]!="") { echo ucfirst($_REQUEST[status]); } else { echo "Pending"; }?></h3>  
  <form name="search" action="" method="post">
<table width="100%" cellspacing="0" cellpadding="3" border="0">
  <tbody>
  <tr class="row1">
    <td width="13%"><strong>Department</strong></td>
    <td width="35%"><select id="dept" name="dept" onchange="leaveChange(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($DeptRec1['id']==$_REQUEST['dept']){ echo "selected";}?>><?php echo $DeptRec1['deptname']; ?></option>
          <?php } ?>
      </select></td>
    <td width="13%"><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($designRec1['id']==$_REQUEST['design']){ echo "selected";}?>><?php echo $designRec1['designame']; ?></option>
          <?php } ?>        
         </select>
      </td>
    </tr>
<tr class="row1">
  <td><strong>Experience</strong></td>
   <td class="demo"><input type="text" value="<?php echo $_REQUEST['exper']; ?>" 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>

<table width="100%" cellpadding="3" cellspacing="0" border="1" style="border:#808080 1px solid; border-collapse:collapse;">
<tr>
  <th rowspan="2" width="4%"><strong>S. No.</strong></th>
  <th rowspan="2"><strong>Applicant Name</strong></th>
  <th rowspan="2" width="10%"><strong>Contact No.</strong></th>
  <th rowspan="2" width="12%"><strong>Email</strong></th>
  <th rowspan="2" width="8%"><strong>Total Experience</strong></th>
  <th colspan="2" width="7%" style="text-align:center;"><strong>Resume</strong></th>
  <th rowspan="2" width="18%" style="text-align:center;"><strong>Action</strong></th>
</tr>
<tr>
  <th width="5%" style="text-align:center;">Download</th>
  <th width="5%" style="text-align:center;">View</th>
</tr>

<?php $i=0; 
     
  if(!empty($filter))
  {
  
    $filter1 = implode(" and ",$filter);
   // echo $filter1;

if($_REQUEST[status]!=""){



    $SQL1=DB_query("SELECT hr_job_created_id, designation, department, total_experience, count(*) as totalresume FROM hr_applcnt_rgstn where $filter1 and  status='".$_REQUEST[status]."' group by hr_job_created_id",$db);
  }
  else{

   
     $SQL1=DB_query("SELECT hr_job_created_id, designation, department, total_experience,count(*) as totalresume FROM hr_applcnt_rgstn where  $filter1 and status='pending' group by hr_job_created_id",$db);
  }
}
else{
if($_REQUEST[status]!=""){
    $SQL1=DB_query("SELECT hr_job_created_id, designation, total_experience, department,count(*) as totalresume FROM hr_applcnt_rgstn where  status='".$_REQUEST[status]."' group by hr_job_created_id",$db);
  }
  else{
      
     $SQL1=DB_query("SELECT hr_job_created_id, designation,department,count(*) as totalresume FROM hr_applcnt_rgstn where  status='pending' group by hr_job_created_id",$db);
  }

}
     if(DB_num_rows($SQL1)>0){  
while($GetRec1=DB_fetch_array($SQL1)) {?>

<tr bgcolor="#e4e4e4">
  <td colspan="2"><strong>VCode :</strong> <?php 
            echo $s->GetFieldValue("hr_job_created","id='".$GetRec1['hr_job_created_id']."'","vacancy_code"); ?>
      </td>
  <td colspan="2"><strong>Department :</strong> <?php $dept= DB_fetch_assoc(DB_query("select * from deptmaster where id='".$GetRec1['department']."' ",$db)); echo $dept['deptname']; ?></td>
  <td colspan="3"><strong>Designation :</strong> <?php $desig= DB_fetch_assoc(DB_query("select * from desigmaster where id='".$GetRec1['designation']."' ",$db)); echo $desig['designame'];?></td>
  <td style="text-align:center;"><strong>Total Resume <?php echo $GetRec1['totalresume']; ?></strong></td>  
</tr>

<?php 

    
  if(!empty($filter))
  {
  
    $filter1 = implode(" and ",$filter);
if($_REQUEST[status]!=""){
$SQL=DB_query("SELECT * FROM hr_applcnt_rgstn where $filter1 and status='".$_REQUEST[status]."' and hr_job_created_id='".$GetRec1['hr_job_created_id']."'",$db);
}else{
  $SQL=DB_query("SELECT * FROM hr_applcnt_rgstn where  $filter1 and status='pending'   and hr_job_created_id='".$GetRec1['hr_job_created_id']."'",$db);
}
}else{
if($_REQUEST[status]!=""){
$SQL=DB_query("SELECT * FROM hr_applcnt_rgstn where  status='".$_REQUEST[status]."' and hr_job_created_id='".$GetRec1['hr_job_created_id']."'",$db);
}else{
  $SQL=DB_query("SELECT * FROM hr_applcnt_rgstn where status='pending'  and hr_job_created_id='".$GetRec1['hr_job_created_id']."'",$db);
}

}
 

while($GetRec=DB_fetch_array($SQL)) {?>
<tr bgcolor="#fff">
    <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['total_experience']; ?></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>
      <!--<a href="uploaded_docs/<?php echo $GetRec['attach_file']; ?>"target="_blank" title="Vacancy Profile"><img src='images/search.png' width="15" height="15" title="View Document" /></a>-->
     <!-- <input type="button" name="LeaveApplly" id="LeaveApplly_<?php echo $i; ?>" class="ApplyLeaveIcon" <?php echo $disable; ?> />-->
    </td>
    <td style="text-align:center;"><a href="index.php?route=HRModule/Master/applicant_shortlisting&modid=<?php echo $_REQUEST['modid'] ?>&frmid=<?php echo $_REQUEST['frmid'] ?>&vacid=<?php echo $GetRec['id'] ?>&status=rejected"><input type="button" value="Reject" class="search" /></a>
      <a href="index.php?route=HRModule/Master/applicant_shortlisting&modid=<?php echo $_REQUEST['modid'] ?>&frmid=<?php echo $_REQUEST['frmid'] ?>&vacid=<?php echo $GetRec['id'] ?>&status=hold"><input type="button" value="Hold" class="search" /></a>
      <a href="index.php?route=HRModule/Master/applicant_shortlisting&modid=<?php echo $_REQUEST['modid'] ?>&frmid=<?php echo $_REQUEST['frmid'] ?>&vacid=<?php echo $GetRec['id'] ?>&status=shortlisted"><input type="button" value="Shortlist" class="search" /></a>
     <!-- <a href="index.php?route=HRModule/Master/applicant_shortlisting&modid=<?php echo $_REQUEST['modid'] ?>&frmid=<?php echo $_REQUEST['frmid'] ?>&vacid=<?php echo $GetRec['id'] ?>&status=pending"><input type="button" value="pending" ></a>-->
    </td>  
</tr>
<?php $i++;}} }else{?>
<tr>
    <td colspan="8">No Result Found.</td>
</tr>
<?php } ?>
</table>
</div>
</div>
<script type="text/javascript" src="js/css-pop.js"></script>
<script>

function leaveChange(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({
        title:'Resume',
        modal: true,
        resizable: false,
        width:900,
        height:700,
        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>
<div id="PickedItems"></div>
<div id="blanket" style="display:none;"></div>
<div id="popUpDiv" style="display:none;">
    
      <a href="#" onclick="popup('popUpDiv')" >X</a>
        <?php 
        /* if($filewidth!='')
        {
       include("filedownload.php");
    $filename = $pr[1];

    $content = read_file_docx($filewidth);
    if($content !== false) {


        echo "<pre>".$content."</pre>";   
    }
    else {
        echo 'Couldn\'t find the file. Please check that file.';
    }
  }
*/
         ?>
  </div>
  