<?php //error_reporting(0); ?>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div"> 
<form name="search" action="" method="post">
<div id="PickedItems" style="display:none"></div>
<h1>Applicant Confirmation</h1>
<p style="text-align:left;">
<?php  $url='&modid='.$_REQUEST['modid'].'&frmid='.$_REQUEST['frmid'];?>
<table width="100%" cellspacing="0" cellpadding="3" border="0" align="center">
  <tbody>
  <tr class="row1">
    <td width="13%"><strong>Department</strong></td>
    <td width="20%"><select style="width:98%;" 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="13%"><strong>Designation</strong></td>
    <td width="20%"> 
      <select style="width:98%;" 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="13%"><strong>Applicant</strong></td>
    <td> 
      <select style="width:98%;" id="applicant" name="applicant">              
      <option value="0">Select Applicant </option>
         <?php $SQL12=DB_query("SELECT DISTINCT a.hr_applcnt_rgstn_id,b.* FROM hr_applcnt_rgstn_doc a INNER JOIN hr_applcnt_rgstn b ON a.hr_applcnt_rgstn_id=b.id",$db);
                         while($GetRec12=DB_fetch_array($SQL12)) {

        ?>
        <option value="<?php echo $GetRec12['hr_applcnt_rgstn_id'];?>"><?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>
<br>
<?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']!='0')
  {
  $filter[]="b.id='".$_REQUEST['applicant']."'";
  }
}
if($filter!='')
  {
  
    $filter1 = implode(" and ",$filter);
    
   $SQL=DB_query("select distinct a.hr_applcnt_rgstn_id,b.* from hr_applcnt_rgstn_doc a inner join hr_applcnt_rgstn b on a.hr_applcnt_rgstn_id=b.id where $filter1 and b.status='appoint_accept' ",$db);
    }
else
{
  $SQL=DB_query("select distinct a.hr_applcnt_rgstn_id,b.* from hr_applcnt_rgstn_doc a inner join hr_applcnt_rgstn b on a.hr_applcnt_rgstn_id=b.id where b.status='appoint_accept'",$db);
}


?>
 <table width="100%" cellpadding="3" cellspacing="0" border="1" style="border:#808080 1px solid; border-collapse:collapse;">
		 
		<tr bgcolor="#fff">
		  <th width="5%"><strong>S. No.</strong></th>
		  <th><strong>Applicant Name</strong></th>
		  <th width="10%" ><strong>Contact No.</strong></th>
      <th width="10%" ><strong>Department</strong></th>
      <th width="12%" ><strong>Designation</strong></th>
      <th width="10%" ><strong>No. of Total Doc.</strong></th>
      <th width="10%" ><strong>No. of Pending Doc.</strong></th>
      <th width="10%" ><strong>No. of accepted Doc.</strong></th>
		  <th width="10%" style="text-align:center;"><strong>Action</strong></th>
		</tr>

			<?php 
      $i=1;
			while($GetRec=DB_fetch_array($SQL)) {

			$qt=DB_query("select * from hr_applcnt_rgstn_doc where hr_applcnt_rgstn_id='".$GetRec['hr_applcnt_rgstn_id']."' and  status='accept'",$db);
      $qt2=DB_query("select * from hr_applcnt_rgstn_doc where hr_applcnt_rgstn_id='".$GetRec['hr_applcnt_rgstn_id']."' and  status='reject'",$db);
     $no_reject=DB_num_rows($qt2);
      $qt1=DB_query("select * from hr_applcnt_rgstn_doc where hr_applcnt_rgstn_id='".$GetRec['hr_applcnt_rgstn_id']."' and status='pending'",$db);
      
       $no_accept=DB_num_rows($qt);
       $no_pending=DB_num_rows($qt1);
			if($no_accept>0)
			{
			 $no_pending=DB_num_rows($qt1);
       $total=$no_reject+$no_accept+$no_pending;
			 ?>
<tr>
<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 $s->GetFieldValue("deptmaster","id='".$GetRec['department']."'","deptname") ;?></td>
<td><?php echo $s->GetFieldValue("desigmaster","id='".$GetRec['designation']."'","designame") ;?></td>
<td ><?php echo $total; ?></td>
<td ><?php echo $no_pending; ?></td>
<td ><?php echo $no_accept; ?></td>
<td style="text-align:center;">
      <a href='index.php?route=EmpMaster_new<?php echo$url.'&mainid='.$GetRec['hr_applcnt_rgstn_id']; ?>'> 
      <input class="search" type="button" value="Create Employee" name="ack" onclick="return validate(<?php echo $t; ?> )"></a>
</td>
</tr>
        <?php $i++; } } ?>
</table>
</form>
</div>
</div>

<?php

if($_REQUEST['action']=='ok' && $_REQUEST['id']!='' )
{ 
    $dataArr1['status']='doc_accept';
    $dataArr1['conf_int_app_details_seq']=0;
    //$dataArr1['conf_int_app_details_id']=$_REQUEST['id'];
    $dataArr1['awd_application_id']=$_REQUEST['mainid'];
    $dataArr1['created_by']=$_SESSION['UserID'];    
    $dataArr1['datetime']=date('Y-m-d H:i:s');
    $s->RecordInsert('hr_applcnt_rgstn_log_status',$dataArr1);
    $qt=DB_query("update hr_applcnt_rgstn_doc set status='accept' where id='".$_REQUEST['id']."'",$db);
    $s->pageLocation("index.php?route=HRModule/Master/view_document"."&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']);
}
if($_REQUEST['action']=='reject' && $_REQUEST['id']!='' )
{ 
    $dataArr1['status']='doc_reject';
    $dataArr1['conf_int_app_details_seq']=0;
    //$dataArr1['conf_int_app_details_id']=$_REQUEST['id'];
    $dataArr1['awd_application_id']=$_REQUEST['mainid'];
    $dataArr1['created_by']=$_SESSION['UserID'];    
    $dataArr1['datetime']=date('Y-m-d H:i:s');
    $s->RecordInsert('hr_applcnt_rgstn_log_status',$dataArr1);
    $qt=DB_query("update hr_applcnt_rgstn_doc set status='reject' where id='".$_REQUEST['id']."'",$db);
    $s->pageLocation("index.php?route=HRModule/Master/view_document"."&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']);
}
	
?>