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

<!--
<script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
  <script>tinymce.init({ selector:'textarea' });</script>-->
<form name="search" action="" method="post">
<div class="body_contain">
<div class="tab_div"> 
<?php 
include("style_fc/fckeditor/fckeditor.php") ;
//echo $_REQUEST['id']; 
$SQL=DB_query("SELECT a.*,b.*,a.id as mainid FROM hr_applcnt_rgstn a inner join hr_applcnt_rgstn_offer b on b.hr_applcnt_rgstn_id=a.id  WHERE a.id='".$_REQUEST['id']."'",$db);
while($GetRec=DB_fetch_array($SQL)) {
  extract($GetRec);
}
?>

<?php
if($_REQUEST['save'])
{

//**************************mail functin ***********************************************************
/*
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
      
     
       $to  =  $to_mail;
      //die;
        $email=$email_id;
        $subject="Offer letter";
         $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;
  } 
   $to=$s->getField('hr_applcnt_rgstn','id',$_REQUEST['id'],'email1');
   $fromemail=$s->getField('www_users','id',$_SESSION['UserID'],'email');  
  
   $from='From'. ':- '. ' '.$fromemail ;
  $name=$s->getField('hr_applcnt_rgstn','id',$_REQUEST['id'],'first_name');
 $message="Mr / Ms". ":- ". $name. " " ."<br>". "This is a offer letter confirmation mail";
 	$asd=0;
 	 */
//if(sendMail($to,$message,$fromemail)){


//**********************mail function********************************************************
	
	//$dataArr1['hr_applcnt_rgstn_id']=$_REQUEST['id'];
    
 
    
   // $dataArr1['location']=$_REQUEST['location'];
   // $dataArr1['remuneration']=$_REQUEST['salary'];
   // $dataArr1['notice_period']=$_REQUEST['notice'];
    //$dataArr1['joining_date']=ConvertSQLDate($_REQUEST['joining_date']);
   // $dataArr1['reporting']=$_REQUEST['reporting'];
    $body="<pre>".$_REQUEST['body']."<pre>";
    $dataArr1['offer_date']=ConvertSQLDate($_REQUEST['offer_date']);
    $dataArr1['body']=$body;


    $dataArr1['subject']=$_REQUEST['sub'];
    $dataArr1['modified_by']=$_SESSION['UserID'];    
    $dataArr1['modified_date']=date('Y-m-d H:i:s');
    $dataArr1['employee_type']=$_REQUEST['employee_type'];
    $dataArr1['grade']=$_REQUEST['grade'];
    $cond="hr_applcnt_rgstn_id='".$_REQUEST['id']."'";
    $s->RecordEdit('hr_applcnt_rgstn_offer',$dataArr1,$cond);
    
    $dataArr12['status']='offer';
    $dataArr12['conf_int_app_details_seq']=0;
    //$dataArr1['conf_int_app_details_id']=$_REQUEST['id'];
    $dataArr12['awd_application_id']=$_REQUEST['id'];
    $dataArr12['created_by']=$_SESSION['UserID'];    
    $dataArr12['datetime']=date('Y-m-d H:i:s');
    $s->RecordInsert('hr_applcnt_rgstn_log_status',$dataArr12);
   	$s->pageLocation("index.php?route=HRModule/Master/offered"."&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']);
      
}
?>
<?php
if($_REQUEST['calcel'])
{
 $s->pageLocation("index.php?route=HRModule/Master/offered"."&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']); 
}
?>
<h1>Proposed Offer</h1>
<div style="width:1100px; height:auto; margin:0 auto;">
<table width="100%" cellspacing="0" cellpadding="3" border="0" align="center">
<tr class="row1">
<td><strong>Ref No&nbsp;:&nbsp;</strong><input type="text" disabled="disabled" value="<?php echo $offer_no; ?>"></td>
<td></td>
<td style="text-align:right;"><strong>Date&nbsp;:&nbsp;</strong><input id="" class="datepicker" type="text"  name="offer_date" value="<?php echo ConvertSQLDate($offer_date); ?>"></td>

</tr>
<tr class="row1">
<td><strong>Employee Type<font color="#FF0000" size="-1">*</font></strong><select name="employee_type" id="employee_type" onchange="finGrd(),rsetfun()"   style="width:98%" >
<option value="">Select</option>
<option value="worker"<?php echo($employee_type=='worker'?'selected':'')?>>Worker</option>
<option value="employee"<?php echo($employee_type=='employee'?'selected':'')?>>Employee</option>
</select>
</td>
<td></td>
<td><strong>Salary Grade:</strong><select name="grade" id="grade" style="width:98%;" onchange="finGrd1()"  >
		
		  <?php
     
      ///$grade_sql=DB_query("Select * from emp_grade where id= '".$grade."'",$db);
      $grade_sql=DB_query("Select * from emp_grade ",$db);
		while($grade_result=DB_fetch_array($grade_sql))
		{
		?>
			  <option value="<?php echo $grade_result['id'];?>"<?php echo ($grade==$grade_result['id']?'selected':'');?>><?php echo $grade_result['grade_name'];?></option>
			  <?php } ?>
		  </select></td>
</tr>
    <?php 
    $querySal = DB_query("SELECT `esg`.* FROM `emp_grade` `eg` INNER JOIN `emp_salary_grade` `esg` ON `eg`.`id`=`esg`.`emp_grade_id` WHERE `eg`.`employment_type`='".trim($employee_type)."' and `eg`.`id`='".$grade."'",$db);
	  $resultSal23 = DB_fetch_assoc($querySal);
   ?>
<tr class="row1">
<td><strong>CTC (Monthly)(in INR)&nbsp;:&nbsp;</strong><input type="text"  id="ctc_monthly" name="ctc_monthly" onkeyup="yearlyctc(this.value)" =() value="<?php echo $resultSal23['gross_salary'];?>"></td>
<td></td>

<td><strong>CTC (Yearly)(in INR)&nbsp;:&nbsp;</strong><input type="text" disabled="disabled" id="ctc_yearly" name="ctc_yearly" value="<?php echo $resultSal23['gross_salary']*12;?>"></td>

</tr>
</table>
<table width="100%" cellspacing="0" cellpadding="3" border="0" align="center">
<tr class="row1">
</tr>
<tr class="row1">
<td  style="text-align:right;"><strong>Name : -</strong></td>
<td><b><?php echo $first_name.'&nbsp;&nbsp;'.$middle_name.'&nbsp;&nbsp;'.$last_name; ?></b></td>
<td style="text-align:right;"><strong>Department : -</strong></td>
<td><b><?php echo $s->getField('deptmaster','id',$department,'deptname'); ?></b></td>
<td style="text-align:right;"><strong>Designation : -</strong></td>
<td><b><?php echo $s->getField('desigmaster','id',$designation,'designame'); ?></b></td>
</tr>
</table>
<table width="100%" cellspacing="0" cellpadding="3" border="0" align="center">

<tr class="row1">
<td style="text-align:right;"><strong>Subject</strong></td>
<td><b><input type="text" name="sub" style="width:100%;align:left;" value="<?php echo $subject; ?>"></b></td>
<td colspan="4"></td>
</tr>
<tr class="row1">
<td style="text-align:right;"><strong></strong></td>
<td>
<?php

        $sBasePath = $_SERVER[ 'PHP_SELF' ] ;                                                       
        $oFCKeditor = new FCKeditor('body') ;                                                 
        $oFCKeditor->BasePath = 'style_fc/fckeditor/' ;                                                       
        $oFCKeditor->ToolbarSet = 'Basic';                                                            
        $oFCKeditor->Height = 300;                                                                     
        $oFCKeditor->Width  = 1210;                                                                     
        $oFCKeditor->Value =$body;
        $oFCKeditor->Create() ;
      ?>

<!--<textarea rows="13" cols="50" name="body" ><?php echo $body; ?></textarea>--></td>
<td colspan="4"></td>
</tr>
</table>
<!--<h1>Proposed Offer</h1>
<div style="width:1100px; height:auto; margin:0 auto;">
<table width="100%" cellspacing="0" cellpadding="3" border="0" align="center">
<tr class="row1">
<td><strong>Offer No.&nbsp;:&nbsp;</strong><input type="text" readonly  value="<?php echo $offer_no; ?>"></td>
<td></td>
<td style="text-align:right;"><strong>Date&nbsp;:&nbsp;</strong><input id="" value="<?php echo ConvertSQLDate($offer_date); ?>" class="datepicker" type="text"  name="offer_date"></td>

</tr>
</table>
<table width="100%" cellspacing="0" cellpadding="3" border="0" align="center">
<tr class="row1">
<th colspan="2"><strong>Name & Address</strong></th>
</tr>
<tr class="row1">
<td width="10%"><strong>Name</strong></td>
<td><b><?php echo $first_name.'&nbsp;&nbsp;'.$middle_name.'&nbsp;&nbsp;'.$last_name; ?></b></td>
</tr>
<tr class="row1">
<td><strong>Address</strong></td>
<td><b><?php echo $prmnt_address; ?></b></td>
</tr>
<tr class="row1">
<td><strong>Country</strong></td>
<td><b><?php echo $country; ?></b></td>
</tr>
<tr class="row1">
<td><strong>State</strong></td>
<td><b><?php echo $state; ?></b></td>
</tr>
<tr class="row1">
<td><strong>City</strong></td>
<td><b><?php echo $city; ?></b></td>
</tr>
<tr class="row1">
<td><strong>Pin code</strong></td>
<td><b><?php echo $pincode; ?></b></td>
</tr>
</table>
	<table width="100%" cellspacing="0" cellpadding="3" border="0" align="center">
	<tr class="row1">
<td ><strong>Dear Mr. /Ms.</strong>&nbsp;:-&nbsp;&nbsp;<b><?php echo $first_name.'&nbsp;&nbsp;'.$middle_name.'&nbsp;&nbsp;'.$last_name; ?></b></td>
</tr>
<tr class="row1">
<td><strong>Sub: Appointment to the post of</strong>&nbsp;:-&nbsp;&nbsp;<b><?php echo $s->getField('desigmaster','id',$designation,'designame'); ?></b></td>
</tr>
<tr class="row1">
<td><strong>Based on your interview with us recently, we are now pleased to offer you appointment
			 as above on the following terms & conditions:-</strong></td>
</tr>
			
</table>
		<table width="100%" cellspacing="0" cellpadding="3" border="0" align="center">
		<tr class="row1">
		<td width="10%"><strong>Position:</strong> </td>
		<td>&nbsp;&nbsp;&nbsp;<b><?php echo $s->getField('desigmaster','id',$designation,'designame'); ?></b></td>
		</tr>
		<tr class="row1">
		<td><strong>Location:</strong></td>
		<td>You will be initially based at &nbsp;&nbsp;&nbsp;<input type="text" value="<?php echo $location; ?>" name="location"></td>
		</tr>
		<tr class="row1">
		<td><strong>Remuneration:</strong></td>
		<td>The Gross remuneration shall be Rs&nbsp;&nbsp;&nbsp;<input type="text" value="<?php echo $remuneration; ?>" name="salary">&nbsp;&nbsp;&nbsp;per annum. 
								The details of the same are attached at Annexure - I.</td>
		</tr>
		<tr class="row1">
		<td><strong>Notice Period:</strong></td>
		<td>The notice period will be&nbsp;&nbsp;&nbsp;<input type="text" value="<?php echo $notice_period; ?>" name="notice">&nbsp;&nbsp;&nbsp;days on either side.</td>
		</tr>
		<tr class="row1">
		<td><strong>Joining date:</strong></td>
		<td>On&nbsp;&nbsp;&nbsp;<input id="" value="<?php echo ConvertSQLDate($joining_date); ?>" class="datepicker" type="text"  name="joining_date"></td>
		</tr>
		<tr class="row1">
		<td colspan="2"><strong>Date of acceptance:</strong>	Your formal acceptance to the terms and conditions should
			be confirmed by counter signing and returning the enclosed copy of this letter.</td>
		</tr>
		<tr class="row1">
		<td><strong>Reporting:</strong></td>
		<td>You shall report to the&nbsp;&nbsp;&nbsp;<input type="text" value="<?php echo $reporting; ?>" name="reporting">&nbsp;&nbsp;&nbsp; who would assign you job responsibilities from
		 time to time or such other person as directed from time to time.</td>
		</tr>
		<tr><td>&nbsp;</td></tr>			
		</table>-->
		<div style="text-align:center;"><input class="search" type="submit" value="Save" name="save" onClick="return validate()">
		<input class="search" type="submit" value="cancel" name="calcel"></div>
	</div>
</div>
</div>
</form>
<script>

function yearlyctc(mctcva)
{
if(mctcva){

  document.getElementById("ctc_yearly").value = mctcva * 12;
}


}

function validate()
{
  if(document.getElementById("ctc_monthly").value=='')
  {
    alert("Please enter monthly CTC");
    document.getElementById("ctc_monthly").focus();
    return false;
  }
}
function  rsetfun(){
// $("#grade").val('');
document.getElementById('grade').selectedIndex = 0;

}
function finGrd()
					{//getStore
						
					var e_type = $('#employee_type').val();
					var grade = $('#grade').val();
					var designation = $('#designation').val();

					if(e_type!=''){
					var type='grade';
					}

					if(type!=''){
					//console.log(designation+'=='+grade);
					$.ajax({
					url : "ajaxSalaryDet.php",
					type : "POST",
					data : {emp_type:e_type,grade:grade,designation:designation,type:type},
					success : function(data) {//alert(data);
					console.log(data);
					if(type=='grade'){
					//	console.log(data);
					
					$('#'+type).html(data);
					}
					

					}
					});
					}

					}

          function finGrd1()
					{//getStore
					var e_type = $('#employee_type').val();
					var grade = $('#grade').val();					
					//console.log(designation+'=='+grade);
					$.ajax({
					url : "ajaxSalaryDet.php",
					type : "POST",
					data : {emp_type:e_type,grade:grade,type:'ctcget'},
					success : function(data) {//alert(data);
           // console.log(data);
            $data1=data.split('@@');
            $('#ctc_yearly').val($data1[1]);
            $('#ctc_monthly').val($data1[0]);
			   	}
						
					});
}

</script>