<?php
$filename = "Report";
header("Cache-control: private");
header('Content-Encoding: UTF-8');
header("Content-Transfer-Encoding: binary");
header("Content-type: application/msexcel; charset=UTF-8");
header("Content-Disposition:attachment; filename=".$filename.".xls");
?>


    
    <?php $k =0;?>
<html>
    <head>
       
    </head>
    <body>
   <table width="100%" align="left" border="0">
      <tr>
	  <td>Sl.No.</td>
	  <td>Name</td>
    <td>Mobile</td>
    <td>Guardian Name</td>
    <td>Age</td>
    <td>Sex</td>
	  <td>Taluk</td>
	  <td>Grama Panchayath</td>
    <td>Ward</td>
    <td>Caste</td>
    <td>Caste certificate</td>
    <td>Toilet Available</td>
    
    <td>Aadhaar Available</td>
    <td>Aadhaar No</td>
    <td>Ration card Available</td>
     <td>Ration card No</td>
    <td>Jobcard Available</td>
    <td>Jobcard No</td>
    <td>Included in baseline survey list</td>
    <td>Electricity Bill RR No</td>
    <td>Electricity Available</td>
    <td>Bank Account Available</td>
     <td>Bank Name</td>
      <td>Branch Name</td>
      <td>Bank Account No</td>
      <td>Ifsc Code</td>
      <td>APL/BPL</td>
      <td>Small/Marginal Farmer</td>
    <td>Physically Handicapped</td>
    <td>Landless Labour</td>
    <td>Women centric family</td>
    <td>Open place avilable or not</td>
    <td>Willing for toilet construction</td>
    <td>Willing to avail Bank loan </td>
    <td>Requires raw materials </td>
    <td>Need Rreadymade toilet</td>
    <td>Agent Name</td>
	  <td>Survey Date</td>
	  </tr>
	   
		 <tr>
		 <?php 
		 $i=1;
	     foreach($details as $row)
	    {?> 
		 <td> <?php echo $i++; ?></td> 
		 <td> <?php  if(isset($row['name']) && $row['name'] !='' && $row['name'] !='0'){ echo $row['name']; }?></td>
      <td> <?php  if(isset($row['mobile']) && $row['mobile'] !='' && $row['mobile'] !='0'){ echo $row['mobile']; }?></td>
		 <td> <?php  if(isset($row['guardian_name']) && $row['guardian_name'] !='' && $row['guardian_name'] !='0'){ echo $row['guardian_name']; }?></td>
     <td> <?php  if(isset($row['dob']) && $row['dob'] !='' && $row['dob'] !='0'){echo $row['dob'];}?></td>
      <td> <?php  if(isset($row['sex']) && $row['sex'] !='' && $row['sex'] !='0'){ echo $row['sex']; }?></td>
     <td> <?php if(isset($row['taluk_name']) && $row['taluk_name'] !='' && $row['taluk_name'] !='0'){ echo $row['taluk_name']; }?></td>  
		 <td> <?php if(isset($row['grama_panchayath']) && $row['grama_panchayath'] !='' && $row['grama_panchayath'] !='0'){ echo $row['grama_panchayath']; }?></td>
     <td> <?php if(isset($row['ward']) && $row['ward'] !='' && $row['ward'] !='0'){ echo $row['ward']; }?></td>
		 
     
     
    

      <?php  if(isset($row['caste']) && $row['caste'] !='' && $row['caste'] !='Others'){ ?><td><?php echo $row['caste']; ?></td><?php } ?>
      
      <?php  if(isset($row['cast_other']) && $row['caste'] =='Others'){ ?>  <td><?php echo $row['cast_other']; ?></td><?php } ?>
     
     <td> <?php  if(isset($row['cast_certificate']) && $row['cast_certificate'] !='' && $row['cast_certificate'] !='0'){ echo $row['cast_certificate']; }?></td>

     <td> <?php  if(isset($row['toilet_avail']) && $row['toilet_avail'] !='' && $row['toilet_avail'] !='0'){ echo $row['toilet_avail']; }?></td>
     <td> <?php  if(isset($row['aadhar']) && $row['aadhar'] !='' && $row['aadhar'] !='0'){ echo $row['aadhar']; }?></td>
      <td>
      <?php  if(isset($row['aadhar_avail']) && $row['aadhar_avail'] !='' && $row['aadhar_avail'] !='0'){ echo $row['aadhar_avail']; }?> 
     </td>
     <td> <?php  if(isset($row['ration_card']) && $row['ration_card'] !='' && $row['ration_card'] !='0'){ echo $row['ration_card']; }?></td>
      <td> <?php  if(isset($row['rationcard_avail']) && $row['rationcard_avail'] !='' && $row['rationcard_avail'] !='0'){ echo $row['rationcard_avail']; }?></td>
     <td> <?php  if(isset($row['jobcard']) && $row['jobcard'] !='' && $row['jobcard'] !='0'){ echo $row['jobcard']; }?></td>

     <td> <?php  if(isset($row['jobcard_avail']) && $row['jobcard_avail'] !='' && $row['jobcard_avail'] !='0'){ echo $row['jobcard_avail']; }?></td>
     <td> <?php  if(isset($row['name_base_line_survey']) && $row['name_base_line_survey'] !='' && $row['name_base_line_survey'] !='0'){ echo $row['name_base_line_survey']; }?></td>

     <td> <?php  if(isset($row['electric_bill']) && $row['electric_bill'] !='' && $row['electric_bill'] !='0'){ echo $row['electric_bill']; }?></td>
     <td> <?php  if(isset($row['electic_bill_avail']) && $row['electic_bill_avail'] !='' && $row['electic_bill_avail'] !='0'){ echo $row['electic_bill_avail']; }?></td>
     <td> <?php  if(isset($row['back_acc']) && $row['back_acc'] !='' && $row['back_acc'] !='0'){ echo $row['back_acc']; }?></td>


     <td> <?php  if(isset($row['bank_name']) && $row['bank_name'] !='' && $row['bank_name'] !='0'){?><?php  echo $row['bank_name']; }?></td>
     <td> <?php  if(isset($row['branch_name']) && $row['branch_name'] !='' && $row['branch_name'] !='0'){?><?php  echo $row['branch_name']; }?></td>
    <td> <?php  if(isset($row['bank_account_avail']) && $row['bank_account_avail'] !='' && $row['bank_account_avail'] !='0'){ ?> <?php  echo $row['bank_account_avail']; }?></td>
     <td> <?php  if(isset($row['ifc_code']) && $row['ifc_code'] !='' && $row['ifc_code'] !='0'){ ?> <?php  echo $row['ifc_code']; }?></td>

     <td> <?php  if(isset($row['cat_bpl_apl']) && $row['cat_bpl_apl'] !='' && $row['cat_bpl_apl'] !='0'){ echo $row['cat_bpl_apl']; }?></td> 
     <td> <?php  if(isset($row['cat_farmer']) && $row['cat_farmer'] !='' && $row['cat_farmer'] !='0'){ echo $row['cat_farmer']; }?></td>
     <td> <?php  if(isset($row['handicapped']) && $row['handicapped'] !='' && $row['handicapped'] !='0'){ echo $row['handicapped']; }?></td>
     <td> <?php  if(isset($row['landless_labour']) && $row['landless_labour'] !='' && $row['landless_labour'] !='0'){ echo $row['landless_labour']; }?></td>

     <td> <?php  if(isset($row['women_centric_family']) && $row['women_centric_family'] !='' && $row['women_centric_family'] !='0'){ echo $row['women_centric_family']; }?></td>

    <td> <?php  if(isset($row['open_place_avil_or_not']) && $row['open_place_avil_or_not'] !='' && $row['open_place_avil_or_not'] !='0'){ echo $row['open_place_avil_or_not']; }?></td>
    <td>  <?php  if(isset($row['toilet_construction']) && $row['toilet_construction'] !='' && $row['toilet_construction'] !='0'){?><?php  echo $row['toilet_construction'];?><?php  }?></td>
    <td>  <?php  if(isset($row['bank_loan']) && $row['bank_loan'] !='' && $row['bank_loan'] !='0'){?> <?php echo $row['bank_loan'];?><br/><?php  }?></td>
     <td>   <?php  if(isset($row['material_for_construction']) && $row['material_for_construction'] !='' && $row['material_for_construction'] !='0'){?><?php  echo $row['material_for_construction']; ?><?php  }?></td>
    <td>  <?php  if(isset($row['readymade_toilet']) && $row['readymade_toilet'] !='' && $row['readymade_toilet'] !='0'){?>  <?php echo $row['readymade_toilet']; }?></td>

     <td><?php if(isset($row['agent_name']) && $row['agent_name'] !='' && $row['agent_name'] !='0'){ echo $row['agent_name']; }?></td>  
		 <td><?php  if(isset($row['created_at']) && $row['created_at'] !='' && $row['created_at'] !='0'){ echo date('d-m-Y', strtotime($row['created_at'])); }?></td> 
		 </tr>
	  <?php 
	  } ?> 
 
      </tr>
    </table>
    </body>
</html>