<?php
 
//make connection
include"../config.php";
$query=mysqli_query($conn,"SELECT * from system_settings  ");
$row=mysqli_fetch_array($query);
include('../api2.php');
foreach ($data as $key => $value)
              {
          $pname=$value['name'];
		  $pnameE=$value['Ename'];
           $district=$value['district'];
		  $districtE=$value['districtE']; 
		  $upzila=$value['upzila'];
		  $upzilaE=$value['upzilaE']; 
		  $smstoken=$value['smstoken'];
		  $sitelink=$value['sitelink'];

}
 
$fyear = $_POST["fyear"];
$ward  = $_POST["ward"];

if($ward == 0 || $ward == "0"){

    $query = mysqli_query($conn,"
        SELECT create_trade.*, sub_ematype.*
        FROM create_trade
        JOIN sub_ematype ON sub_ematype.sema_id = create_trade.sema_id
        WHERE fyear='$fyear' AND status='approved'
         
    ");

}else{

    $query = mysqli_query($conn,"
        SELECT create_trade.*, sub_ematype.*
        FROM create_trade
        JOIN sub_ematype ON sub_ematype.sema_id = create_trade.sema_id
        WHERE fyear='$fyear' AND ward='$ward' AND status='approved'
    ");
}
?>

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>রিপোর্ট</title>

<link rel="stylesheet" href="../tax/tax.css">
<link href="https://fonts.cdnfonts.com/css/solaimanlipi" rel="stylesheet">

<link rel="stylesheet" href="https://cdn.datatables.net/1.11.5/css/jquery.dataTables.css">
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.4.2/css/buttons.dataTables.min.css">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.js"></script>

<script src="https://cdn.datatables.net/buttons/2.4.2/js/dataTables.buttons.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
<script src="https://cdn.datatables.net/buttons/2.4.2/js/buttons.html5.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.4.2/js/buttons.print.min.js"></script>

<style>
body{
    font-family: SolaimanLipi;
}

.menu{
    margin:10px;
}
</style>

</head>

<body>

<div class="menu">
    <button onclick="history.back()">Back</button>
    <button onclick="window.print()">Print</button>
</div>

<!-- HEADER -->
 <table width="95%" hight="95%" border="0" align="center">
       <tr>
        <td width="22%" valign="middle"><img src="../<?php echo $row['cover_img']; ?>" width="70" height="70"  alt=""/></td>
             <td width="56%" align="center" nowrap><div style="font-size:22px; text-shadow: 0px 0px 0px #000, 0px 0px 0px indigo;" class="head-line-1"> <?php echo $pname;?> ইউনিয়ন পরিষদ</div>
	<div style="font-size: 14px"> উপজেলাঃ <?php echo $upzila;?>, জেলাঃ<?php echo $district;?> ।</div>
         <div class="head-line-2 "> <b> লাইসেন্স ফি রিপোর্ট</b><div class="head-line-2 "> </div></div>
         </td>
         <td width="22%" align="center" style="font-size: 14px;" valign="middle"> <div class="head-line-2 ">  </div><div class="head-line-2 "> </div></td>
		
      </tr>
    </table>
<table width="100%" border="0" align="center">
<tr>
<td align="center">
    <h2>লাইসেন্স ডিমান্ড প্রতিবেদন</h2>
    <p>
        অর্থ বছর: <?php echo $fyear; ?> |
        <?php echo ($ward==0 ? "সকল ওয়ার্ড" : $ward." নং ওয়ার্ড"); ?>
    </p>
</td>
</tr>
</table>

<!-- TABLE -->
<table id="table_id" class="display">
<thead>
<tr>
                <th>ক্রমিক নং</th>
	            <th>প্রতিষ্ঠানের নাম</th>
	            <th>প্রতিষ্ঠানের ধরন</th>
	            <th>মালিকের নাম</th>
	            <th>পূর্নঠিকানা</th>
	            <th>মোবাইল নম্বর</th>
	            <th>ব্যবসার স্থান</th>
</tr>
</thead>

<tbody>
<?php $i=1; while($row=mysqli_fetch_array($query)){ ?>
<tr>
<td><?php echo $i++; ?></td>
<td><?php echo $row["h_area"]; ?></td>
<td><?php echo $row["sub_ematype"]; ?></td>
<td><?php echo $row["name"]; ?></td>
<td><?php echo $row["peraddress"]; ?></td>
<td><?php echo $row["mobile"]; ?></td>
<td><?php echo $row["road"]; ?></td>
</tr>
<?php } ?>
</tbody>
</table>

<script>
$(document).ready(function(){

    $('#table_id').DataTable({
        dom: 'Bfrtip',
        buttons: [
            { extend:'excelHtml5', title:'লাইসেন্স রিপোর্ট' },
            { extend:'pdfHtml5', title:'লাইসেন্স রিপোর্ট', orientation:'landscape', pageSize:'A4' },
            { extend:'print', title:'লাইসেন্স রিপোর্ট' }
        ]
    });

});
</script>

</body>
</html>