

<?php
include('./includes/fun-php.php');
include('./includes/fun-HRClass.php');
$modid=$_REQUEST['modid'];
$frmid=$_REQUEST['frmid'];

?>


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

<form name="search" action="" method="post">
<div class="body_contain">
<div class="tab_div"> 
<div id="PickedItems" style="display:none">
</div>
<h1>Offer Acknowledgement</h1>
<div class="new_tab">
<div class="inside_tab">
  <ul>
    <li><a href="index.php?route=HRModule/Master/offer_ack&modid=<?php echo  $_REQUEST['modid']?>&frmid=<?php echo $_REQUEST['frmid']?>&tab=1&status=offer">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/offer_ack&modid=<?php echo  $_REQUEST['modid']?>&frmid=<?php echo $_REQUEST['frmid']?>&tab=3&status=off_accept">Offer Accepted</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>
<p style="text-align:left;">
<?php  $url='&modid='.$_REQUEST['modid'].'&frmid='.$_REQUEST['frmid'];?>
<input type="hidden" name="url1" id="modid" value="<?php echo $_REQUEST['modid']; ?>">
<input type="hidden" name="url12" id="frmid" value="<?php echo$_REQUEST['frmid']; ?>">
  <!--
  <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_ackowledge<?php echo$url; ?>'>
  <input class="search" type="button" value="Acknowledged"></a>-->
</p>
<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 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 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 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='offer'",$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><br>
<?php
//if(in_array($_SESSION['UserID'],$Explode))
//{

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

  //$filter[]="1=1";
if($_REQUEST['dept']!='0')
  {
  $filter[]="a.department='".$_REQUEST['dept']."'";
  }
  if($_REQUEST['design']!='0' && $_REQUEST['design']!='')
  {
  $filter[]="a.designation='".$_REQUEST['design']."'";
  }
  if($_REQUEST['applicant']!='')
  {
  $filter[]="a.first_name='".$_REQUEST['applicant']."'";
  }
}
if($filter!='')
  {
  
    $filter1 = implode(" and ",$filter);
    if($_REQUEST[status]!=""){
 $SQL=DB_query("SELECT a.*,b.*,a.id as mainid,b.id as offid FROM hr_applcnt_rgstn a inner join hr_applcnt_rgstn_offer b on b.hr_applcnt_rgstn_id=a.id where  $filter1 and a.status='".$_REQUEST[status]."'",$db);
  
    }
    else{
       $SQL=DB_query("SELECT a.*,b.*,a.id as mainid,b.id as offid FROM hr_applcnt_rgstn a inner join hr_applcnt_rgstn_offer b on b.hr_applcnt_rgstn_id=a.id where  $filter1 and a.status='offer'",$db);
  
    }
    
    }
else
{
  if($_REQUEST[status]!=""){
     $SQL=DB_query("SELECT a.*,b.*,a.id as mainid,b.id as offid FROM hr_applcnt_rgstn a inner join hr_applcnt_rgstn_offer b on b.hr_applcnt_rgstn_id=a.id  WHERE a.status='".$_REQUEST[status]."'",$db);


  }else{
     $SQL=DB_query("SELECT a.*,b.*,a.id as mainid,b.id as offid FROM hr_applcnt_rgstn a inner join hr_applcnt_rgstn_offer b on b.hr_applcnt_rgstn_id=a.id  WHERE a.status='offer'",$db);

  }
 }


?>
<?php 
if($_REQUEST[status]=="offer" || $_REQUEST[status]==""){
  
   echo "<h3>Pending For Acceptance</h3>";
   $disabled="button";
   $printview="hidden";
 }
else{
 
   echo "<h3>Offer Accepted</h3>";
   $disabled="hidden";
   $printview="button";

}
?>
<div style="width:100%; overflow:auto; margin:0 auto;">
 <table width="100%" cellpadding="3" cellspacing="0" border="1" style="border:#808080 1px solid; border-collapse:collapse;">
<tr>
  <th width="4%"><strong>S. No.</strong></th>
  <th><strong>Applicant Name</strong></th>
  <th width="6%"><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="8%"><strong>No. of Ref.</strong></th>->
  <th width="160"><strong>Reference Name</strong></th>
  <th width="160"><strong>Reference Mail</strong></th>-->
  <th width="8%"><strong>Offer No.</strong></th>
  <th width="8%"><strong>Offer Date</strong></th>
 <!-- <th width="8%"><strong>Location</strong></th>
  <th width="8%"><strong>Joining Date</strong></th>-->
  <th width="13%" style="text-align:center;" colspan="2"><strong>Action</strong></th>
</tr>
<?php 
$i=1;
//$SQL=DB_query("SELECT * FROM hr_applcnt_rgstn where $filter1 and status='accept' and conf_int_app_details_seq ='".$oldseq."'"


while($GetRec=DB_fetch_array($SQL)) {
  $applicantid=$GetRec['id'];
  $rurl_view="offer_letter_pdf.php?modid=".$modid."&frmid=".$frmid."";
 // $qt=DB_num_rows(DB_query("SELECT * FROM hr_appl_cnt_rgstn_ref where hr_applcnt_rgstn_id='".$GetRec['mainid']."' and akk_status='ok'",$db));
//if($qt>=2){
  ?>
  <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><?php echo $qt; ?></td>
        <td><a href='index.php?route=HRModule/Master/create_offer<?php echo$url.'&id='.$GetRec['id'].'&action='.'offer'; ?>'>
          <input class="search" type="button" value="Offer" name="offer"> </a></td>-->
          <td><?php echo $GetRec['offer_no']; ?></td>
          <td><?php echo convertsqldate($GetRec['offer_date']); ?></td>
         <!-- <td><?php echo $GetRec['location']; ?></td>
          <td><?php echo convertsqldate($GetRec['joining_date']); ?></td>-->
          <td>
          
          <!--<a href='index.php?route=HRModule/Master/offer_ack<?php echo$url; ?>&action=accept&id=<?php echo $GetRec['mainid']; ?>'>-->
          <input class="search" type="<?php echo $disabled?>" onclick="pop(<?php echo $GetRec['mainid']; ?>,<?php echo $GetRec['offid']; ?>,'acpt',<?php echo $_REQUEST['frmid']; ?>,<?php echo $_REQUEST['modid']; ?>)" value="Accept" id="emp_popup" name="emp_popup">

         <!-- <a href='index.php?route=HRModule/Master/offer_ack<?php echo$url; ?>&action=reject&id=<?php echo $GetRec['mainid']; ?>'>-->
          <input class="search" type="<?php echo $disabled?>" onclick="pop(<?php echo $GetRec['mainid']; ?>,<?php echo $GetRec['offid']; ?>,'rect',<?php echo $_REQUEST['frmid']; ?>,<?php echo $_REQUEST['modid']; ?>)" value="Reject"></a>
         
            
            <a href="<?php echo $rurl_view.'&app_id='.$GetRec['id']?>" target="_blank"><img src="images/icon_print.jpg" width="18" height="18" title="Print" <?php echo $printview;?> /></a>    
  
          <!-- <input class="search" type="<?php echo $printview?>"  value="Print Offer Letter"></a> -->
         
          </td>         
        </tr>
        <?php $i++; }// } ?>
</table>
</div>
</div>
</div>
</form>

<?php
if($_REQUEST['action']=='accept' && $_REQUEST['id']!='' )
{ 
    $dataArr1['status']='off_accept';
    $dataArr1['conf_int_app_details_seq']=0;
    //$dataArr1['conf_int_app_details_id']=$_REQUEST['id'];
    $dataArr1['awd_application_id']=$_REQUEST['id'];
    $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 set status='off_accept' where id='".$_REQUEST['id']."'",$db);
    $s->pageLocation("index.php?route=HRModule/Master/offer_ack"."&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']);
}
if($_REQUEST['action']=='reject' && $_REQUEST['id']!='' )
{ 
    $dataArr1['status']='off_reject';
    $dataArr1['conf_int_app_details_seq']=0;
    //$dataArr1['conf_int_app_details_id']=$_REQUEST['id'];
    $dataArr1['awd_application_id']=$_REQUEST['id'];
    $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 set status='off_reject' where id='".$_REQUEST['id']."'",$db);
    $s->pageLocation("index.php?route=HRModule/Master/offer_ack"."&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']);
}
?>

<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
 
<script src="https://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script>
<script type="text/javascript" language="javascript">
//$.noConflict();
function pop(id,offid,str,frmid,modid){
  

 // alert(id);
  //alert(str);
  $("#PickedItems").dialog({
                title:'Offer Acknowledgement ',
                modal: true,
                resizable: false,
                width:900,
                height:400,
                closeText: 'fechar',
                draggable: true,
                show: 'fade',
                hide: 'fade',
                dialogClass: 'main-dialog-class',
                buttons: {
                        Exit: function()
                        {
                                $(this).dialog("close");
                        }
                }

            });
   Getemployeelist(id,offid,str,frmid,modid);
}

    
function Getemployeelist(id,offid,str,frmid,modid)
{ 
  var xmlhttp;
    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)
    {
       // alert(xmlhttp.responseText);
    document.getElementById("PickedItems").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("POST",'ajax_offer.php?id='+id+'&str='+str+'&offid='+offid+'&modid='+modid+'&frmid='+frmid,true);
xmlhttp.send();
}
</script>
