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

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

<h1>Reference Mail</h1>
<?php 
$qu=DB_fetch_array(DB_query("SELECT no_of_assignee FROM conf_interview_approval",$db));
$no_assign=$qu['no_of_assignee'];
?>

<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="">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>
<br>
<?php
//if(in_array($_SESSION['UserID'],$Explode))
//{

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['applicant']!='')
  {
  $filter[]="first_name='".$_REQUEST['applicant']."'";
  }
}
if($filter!='')
  {
  
    $filter1 = implode(" and ",$filter);
    
    $SQL=DB_query("SELECT * FROM hr_applcnt_rgstn where $filter1 and status='accept' and conf_int_app_details_seq ='".$no_assign."'order by id desc",$db);
    }
else
{
//echo "SELECT * FROM hr_applcnt_rgstn where status='accept' and conf_int_app_details_seq ='".$no_assign."'order by id desc";
  $SQL=DB_query("SELECT * FROM hr_applcnt_rgstn where status='accept' and conf_int_app_details_seq ='".$no_assign."'order by id desc",$db);
}


?>

 <table width="100%" cellpadding="3" cellspacing="0" border="1" style="border:#808080 1px solid; border-collapse:collapse;">
<tr>
  <th width="3%"><strong>S. No.</strong></th>
  <th><strong>Applicant Name</strong></th>
  <th width="8%"><strong>Contact No</strong></th>
  <th width="12%"><strong>Email</strong></th>
  <th width="12%"><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="30" style="text-align:center;" colspan="2"><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."'"


if(DB_num_rows($SQL)>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="2" valign="top" style="padding:0;">
        <div id="amc-tab">
          <table width="100%" border="0" cellpadding="3" cellspacing="0">
          <?php
          $email='';
            $SQL1=DB_query("SELECT * FROM hr_applcnt_rgstn_ref where hr_applcnt_rgstn_id='".$GetRec['id']."' AND email!=''",$db);
              while($GetRec1=DB_fetch_array($SQL1)) {
              $email[]=$GetRec1['email'];
              ?>
         
          <tr>
          <td  width="160"><?php echo $GetRec1['name']; ?></td>
          <td width="160">
          <?php echo $GetRec1['email']; ?></td>
          </tr>
            
         
        <?php } ?>
         </table></div></td>
         <td style="text-align:center;" width="20">
            <?php   //if(!empty($email)){ echo implode(",",$email); } ?>
         <a href="mailto:<?php if(!empty($email)){ echo implode(",",$email); }  ?>?Subject=<?php echo $GetRec['subject']  ?>&Body=<?php echo strip_tags($GetRec['body']);  ?>">

         <img src='images/email.png' width="15" height="13" title="Send Mail" /></a></td>
        <td > <a href="index.php?route=HRModule/Master/refference_mail&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&action=<?php echo 'mail';?>&id=<?php echo $GetRec['id']; ?>"><input class="search" type="button" name="button" value="Offer"></a></td>
        </tr>
        <?php $i++; } } ?>
</table>
</div>
</div>
<?php 
/*
function dateDiff1($d1, $d2)
  {
        return round(abs(strtotime($d1)-strtotime($d2))/86400)+1;
  } 
   
    require_once('mailerfunction/phpmailer/class.phpmailer.php'); 
   // include("../../class.smtp.php"); 

  function sendMail($to_mail,$maildata,$email_id)
  {
    

    //$to="manoj@acgil.com,dinesh@acgil.com,ravindra@acgil.com";
  
       
      // optional, gets called from within class.phpmailer.php if not already loaded
        // telling the class to use SMTP
      //error_reporting(0);
     
       $to  =  $to_mail;
      //die;
        $email=$email_id;
        $subject="confirmation mail";
         $mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
        $mail->IsSMTP();
        try {
        
            $mail->Host       = "mail.marketing.i2k2.com"; // SMTP server
            $mail->SMTPDebug  = 0;                     // enables SMTP debug information (for testing)
            $mail->SMTPAuth   = true;                  // enable SMTP authentication
            //$mail->Host       = "host2.777networks.com"; // sets the SMTP server
            $mail->Host       = "mail.marketing.i2k2.com"; // sets the SMTP server
            $mail->Port       = 25;
            $mail->Username   = "authsasl@marketing.i2k2.com"; // SMTP account username
            $mail->Password   = "MtaMyNetwork?1024?";        // SMTP account password
            //$mail->Password   = "123456";        // SMTP account password
            $mail->AddReplyTo($email);
            $mail->AddAddress($to);
            //$mail->SetFrom($email);
            $mail->SetFrom($email);
            $mail->Subject = $subject;
            $mail->AltBody = $maildata; // optional - MsgHTML will create an alternate automatically
            //$mail->MsgHTML(file_get_contents('contents.html'));
            $mail->MsgHTML($maildata);
            //$mail->AddAttachment('images/phpmailer.gif');      // attachment
            //$mail->AddAttachment('images/phpmailer_mini.gif'); // attachment
             if($mail->Send())  
              $errorMsg="Sucessfully send";
             else
              $errorMsg="Not Sucessfully send";
            
          } catch (phpmailerException $e) {
          
          } catch (Exception $e) {
          }
       
       return 1;
      
  }
  */
 

if(isset($_REQUEST['action'])=='mail' && $_REQUEST['id']!='' )
{ 
  //echo $_REQUEST['id'];
 //die;
/*
  $fromemail=$s->getField('www_users','id',$_SESSION['UserID'],'email');
  $subject="confirmation mail";
  $asd=0;
  $from='From'. ':- '. ' '.$fromemail ;
      $SQL13=DB_query("SELECT * FROM hr_applcnt_rgstn_ref where hr_applcnt_rgstn_id='".$_REQUEST['id']."' and email!='' ",$db);
      while($GetRec13=DB_fetch_array($SQL13))
       {
        
         $to=$GetRec13['email'];
        // $to='ravindra@acgil.com';
           $name=$GetRec13['name'];
            $message="Mr / Ms". ":- ". $name. " " ."<br>". "This is confirmation mail ";
              //$m=mail($to,$subject,$message,$from);
           if(sendMail($to,$message,$fromemail)){
            $asd=1;
           }
           else{
            $asd+=0;
           }
           
       //$to1[]=$GetRec13['email'];
      }
      */
     // die;
    
     // if($asd > 0)
     //{     
    $dataArr1['status']='mail';
    $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='mail' where id='".$_REQUEST['id']."'",$db);
 
   // }
 /*   else
    {
    $dataArr1['status']='mail';
    $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='mail' where id='".$_REQUEST['id']."'",$db);
   
     }*/
$s->pageLocation("index.php?route=HRModule/Master/refference_mail"."&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']);
}
?>
