<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
$emp_id  =  $s->GetFieldValue("www_users","id='".$_SESSION['UserID']."' ","empid")
?>
<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%" border="0" cellpadding="3" cellspacing="0">
  <tr class="row1">
  <td width="13%"><strong>Employee</strong></td>
  <td width="35%">
  	<?php //print_r($_SESSION); ?>
  	<select name="emp"  style="width:98%;">   
  <?php   	 
  	 if($_SESSION['UserType']=='SuperAdmin'){
  	 	?> <option value="">---All---</option>
  	<?php  $Sitesql="select * from empmaster  order by emp_name ASC";  		
		}
		else{
			$Sitesql="select * from empmaster  where id='".$emp_id."' order by emp_name ASC";
		}
  $SiteRes=DB_query($Sitesql,$db);
  while($SiteRow=DB_fetch_array($SiteRes)){?>
            <option value="<?php  echo $SiteRow['id'];?>" <?php  if($_REQUEST['emp']==$SiteRow['id']){ echo "selected"; }?> >
            <?php  echo $SiteRow['emp_name'];?>
            </option>
<?php }?>
    </select>
  </td>
  <td width="13%"><strong>Finincial Year</strong></td>
  <td><select name="fin_year"  style="width:98%;">
    <option value="">---Select---</option>
  <?php $finyearsql="SELECT * FROM `company_financial_years` order by id desc";
  		$finyearsqlRes=DB_query($finyearsql,$db);
  		while($finyeaRow=DB_fetch_array($finyearsqlRes)){?>
            <option value="<?php  echo $finyeaRow['id'];?>" <?php  echo $_REQUEST['fin_year']==$finyeaRow['id']?'selected':''?> >
            <?php  echo date('Y',strtotime($finyeaRow['year_start']))."-TO- ".date('Y',strtotime($finyeaRow['year_end']));?>
            </option>
<?php }?>
          </select>
  </td>
  </tr>
  <tr class="row1">
  <td style="text-align:center;" colspan="4"><input name="Search" type="submit" class="search" value="Search"/></td>
</tr>
  </table>
  </form>

<?php 

if($_REQUEST['Search']){
$filter='1=1';
    
	

	if($_REQUEST['fin_year']!='' ) 
	 {
		 $filter.=" and fin_year='".$_REQUEST['fin_year']."' ";
	 }
	 if($_REQUEST['emp']!='' ) 
	 {
		 $filter.=" and emp_id='".$_REQUEST['emp']."' ";
	 }

	if($_SESSION['UserType']=='SuperAdmin'){

		 $sql2="SELECT * FROM `hr_declaration_head` where $filter";
	}
	else{
		 $sql2="SELECT * FROM `hr_declaration_head` where $filter and emp_id='".$emp_id."'";
	}

}
else{
	if($_SESSION['UserType']=='SuperAdmin'){

		 $sql2="SELECT * FROM `hr_declaration_head`";
	}
	else{
		 $sql2="SELECT * FROM `hr_declaration_head` where emp_id='".$emp_id."'";
	}

}	






/*if($_REQUEST['Search']){
$filter='1=1';
    
	

	if($_REQUEST['financial_year_id']!='' ) 
	 {
		 $filter.=" and fin_year='".$_REQUEST['financial_year_id']."' ";
	 }
	 if($_REQUEST['employee']!='' ) 
	 {
		 $filter.=" and emp_id='".$_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_declaration_head  where $filter ";
	else
		 $sql2 = "select * from hr_declaration_head  ";*/
	
	
   // $_SESSION['purch_reg1']=$sql2 ;  
 //} ?>


<?php if($_REQUEST['Search']){ 
		
	$res = DB_query($sql2,$db);
		//echo DB_num_rows($res);
	?>
<div id="pr">
	<!--<a href="appraisal_register_report.php" target="_blank" class="search">Print</a>-->

<!--<p align="right"><a href="investment_report_print.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 style="text-align:left;"><strong>Employee Name</strong></th>
    <th width="10%" style="text-align:left;"><strong>Pan No.</strong></th>
    <th width="10%" style="text-align:left;"><strong>Phone No.</strong></th>
    <th width="12%" style="text-align:left;"><strong>Financial Year</strong></th>
    <th width="5%" style="text-align:left;"><strong>INV DEC</strong></th>
    <th width="5%" style="text-align:left;"><strong>HPD</strong></th>
    <th width="5%" style="text-align:left;"><strong>PRE CAL</strong></th>
    <th width="5%" style="text-align:left;"><strong>Document</strong></th>
    <th width="5%" style="text-align:left;"><strong>Action</strong></th>         
  </tr>
  <?php
  $_SESSION['invest']=$sql2;
$i=1;
	
 	while($row = DB_fetch_array($res))
	{		
	 ?>
	  <tr bgcolor="#FFFFFF" >
    	<td><?php echo $i;?></td>
    	<td><?php echo $s->getField('empmaster','id',$row['emp_id'],'emp_code'); ?></td>
    	<td><?php echo $s->getField('empmaster','id',$row['emp_id'],'emp_name'); ?></td>
    	<td><?php echo $s->getField('empmaster','id',$row['emp_id'],'pan_no'); ?></td>
    	<td><?php echo $s->GetFieldValue("employee_address","emp_id='".$row['emp_id']."' ","per_mobile"); ?></td>
    	<td><?php echo ConvertSQLDate( $s->getField('company_financial_years','id',$row['fin_year'],'year_start'))."-TO-".ConvertSQLDate( $s->getField('company_financial_years','id',$row['fin_year'],'year_end')); ?></td>
    	<td style="text-align:center;"><?php $id= $s->GetFieldValue("hr_declaration_head","emp_id='".$row['emp_id']."' AND fin_year='".$row['fin_year']."' ","id");
				if(isset($id)){	?>
					<i class="fa fa-check" style="color:green;"></i>
				<?php } else { ?>
					<i class="fa fa-times" style="color:red;"></i>
				<?php } ?>
    	</td>
    	<td style="text-align:center;">    			
			<?php $id= $s->GetFieldValue("hr_property_declaration","emp_id='".$row['emp_id']."' AND fin_year='".$row['fin_year']."' ","id");
				if(isset($id)){
					?>
					<i class="fa fa-check" style="color:green;"></i>
				<?php } else{
					?>
					<i class="fa fa-times" style="color:red;"></i>
				<? } ?>
		</td>
    	<td style="text-align:center;">    			
			<?php $id= $s->GetFieldValue("hr_premium_calculation","emp_id='".$row['emp_id']."' AND fin_year='".$row['fin_year']."' ","id");
				if(isset($id)){
					?>
					<i class="fa fa-check" style="color:green;"></i>
				<?php }
				else{
					?>
					<i class="fa fa-times" style="color:red;"></i>
				<? } ?>
		</td>
    	<td>    			
    			<?php 
//DB_num_rows  
    			 $sql3="SELECT * FROM `hr_declaration_document_updating` where hr_declaration_head_id='".$row['id']."'";
    			 	$resa = DB_query($sql3,$db);
    			 	echo DB_num_rows($resa);    			
    			 ?></td>
    	<td style="text-align:center;"><a target="_blank" href="print_investment_report_new.php?id=<?php echo $row['id']; ?>"><img src="images/icon_print.jpg" width="18" height="18" title="Print" /></a></td>         
   </tr>
    <?php  $i++; }  ?>
   
</table>
</div>
<?php  }else{ ?>
<script>/*document.getElementById("getbranchwise").style.display="none";*/</script>
<?php }?>

</div>
</div>
