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

<form name="search" action="" method="post">
<div class="body_contain">
<div class="tab_div"> 
<?php 
include("style_fc/fckeditor/fckeditor.php") ;

	if($_REQUEST['action']=='offer' && $_REQUEST['id']!='')
	{
		//echo $_REQUEST['id'];
		$query=DB_query("select * from hr_applcnt_rgstn where id='".$_REQUEST['id']."'",$db);
		$row=DB_fetch_array($query);
		extract($row);
		
	}
?>
<?php
if($_REQUEST['save'])
{

//**********************mail function********************************************************
	$sql="select offer_no from hr_applcnt_rgstn_offer order by offer_no desc limit 1";
	 
	$result = DB_query($sql,$db);
	$numrows = DB_num_rows($result);

	if($numrows>0)
	
	{
		
		$IsuuNo=DB_fetch_array($result);
		$Explo=explode("/",$IsuuNo['offer_no']);
		$maxval=$Explo[1];
		
		$strFinal = $maxval+1;
		 $strBothFinal = "GS1".'/'.str_pad($strFinal,6,"0",STR_PAD_LEFT);
	}
	else
	{
		
	 $strBothFinal= "GS1".'/'.'000001';
	}
	
	$dataArr1['hr_applcnt_rgstn_id']=$_REQUEST['id'];
    $dataArr1['offer_no']=$strBothFinal;
    $dataArr1['body']=$_REQUEST['body'];
    $dataArr1['subject']=$_REQUEST['sub'];
    $dataArr1['employee_type']=$_REQUEST['employee_type'];
    $dataArr1['grade']=$_REQUEST['grade'];
  
    $dataArr1['offer_date']=ConvertSQLDate($_REQUEST['offer_date']);
    
   // $dataArr1['location']=$_REQUEST['location'];
   // $dataArr1['remuneration']=$_REQUEST['salary'];
   // $dataArr1['notice_period']=$_REQUEST['notice'];
    //$dataArr1['joining_date']=ConvertSQLDate($_REQUEST['joining_date']);
    //$dataArr1['reporting']=$_REQUEST['reporting'];
    $dataArr1['created_by']=$_SESSION['UserID'];    
    $dataArr1['created_date']=date('Y-m-d H:i:s');
    $s->RecordInsert('hr_applcnt_rgstn_offer',$dataArr1);

    $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);
    
    $qt=DB_query("update hr_applcnt_rgstn set status='offer' ,grade_id='".$_REQUEST['grade']."' where id='".$_REQUEST['id']."'",$db);
  
   	$s->pageLocation("index.php?route=HRModule/Master/proposed_offer"."&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']);
    
    // }
    
 
}
?>
<?php
if($_REQUEST['calcel'])
{
 $s->pageLocation("index.php?route=HRModule/Master/proposed_offer"."&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="Auto Generated"></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 date('d/m/y');?>"></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);
		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>
</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;"></b></td>
<td colspan="4"></td>
</tr>
<tr class="row1">
<td style="text-align:right;"><strong></strong></td>
<td>
	<?php  $body = '<p>Dear <strong>[Mr./Miss./Mrs./Ms.] [Name]</strong>,<br>Congratulations! We are pleased to confirm that you have been selected to work for <strong>[Company Name]</strong>. We are delighted to make you the following job offer.<br>The position we are offering you is that of <strong> [Job Title]</strong> at a monthly salary of [Salary per month] with an annual cost to company <strong>[Annual CTC]</strong>. This position reports to <strong>[Supervisor Title]</strong>, <strong>[Supervisor Name]</strong>. Your working hours will be from <strong>[9AM to 6PM]</strong>,<strong> [Starting Week Day]</strong> to <strong>[Ending Week Day].</strong>&nbsp;<br>Benefits for the position include: (Use if relevant to the position)Benefit A (Casual Leave of 12 days per annum)Benefit B (Employer State Insurance Corporation ESIC Coverage)Benefit C<br>We would like you to start work on <strong>[Desired starting date] </strong>at <strong>[Desired starting time]</strong>. Please report to [Name of person to report on start date], for documentation and orientation. If this date is not acceptable, please contact me immediately.<br>Please sign the enclosed copy of this letter and return it to me by <strong>[Last date for offer acceptance] </strong>to indicate your acceptance of this offer.<br>We are confident you will be able to make a significant contribution to the success of our <strong>[Company Name] </strong>and look forward to working with you.<br>Sincerely,<br><strong>(Name of person authorized to make offer)<br>(Position)<br>(Company)</strong><br></p>';
				$sBasePath = $_SERVER[ 'PHP_SELF' ] ;                                                       
				$oFCKeditor = new FCKeditor('body') ;                                                 
				$oFCKeditor->BasePath = 'style_fc/fckeditor/' ;                                                       
				$oFCKeditor->ToolbarSet = 'Basic';                                                            
				$oFCKeditor->Height = 300;                                                                     
				$oFCKeditor->Width  = 980;                                                                     
				$oFCKeditor->Value =$body;
				$oFCKeditor->Create() ;
			?>

	<!--<textarea rows="13" cols="50" name="body" id="body" ></textarea>--></td>
<td colspan="4"></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;<?php echo $s->getField('desigmaster','id',$designation,'designame'); ?></td>
		</tr>
		<tr class="row1">
		<td><strong>Location:</strong></td>
		<td>You will be initially based at &nbsp;&nbsp;&nbsp;<input type="text" 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" 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" 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="" 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" 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">
		<input class="search" type="submit" value="cancel" name="calcel"></div>
	</div>
</div>
</div>

 
</form>

<script>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();
					var designation = 000;
					console.log(designation);

					
					$.ajax({
					url : "ajaxSalaryDet.php",
					type : "POST",
					data : {emp_type:e_type,grade:grade,type:'ctcget'},
					success : function(data) {
					var i=1, j=1, total_deduction=0;
					$('#'+type).empty();
					console.log(data);
					var obj = JSON.parse(data);
					
					// $.each(obj, function(key,value) {
					// 	$('#basic_salary').val(value.fixed_pay);
					// 	$('#net_sal').val(value.net_pay);
					// 	$('#net_sal_hid').val(value.net_pay);
					// 	$('#gross_sal').val(value.gross_salary);
					// 	// $('#allow_tot').val(value.gross_salary);

						
					//   if(value.all_ded_prefix=='A'){
					//   	$('#allowPerc_'+i).val(value.percentage);
					//   	$('#allow_'+i).val(value.percentage_value);
					//   	i++;
					//   }else if(value.all_ded_prefix=='D'){
					//   	total_deduction += parseFloat(value.percentage_value);
					//   	$('#detection_class_perc_'+j).val(value.percentage);
					//   	$('#detection_class_value_'+j).val(value.percentage_value);
					//   	j++;
					//   }
					//   $('#deduct_tot').val(total_deduction);
					//   $('#deduct_tot_hid').val(total_deduction);
					// });
				}
				
				});
			}			
</script>