<div class="acg-top-pad10">
<div id="inshow"> 
<?php 
	session_start();
//error_reporting(0);
//include("connection.php");
$emp_id  =  $s->GetFieldValue("www_users","id='".$_SESSION['UserID']."' ","empid");
$finYear=$_SESSION['YearStart']."-".$_SESSION['YearEnd1'];
if(isset($_REQUEST['action']) && $_REQUEST['action']=="delete_tds"  && isset($_REQUEST['tds_id'])){
	//&& isset($_REQUEST['emp_id'])
	        $property_declaration_finyear=$s->GetFieldValue("hr_declaration_head","id='".$_REQUEST['tds_id']."' ","fin_year");
			DB_query("Delete from hr_declaration_head WHERE id='".$_REQUEST['tds_id']."'",$db);
			DB_query("Delete from hr_declaration_rent WHERE declaration_head_id='".$_REQUEST['tds_id']."'",$db);
			DB_query("Delete from hr_declaration_property WHERE declaration_head_id='".$_REQUEST['tds_id']."'",$db);
			DB_query("Delete from hr_declaration_medical WHERE declaration_head_id='".$_REQUEST['tds_id']."'",$db);

			DB_query("Delete from hr_declaration_edu WHERE declaration_head_id='".$_REQUEST['tds_id']."'",$db);
			DB_query("Delete from hr_declaration_insurance WHERE declaration_head_id='".$_REQUEST['tds_id']."'",$db);

			DB_query("Delete from hr_declaration_document_updating WHERE hr_declaration_head_id='".$_REQUEST['tds_id']."'",$db);
			
			$property_declaration_id=$s->GetFieldValue("hr_property_declaration","emp_id='".$_REQUEST['emp_id']."' and fin_year='".$property_declaration_finyear."'","id");

			DB_query("Delete from hr_property_declaration WHERE emp_id='".$_REQUEST['emp_id']."'",$db);
			DB_query("Delete from hr_property_dclrtn_details WHERE property_declaration_id='".$property_declaration_id."'",$db);
			DB_query("Delete from hr_premium_calculation WHERE emp_id='".$_REQUEST['emp_id']."'",$db);

}
 ?>
<link rel="stylesheet" href="../../css/jquery.ui.all.css">
<link rel="stylesheet" href="../../css/jquery.ui.theme.css">
<script src="../js/jquery-1.5.1.js"></script>
<script src="../ui/jquery.ui.datepicker.js"></script>
<script src="../ui/jquery.ui.timepicker.css"></script>
<script src="../ui/jquery.ui.core.js"></script>
<script src="../ui/jquery.ui.timepicker.js"></script>
<script type="text/javascript">
var jj=$.noConflict();
 jj(function() {
  
jj(".datepicker").datepicker({ dateFormat: 'dd/mm/yy' ,changeMonth: true,
    changeYear: true,
    yearRange: '-80:+20'});
});
jj('.timepicker').timepicker();
</script>
<script src="../ui/jqueryui.min.js"></script>
<link rel="stylesheet" href="../css/jquery.ui.all.css">
<link rel="stylesheet" href="css/new_mxerp.css">
<div style="width:100%">
<div class="body_contain">
<div class="tab_div">
<div id="show">	
 <!--<ul id="navigation">
   <li><a href="#" onclick="showtodo();">Create To Do</a></li>   
 </ul>-->
<h1>House Property Declaration <a href="#" onclick="tds();"></a></h1>	
<form action="" method="post" name="myform" >
  <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" >
    <option value="">---Select---</option>
  <?php 
  	 
  	 if($_SESSION['UserType']=='SuperAdmin'){
  		$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  echo $_REQUEST['emp']==$SiteRow['id']?'selected':''?> >
            <?php  echo $SiteRow['emp_name'];?>
            </option>
<?php }?>
          </select>
  </td>
  <td width="13%"><strong>Finincial Year</strong></td>
  <td><select name="fin_year" >
    <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"><strong> <input name="Search" type="submit" class="search" value="Search"/></strong></td>
</tr>
  </table>
  </form>

	<p align="left"><a href="index.php?route=HRModule/Master/house_property_declaration_index&action=andnew<?php echo $rurl;?>" > <input  class="search" type ="button" name ="Create New"  value="Create New"></a>
	</p>
<table width="100%" cellpadding="3" cellspacing="0" border="1" style="border:#808080 1px solid; border-collapse:collapse;">
	<tr>
		<th width="10%"><strong>Emp. No.</strong></th>
		<th><strong>Emp. Name</strong></th>
        <th width="15%"><strong>PAN No.</strong></th>
		<th width="10%"><strong>Status</strong></th>
		<th width="12%"><strong>Finincial Year</strong></th>
		<th width="5%" style="text-align:center;"><strong>Action</strong></th>
	</tr>
<?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'){

		 $SQLDEC=DB_query("SELECT * FROM `hr_property_declaration` where $filter ",$db);
	}
	else{
		 $SQLDEC=DB_query("SELECT * FROM `hr_property_declaration` where $filter and emp_id='".$emp_id."'",$db);
	}

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

		 $SQLDEC=DB_query("SELECT * FROM `hr_property_declaration`",$db);
	}
	else{
		 $SQLDEC=DB_query("SELECT * FROM `hr_property_declaration` where emp_id='".$emp_id."'",$db);
	}

}

    // $SQLDEC=DB_query("SELECT * FROM `hr_property_declaration` where emp_id='".$emp_id."' ",$db);
      while($DECOView=DB_fetch_array($SQLDEC)) {?>
	<tr>
        <td><?php echo $s->GetFieldValue("empmaster","id='".$DECOView['emp_id']."' ","emp_code"); ?></td>
		<td><?php echo $s->GetFieldValue("empmaster","id='".$DECOView['emp_id']."' ","emp_name"); ?></td>
        <td><?php echo $s->GetFieldValue("empmaster","id='".$DECOView['emp_id']."' ","pan_no"); ?></td>
        <td><?php if($DECOView['status']==0){echo "Pending";} else{ echo "Confirm";} ?></td>
		<td><?php echo $s->GetFieldValue("company_financial_years","id='".$DECOView['fin_year']."'","year(year_start)")."-".$s->GetFieldValue("company_financial_years","id='".$DECOView['fin_year']."'","year(year_end)"); ?></td>
        <td style="text-align:center;"><a href="index.php?route=HRModule/Master/house-property-declaration_edit&action=edit&tds_id=<?php echo $DECOView['id']; ?><?php echo $rurl;?>" ><img width="15" height="15" title="Edit" src="images/icon-edit.png"></a></td>       
	</tr>
<?php }?>
</table>
</div>


</div></div>

<script type="text/javascript" language="javascript">

	function getUsers(group_id){
		$.post("ajax_file.php",{"group_id":group_id},function(data){
			$("#leaduserid").html(data);
		});
	}

function showtodo()
{
	document.getElementById("show").style.display='none';
	document.getElementById("hide").style.display='block';
}

function tds(){
  $.post("tds.php",{'action':'addnew'},function(data){
      $('#dash').html(data);
    });
}

function tds_edit(tdsId){
  $.post("tds_edit.php",{'action':'addnew','tds_id':tdsId},function(data){
      $('#dash').html(data);
    });
}
</script>
</div>
</div>