<link rel="stylesheet" href="css/new_mxerp.css">

<form name="search" action="" method="post">
<div class="body_contain">
<div class="tab_div"> 

<h1>Reference Acknowledgement</h1>

<?php 
$qu=DB_fetch_array(DB_query("SELECT no_of_assignee FROM conf_interview_approval",$db));
$no_assign=$qu['no_of_assignee'];
?>
<form>
<p style="text-align:left;">
<?php  $url='&modid='.$_REQUEST['modid'].'&frmid='.$_REQUEST['frmid'];?>
<a href='index.php?route=HRModule/Master/reference_aknow<?php echo$url; ?>'>
  <input class="search" type="button" value="Pending"></a>
  <a href='index.php?route=HRModule/Master/Reference_rejected<?php echo$url; ?>'>
  <input class="search" type="button" value="Rejected"></a>
  <a href='index.php?route=HRModule/Master/reference_hold<?php echo$url; ?>'>
  <input class="search" type="button" value="Hold"></a>
  <a href='index.php?route=HRModule/Master/reference_ackowledge<?php echo$url; ?>'>
  <input class="search" type="button" value="Acknowledged"></a>
</p>
<table width="70%" cellspacing="0" cellpadding="3" border="0" align="center">
  <tbody><tr class="row1">

    <td width="15%" class="tabledata1"><strong>Department</strong></td>
    <td width="35%"><select style="width:100%;" id="dept" name="dept" onchange="get_designation(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="15%" class="tabledata1"><strong>Designation</strong></td>
    <td width="35%"> 
      <select style="width:100%;" id="design" name="design" onchange="get_applicant(this.value)">              
      <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 width="15%" class="tabledata1"><strong>Applicant </strong></td>
    <td width="35%"> 
      <select style="width:100%;" id="applicant" name="applicant">              
      <option value="">Select Applicant </option>
         <?php $SQL12=DB_query("SELECT id,first_name,middle_name,last_name FROM hr_applcnt_rgstn where status='accept' and conf_int_app_details_seq ='".$no_assign."'",$db);
                         while($GetRec12=DB_fetch_array($SQL12)) {

        ?>
        <option value="<?php echo $GetRec12['first_name'];?>"><?php echo $GetRec12['first_name']." ".$GetRec12['middle_name']." ".$GetRec12['last_name']; ?></option>
          <?php  } ?>        
         </select>
      </td>
    </tr>

<tr class="row1">
  <td style="text-align:center;" colspan="6"><input type="submit" onclick="return frmvalidate();" value="Search" class="search" name="Search">
  </td>
</tr>
</tbody></table>
<?php
//if(in_array($_SESSION['UserID'],$Explode))
//{

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

  //$filter[]="1=1";
if($_REQUEST['dept']!='0')
  {
  $filter[]="b.department='".$_REQUEST['dept']."'";
  }
  if($_REQUEST['design']!='0' && $_REQUEST['design']!='')
  {
  $filter[]="b.designation='".$_REQUEST['design']."'";
  }
  if($_REQUEST['applicant']!='')
  {
  $filter[]="b.first_name='".$_REQUEST['applicant']."'";
  }
}
if($filter!='')
  {
  
    $filter1 = implode(" and ",$filter);
    
   $SQL=DB_query("SELECT a.*,b.*,b.id AS mainid FROM hr_applcnt_rgstn_log_status a INNER JOIN hr_applcnt_rgstn b ON a.awd_application_id=b.id WHERE $filter1 and a.status='mail'",$db);
    }
else
{
  $SQL=DB_query("SELECT a.*,b.*,b.id AS mainid FROM hr_applcnt_rgstn_log_status a INNER JOIN hr_applcnt_rgstn b ON a.awd_application_id=b.id WHERE a.status='mail'",$db);
}


?>
<div style="width:1250px; overflow:auto; margin:0 auto;">
 <table width="1800" cellpadding="3" cellspacing="0" border="1">
 <tr><td colspan="9"><h3>ACKNOWLEDGED</h3></td></tr>
<tr>
  <th width="3%"><strong>S. No.</strong></th>
  <th><strong>Applicant Name</strong></th>
  <th width="5%"><strong>Contact No</strong></th>
  <th width="12%"><strong>Email</strong></th>
  <th width="6%"><strong>Department</strong></th>
  <th width="12%"><strong>Designation</strong></th>
  <th width="8%"><strong>Job Type</strong></th>
  <th width="160"><strong>Reference Name</strong></th>
  <th width="160"><strong>Reference Mail</strong></th>
  <!--<th width="408" style="text-align:center;"><strong>Action</strong></th>
  <td class="tabledata"><strong>Action</strong></td>-->
</tr>
<?php 
$i=1;
//$SQL=DB_query("SELECT * FROM hr_applcnt_rgstn where $filter1 and status='accept' and conf_int_app_details_seq ='".$oldseq."'"

$qt=DB_num_rows(DB_query("SELECT * FROM hr_applcnt_rgstn_ref where akk_status='ok'",$db));
if($qt>0){
while($GetRec=DB_fetch_array($SQL)) {
  $applicantid=$GetRec['id'];
  ?>
  <tr bgcolor="#fff">
  <td><?php echo $i; ?></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 $s->GetFieldValue("deptmaster","id='".$GetRec['department']."'","deptname") ;?></td>
        <td><?php echo $s->GetFieldValue("desigmaster","id='".$GetRec['designation']."'","designame") ;?></td>
        <td><?php $jobtype= $s->GetFieldValue("hr_job_created","id='".$GetRec['hr_job_created_id']."'","job_type") ;
            if($jobtype=='p'){
              echo "Permanent";
              $emp_type='Permanent';
            }
            if($jobtype=='c'){
              echo "Contract ";
              $emp_type='Contract';
            }

        ?></td>
        <td colspan="3" valign="top" style="padding:0;">
        <div id="amc-tab">
          <table width="100%" border="0" cellpadding="3" cellspacing="0">
          <?php
              $t=1;
            $SQL1=DB_query("SELECT * FROM hr_applcnt_rgstn_ref where hr_applcnt_rgstn_id='".$GetRec['mainid']."' and akk_status='ok'",$db);
              while($GetRec1=DB_fetch_array($SQL1)) {
              
              ?>
         
          <tr>
          <td  width="160"><?php echo $GetRec1['name']; ?></td>
          <td width="160">
          <?php echo $GetRec1['email']; ?></td>
         <!-- <td width="200">
          
          <a href='index.php?route=HRModule/Master/reference_aknow<?php echo$url.'&id='.$GetRec1['id'].'&action='.'hold'; ?>'>
          <input class="search" type="button" value="Hold" name="hold"> </a>
          
          <input class="search" type="button" value="Reject" name="reject">
          
          <input class="search" type="submit" value="ACK" name="ack" onclick="return validate(<?php echo $t; ?> )">
          
          </td>
        <td width="200"><textarea placeholder="Ackowledgement" rows="2" cols="10" name="ackdetails[]" id="ack_<?php echo $t; ?>"></textarea></td>
          </tr>
            <input type="hidden" name="detailsid[]" value="<?php echo $GetRec1['id']; ?>">-->
         
        <?php $t++; } ?>
         </table></div></td>
         
        </tr>
        <?php $i++; } } ?>
</table>
</div>
</div>
</div>
</form>
<?php
/*
if($_REQUEST['action']=='hold' && $_REQUEST['id']!='')
{
$qu=DB_query("UPDATE hr_applcnt_rgstn_ref SET akk_status='hold' WHERE id='".$_REQUEST['id']."'",$db);
$s->pageLocation("index.php?route=HRModule/Master/reference_aknow"."&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']);
}
if($_REQUEST['action']=='reject' && $_REQUEST['id']!='')
{
$qu=DB_query("UPDATE hr_applcnt_rgstn_ref SET akk_status='reject' WHERE id='".$_REQUEST['id']."'",$db);
$s->pageLocation("index.php?route=HRModule/Master/reference_aknow"."&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']);
}

  if($_REQUEST['ack'])
  {
    for($it=0;$it<count($_REQUEST['detailsid']);$it++)
      {
        if($_REQUEST['ackdetails'][$it]!='')
        {
          echo $details=$_REQUEST['ackdetails'][$it];
          echo $mid=$_REQUEST['detailsid'][$it];
      $qu=DB_query("UPDATE hr_applcnt_rgstn_ref SET akk_status='ok',aknowlede='".$details."' WHERE id='".$mid."'",$db);
       } 
       }
  $s->pageLocation("index.php?route=HRModule/Master/reference_aknow"."&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']);        
  }
  //echo "<pre>";
 // print_r($_REQUEST['ackdetails']);
*/
?>

<script type="text/javascript">
  function validate(str)
  {
   //alert(str);
    var x=document.getElementById('ack_'+str).value;
    if(x=='')
    {
    alert('please Enter ackowledgement');
    return false;
  }
  }
</script>