<?php
//$sql = mysqli_query($con,"SELECT * FROM TourPayment");
//$user = mysqli_fetch_assoc($sql);

$tou=$_GET['tr'];
$grd=$_GET['Grade'];

$resultt = mysqli_query($con,"SELECT * FROM Tours where id='$tou'");
    while($row = $resultt->fetch_assoc()) 
    {
      $tit=$row['Title'];
    }
    
    
    $sql = "SELECT SUM(Amount) as Tsum FROM TourPayment where Tid='$tou' AND Grad='$grd'";
    $result = $con->query($sql);
    while($row = $result->fetch_assoc()) 
    {
    $tsum=$row["Tsum"];  
    }
?>


<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0" name="viewport">
  <title>Tour Report</title>
  <meta content="" name="description">
  <meta content="" name="keywords">
  
  <link href="https://fonts.gstatic.com" rel="preconnect">
  <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i|Nunito:300,300i,400,400i,600,600i,700,700i|Poppins:300,300i,400,400i,500,500i,600,600i,700,700i" rel="stylesheet">
  <link href="assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  
   <link href="https://fonts.gstatic.com" rel="preconnect">
  <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i|Nunito:300,300i,400,400i,600,600i,700,700i|Poppins:300,300i,400,400i,500,500i,600,600i,700,700i" rel="stylesheet">
  <link href="assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  <!-- Vendor CSS Files -->
</head>
<body style="border:1px solid #004d1a;border-radius:5px;padding:5px;border-style: double;outline-offset: -5px;">

   <center> <h6 style="margin-top:0px;color:#0099cc" class="text-red" >CATHOLIC DIOCESE OF MURANGA </h6> </center>
   <center> <h3 style="margin-top:-20px" class="text-red" >BISHOP KAIRO EDUCATION CENTRE </h3> </center>
   <center> <h4 style="margin-top:-20px" class="text-red" >EXCELLENCE IS IN GODLINESS </h4> </center>
  
<img style="position:absolute;margin-top:-80px;margin-bottom:10px;max-height:90px" src="https://bishopkairoeducationcentre.sc.ke/QB-Beta/data/logo.png" alt="School Logo" class="" />

   <center><label style="margin-top:-40px" class="text-red" ><strong>Telephone:</strong> 0728 966 221, 0714 647 708 </label>
   <br />
  <label style="margin-top:-20px" class="text-red" ><strong>Email:</strong> cdmbishopkairo@gmail.com </label></center>
  <hr />
   <center><label><strong style="font-size:25px">Tour Report</strong></label></center>
 <center><label style="font-size:18px;font-weight:bold">Title: <u><?php echo $tit; ?></u> Class: <u><?php echo $grd; ?> </u></label></center>

<table class="table table-bordered" style="width:100%">
   <thead>
   <tr style="border:1px solid #000;background-color:#000;color:#FFF">
        <th style="border:0.5px solid #000;margin:0px">#</th>
        <th style="border:0.5px solid #000">Learner</th>
        <th style="border:0.5px solid #000">Adm No</th>
        <th style="border:1px solid #000">Amount Paid</th>
        <th style="border:1px solid #000">Date Paid</th>
        <th style="border:1px solid #000">Bank Credited</th>
        <th style="border:1px solid #000">Entry Date</th>
   </tr>
</thead>
<tbody>
  <?php
  $cnt=1;
   $resultt = mysqli_query($con,"SELECT TourPayment.*,pupils.Names as pnm,pupils.AdmNo as adm,bankdata.Bname as bnk FROM TourPayment left join pupils ON pupils.count=TourPayment.pid left join bankdata ON bankdata.id=TourPayment.Bank where TourPayment.Tid='$tou' AND TourPayment.Grad='$grd'");
    while($user = $resultt->fetch_assoc()) 
    {?>
<tr style="border:1px solid #f0f5f5;font-size:13px;font-family:Times">
<td style="border:1px solid #f0f5f5;margin:0px"><?php echo $cnt;?></td>
<td style="border:1px solid #f0f5f5;margin:0px"><?=$user['pnm']?></td>
<td style="border:1px solid #f0f5f5;margin:0px"><?=$user['adm']?></td>
<td style="border:1px solid #f0f5f5"><strong><?=$user['Amount']?></strong></td>
<td style="border:1px solid #f0f5f5"><?=$user['Dat']?></td>
<td style="border:1px solid #f0f5f5"><?=$user['bnk']?></td>
<td style="border:1px solid #f0f5f5"><?=$user['EntryDate']?></td>
</tr>
<?php
$cnt=$cnt+1;
}?>
<tr style="border:1px solid #000">
    <td colspan="3" style="border:1px solid #e0ebeb">TOTAL:</td>
    <td style="border:1px solid #e0ebeb"><strong style="color:red"><?php echo $tsum; ?></strong></td>
    <td style="border: 1px solid #e0ebeb" colspan="3"></td>
</tr>
</tbody>
</table>
</body>

</html>