<script>
function validate_branch()
{
	$branch = $('#site').val();
	if($branch == "")
	{
		alert("Select Branch");
		return false;
	}
	return true;
}

function getsubcategory(str)
{
	if (str.length==0)
	{
	document.getElementById("groupwise").innerHTML="";
	return;
	}
	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)
	{
	var data=xmlhttp.responseText.split("__");
	document.getElementById("SUBGRP").innerHTML=data[0]
	document.getElementById("itemid").innerHTML=data[1];
	}
	}
	xmlhttp.open("GET","GetSubGrpPR.php?GroupId="+str,true);
	xmlhttp.send();
}
function GetItemForPr(str)
{
	if (str.length==0)
	{
	document.getElementById("subgroupwise").innerHTML="";
	return;
	}
	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)
	{
	document.getElementById("itemid").innerHTML=xmlhttp.responseText;
	}
	}
	xmlhttp.open("GET","GetPRItems.php?SubGroupId="+str,true);
	xmlhttp.send();
}
function showIndent(str)
{
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)
    {
	//var data=xmlhttp.responseText.split("__");	
	//alert(data);
	//document.getElementById("vender").innerHTML= xmlhttp.responseText;
        document.getElementById("UserIndent").innerHTML=xmlhttp.responseText;
        displayCode(str);
    	
    }
  }
xmlhttp.open("GET","check_data_fin.php?section=IndentUser&site="+str,true);
xmlhttp.send();
}	


function displayCode(str)
{
	$.post('getCode.php',{'str':str},function(data){
		$('#project').html(data);
	});
}
function changeArea(str)
{
	$.post('getCode.php',{'str':str,'changeArea':'yes'},function(data){
		$('#area').html(data);
	});
}

function showEmpDeptWise(str)
{

	$.post('getCode.php',{'str':str,'changeEmp':'yes'},function(data){
			$('#requition_by').html(data);
		});	
	
	
}
</script>
<?php
$maxAssign="select max(no_of_assignee) as numMax from conf_purch_approval where company_id='".$_SESSION['ACGCompanyId']."' and doc_type='PR'";
$maxAssignExec=DB_query($maxAssign,$db);
$maxAssignDATA=DB_fetch_array($maxAssignExec);
$maximAss=$maxAssignDATA['numMax'];
?>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div">
<h1><?php  echo  $page_title; include('POModule/Class-ItemMaster.php');?></h1>
<form action="" method="post">
<table width="100%" align="center" class="" border="0" cellspacing="0" cellpadding="3">
	<tr class="row1">
	<td width="13%"><strong>Branch</strong></td>
	<?php 
	$ss1="Select loccode,locationname from locations where CompanyId='".$_SESSION['ACGCompanyId']."' and loccode in ('".$_SESSION['AssignedBranch']."')";
	$site_sql=DB_query($ss1,$db);
	?>
	<td width="20%">
	<select name="site" id="site" style="width:100%;" onchange="showIndent(this.value)">
	<option value="">Select</option>
	<?php 
	
	while($site_row = DB_fetch_array($site_sql))
	{
		$p='';
		if($site_row['loccode'] == $_POST['site'])	
			$p="selected";
	?>
	<option value="<?php echo $site_row['loccode']; ?>" <?php echo $p;?>><?php echo $site_row['locationname']; ?></option>
	<?php } ?>
	</select>
	</td>	
	<td width="13%"><strong>Financial Year</strong></td>
	<td width="20%"><select name="financial_year_id" id="financial_year_id" style="width:60%; background:#f8f8f8; border:#878787 1px solid; height:24px;" onchange="get_rating_data(this.value);">                  <option value=""> Select financial year</option>
                <?php $fyear="select * from company_financial_years";
                  $fyearRes=DB_query($fyear,$db); 
                  while($yearRow=DB_fetch_array($fyearRes)){?>?>
                  <option value="<?php echo $yearRow['id'];?>" <?php if($yearRow['id']==$_REQUEST['financial_year_id']){ echo "selected";} ?>><?php echo ConvertSQLDate($yearRow['year_start'])."-TO-".ConvertSQLDate($yearRow['year_end']); ?></option>
                <?php } ?>
          </select></td>
	<td width="13%"><strong>Employee</strong></td>
	<td><select name="employee" id="employee" style="width:60%; background:#f8f8f8; border:#878787 1px solid; height:24px;">  
	           <option value=""> ----Select -----</option>
                <?php $emp="select * from empmaster";
                  $empRes=DB_query($emp,$db); 
                  while($empRow=DB_fetch_array($empRes)){?>?>
                  <option value="<?php echo $empRow['id'];?>"<?php if( $_REQUEST['employee']==$empRow['id']){ echo "selected"; } ?> ><?php  echo $empRow['emp_name']; ?></option>
                <?php } ?>
          </select></td></td>
	</tr>
	
	<tr class="row1">
		<td align="center" colspan="6"><p align="center">
	<input type="submit" name="SearchBranch" value="Search" class="search" style="cursor:pointer;" onclick="return validate_branch();">
	</p></td>
	</tr>
</table>
</form>

<?php 



if($_REQUEST['SearchBranch']){
$filter='1=1';
    
		 
	if($_REQUEST['site']!='' ) 
	 {
		 $filter.=" and branch='".$_REQUEST['site']."' ";
	 }

	if($_REQUEST['financial_year_id']!='' ) 
	 {
		 $filter.=" and eff_fin_year='".$_REQUEST['financial_year_id']."' ";
	 }
	 if($_REQUEST['employee']!='' ) 
	 {
		 $filter.=" and empid='".$_REQUEST['employee']."' ";
	 }
	 
	
	// $sitename=$s->getField('locations','loccode',$_REQUEST['site'],'locationname');		
	// $itemname=$s->getField('empmaster','id',$_REQUEST['requition_by'],'emp_name');
	
	 
	    	
	$_SESSION['mess']=$message;	 
    if($filter!='')
         $sql2 = "select * from hr_insentive_calculation  where $filter ";
	else
		 $sql2 = "select * from hr_insentive_calculation  ";
	
	
    $_SESSION['purch_reg1']=$sql2 ;  
 } ?>


<?php if($_REQUEST['SearchBranch']){ ?>
<div id="pr">
<p align="right"><a href="appraisal_register_report.php" target="_blank" class="search">Print</a>
</p>

<div align="center" style="font-size:12px;"><strong><?php echo $message; ?></strong> </div>
<br />
<table width="100%" cellpadding="3" cellspacing="0" border="1" style="border:solid 1px #808080;">
  <tr>
    <th width="3%" style="text-align:left;"><strong>S.No.</strong></th> 
    <!--<th width="10%" style="text-align:left;"><strong>Employee code</strong></th>-->
    <th width="12%" style="text-align:left;"><strong>Employee Name</strong></th>
    <th width="12%" style="text-align:left;"><strong>Financial Year</strong></th>
    <th width="8%" style="text-align:left;"><strong>Monthly CTC</strong></th>
	<th width="10%" style="text-align:left;"><strong>Rating</strong></th>
	<th width="5%" style="text-align:left;"><strong>Appraisal %</strong></th>
	<th width="8%" style="text-align:left;"><strong>Increase CTC</strong></th>
    
  </tr>
  <?php

$i=1;
	$res = DB_query($sql2,$db);
 	while($row = DB_fetch_array($res))
	{
		
	 ?>
	  <tr bgcolor="#FFFFFF" onmouseover="this.style.backgroundColor='#fffeb3'; this.style.color='#00f';" onmouseout="this.style.backgroundColor='#FFF'; this.style.color='#000000';">
    	<td><?php echo $i++;?></td>
    	
    	<td><?php echo $s->getField('empmaster','id',$row['empid'],'emp_name'); ?></td>
    	<td>		<?php 
    			echo ConvertSQLDate( $s->getField('company_financial_years','id',$row['eff_fin_year'],'year_start'))."-TO-".ConvertSQLDate( $s->getField('company_financial_years','id',$row['eff_fin_year'],'year_end')); ?>
    		</td>
    			<td><?php echo round($s->getField('empmaster','id',$row['empid'],'monthly_ctc')/12); ?></td>
		<td>
		<?php 

			$hr_appraisal_master_details_id= $s->getField('hr_year_appraisal_detail','id',$row['hr_year_appraisal_detail_id'],'hr_appraisal_master_details_id');
			echo $taring=$s->getField('hr_appraisal_master_details','id',$hr_appraisal_master_details_id,'rating');

			$apprajal=$s->getField('hr_appraisal_master_details','id',$hr_appraisal_master_details_id,'appraisal');

			// $dept_id =  $s->GetFieldValue('empmaster',"id='".$requition_by."'",'department');
			 //echo $s->GetFieldValue('deptmaster',"id='".$dept_id."'",'deptname');
		?>
		</td>
		<td><?php  echo round($apprajal=$s->getField('hr_appraisal_master_details','id',$hr_appraisal_master_details_id,'appraisal'));?></td>
		<td><?php  
		$monthlyctc=round($s->getField('empmaster','id',$row['empid'],'monthly_ctc')/12);
		$inmonthctc=$monthlyctc+($monthlyctc*($apprajal/100));
		echo $inmonthctc; ?></td>
		     
   </tr>
    <?php  $sno++; } if($numrow1>0) { ?>
   
   
      <?php } ?>   
</table>
</div>
</div>
<?php  }else{ ?>
<script>/*document.getElementById("getbranchwise").style.display="none";*/</script>
<?php }?>

