<?php
session_start();
include('../include/config.php');
//error_reporting(0);
$trm=$_SESSION['tmm'];
$bid=$_SESSION['bankse'];
$dat=$_SESSION['mmmm'];

 $yrr=substr($dat, 0, 4);
 $mm=substr($dat, 5, 2);

if($mm=='01'){$mm='January';}
if($mm=='02'){$mm='February';}
if($mm=='03'){$mm='March';}
if($mm=='04'){$mm='April';}
if($mm=='05'){$mm='May';}
if($mm=='06'){$mm='June';}
if($mm=='07'){$mm='July';}
if($mm=='08'){$mm='August';}
if($mm=='09'){$mm='September';}
if($mm=='10'){$mm='October';}
if($mm=='11'){$mm='November';}
if($mm=='12'){$mm='December';}

$sql = "select * from bankdata where id='$bid'";
$result = $con->query($sql);
while($row = $result->fetch_assoc()) 
{
  $bname=$row["Bname"]; 
  $act=$row["Account"]; 
}


$sqll = "select SUM(Amount) as tot FROM Expenses where Account='$bid' AND Year='$yrr' AND Month='$mm'";
$result = $con->query($sqll);
if($result>0)
{
while($row = $result->fetch_assoc()) 
{
  $tott=$row["tot"]; 
}
}else
{
  $tott='0';  
}


?>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Expenditure Report</title>
   <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="../plugins/tempusdominus-bootstrap-4/css/tempusdominus-bootstrap-4.min.css">
  <link rel="stylesheet" href="../plugins/fontawesome-free/css/all.min.css">
  <!-- SweetAlert2 -->
  <link rel="stylesheet" href="../plugins/sweetalert2-theme-bootstrap-4/bootstrap-4.min.css">
  <link rel="stylesheet" href="../plugins/datatables-bs4/css/dataTables.bootstrap4.min.css">
  <link rel="stylesheet" href="../plugins/datatables-responsive/css/responsive.bootstrap4.min.css">
  <link rel="stylesheet" href="../plugins/datatables-buttons/css/buttons.bootstrap4.min.css">
  <!-- Toastr -->
  <link rel="stylesheet" href="../plugins/toastr/toastr.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  
  <link rel="stylesheet" href="../dist/css/adminlte.min.css">
    <link rel="stylesheet" href="../plugins/icheck-bootstrap/icheck-bootstrap.min.css">
  <link rel="stylesheet" href="../plugins/overlayScrollbars/css/OverlayScrollbars.min.css">
  <link rel="stylesheet" href="plugins/daterangepicker/daterangepicker.css">
  <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
  <link rel="shortcut icon" href="../images/logo.ico">
  <style>
      .bigger{
          font-size:16px;
          font-family:Tahoma;
      }
      .farmamount
      {
          font-size:18px;
          color:red;
      }
      .requireds
      {
          color:red;
      }
      #tablefarmincome
      {
       font-size:14px;   
      }
      #tablebankdata
      {
          font-size:14px;
      }
      #idmonthincome
      {
          font-size:14px;
          font-family:Robot;
      }
       #tablebusdata
      {
         font-size:12px;
      }
      #tablestaffsss
      {
          font-size:13px;
          font-family:Tahoma;
      }
      
      #tableexpenditure
      {
          font-size:13px;
      }
      
      .incomeperclasstable
      {
          font-size:14px;
      }
      
      .bstaffedit{
          font-size:10px;
      }
      
      .btnstafdelete{
          font-size:10px;
      }
      
      .side{
          box-shadow: 0 0 0 10px #4fc3dc44,
	0 0 50px #4fc3dc, 0 0 100px #4fc3dc;
	border-radius: 5px;
      }
      
      
	 .fc-dayGridMonth-button{
        font-size:10px;
    }
    
    .fc-dayGridWeek-button{
        font-size:10px;
    }
    
    .fc-list-button{
        font-size:10px;
    }
    
    .fc-today-button{
        font-size:10px;
    }
    
    .fc-prev-button{
        font-size:11px;
    }
    
    .fc-next-button{
        font-size:11px;
    }
    
    body{
        padding:10px;
    }
      
  </style>
  
  <link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" crossorigin="anonymous"/>
    <link rel="stylesheet" href="schedule/fullcalendar/lib/main.min.css">
    <script src="schedule/fullcalendar/lib/main.min.js"></script>
    
    <link rel="stylesheet" href="schedule/fullcalendar/lib/main.min.css">
    <script src="schedule/fullcalendar/lib/main.min.js"></script>
</head>
<!--body class="hold-transition sidebar-mini layout-fixed" onload="window.print()"-->
<body class="hold-transition sidebar-mini layout-fixed">
 <div class="wrapper">
     <div class="container" style="border:2px solid gray;border-radius:5px">
        <?php
        $sql = "select SUM(Amount) as Tot  FROM Imprest2 where Imprest='$impid'";
        $result = $con->query($sql);
        while($row = $result->fetch_assoc()) 
        {
        $tot=$row["Tot"]; 
        }
        
        $bal=$amt-$tot;
        ?>
         <center><h3>BISHOP KAIRO EDUCATION CENTRE</h3></center>
          <center><h4>EXPENDITURE REPORT</h4></center>
         <center><h5>Bank Debited: <u><?php echo $bname; ?> (<?php echo $act; ?>)</u></h5></center>
         
         <center><h5>Month: <u><strong><?php echo $mm.' '.$yrr; ?></strong></u>&nbsp; &nbsp;  Total Amount: <strong><?php echo $tott; ?></strong></h5></center>
         <hr />
      <table class="table table-bordered" id="tablefees" >
                     <thead>
                        
                         <tr style="font-size:15px;font-weight:bold;color:#000">
                             <th>#</th>
                             <th>Particular <?php echo $mon; ?></th>
                             <th>Amount</th>
                             <th>Expense date</th>
                             <th>Category</th>
                             <th>Pay Mode</th>
                             <th>Cheque No</th>
                             <th>Entry date</th>
                         </tr>
                     </thead>
                     <tbody>
                    <?php
                  $sql = "select Expenses.*,expenses.Item as ite from Expenses left join expenses ON expenses.Count=Expenses.Cat where Account='$bid' AND Year='$yrr' AND Month='$mm' order by ExpDate DESC";
                    $result = $con->query($sql);
                    if ($result->num_rows > 0) 
                    {
                        $cnt='1';
                        while($row = $result->fetch_assoc()) 
                        {
                    ?>	
                    <tr>
                        <td><?php echo $cnt; ?></td>
                        <td><?php echo $row["Particular"]; ?></td>
                        <td class="alert-success"><?php echo $row["Amount"]; ?>
                        </td>
                        <td><strong><?php echo $row["ExpDate"]; ?></strong></td>
                        <td><?php echo $row["ite"]; ?></td>
                        <td><?php echo $row["Mode"]; ?></td>
                        <td><?php echo $row["Details"]; ?></td>
                        <td><?php echo $row["EntryDate"]; ?></td>
                    </tr>
                    <?php
                    $cnt=$cnt+1;
                    }
                    }
                    ?>
                     </tbody>
                        <?php
                        $sql = "select SUM(Amount) as Tot  FROM Imprest2 where Imprest='$impid'";
                        $result = $con->query($sql);
                        while($row = $result->fetch_assoc()) 
                        {
                        $tot=$row["Tot"]; 
                        }

                        ?>
                      <tr style="font-size:15px;font-weight:bold" class="bg-secondary">
                        <td colspan="2">TOTAL (KES)</td>
                        <td colspan="6" style="font-size:15px;font-weight:bold"><strong><?php echo $tott; ?></strong>
                        </td>
                        </tr>
                 </table> 
                 <hr />
                 
     </div>
 </div>
 
 <script src="../plugins/jquery/jquery.min.js"></script>
<!-- jQuery UI 1.11.4 -->
<script src="//plugins/jquery-ui/jquery-ui.min.js"></script>
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
<script>
  $.widget.bridge('uibutton', $.ui.button)
</script>
<!-- Bootstrap 4 -->
<script src="../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
<!-- ChartJS -->
<script src="../plugins/chart.js/Chart.min.js"></script>
<!-- Sparkline -->
<script src="./plugins/sparklines/sparkline.js"></script>
<!-- JQVMap -->
<script src="../plugins/jqvmap/jquery.vmap.min.js"></script>
<script src="../plugins/jqvmap/maps/jquery.vmap.usa.js"></script>
<!-- jQuery Knob Chart -->
<script src="../plugins/jquery-knob/jquery.knob.min.js"></script>
<!-- daterangepicker -->
<script src="../plugins/moment/moment.min.js"></script>
<script src="../plugins/daterangepicker/daterangepicker.js"></script>
<!-- Tempusdominus Bootstrap 4 -->
<script src="../plugins/tempusdominus-bootstrap-4/js/tempusdominus-bootstrap-4.min.js"></script>
<!-- Summernote -->
<script src="../plugins/summernote/summernote-bs4.min.js"></script>
<!-- overlayScrollbars -->
<script src="../plugins/overlayScrollbars/js/jquery.overlayScrollbars.min.js"></script>
<!-- AdminLTE App -->
<script src="../dist/js/adminlte.js"></script>
<!-- AdminLTE for demo purposes -->
<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
<script src="../dist/js/pages/dashboard.js"></script>

<!--Data tables -->
<script src="../plugins/datatables/jquery.dataTables.min.js"></script>
<script src="../plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="../plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="../plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
<script src="../plugins/datatables-buttons/js/dataTables.buttons.min.js"></script>
<script src="../plugins/datatables-buttons/js/buttons.bootstrap4.min.js"></script>
<script src="../plugins/datatables-buttons/js/buttons.html5.min.js"></script>
<script src="../plugins/datatables-buttons/js/buttons.print.min.js"></script>
<script src="../plugins/datatables-buttons/js/buttons.colVis.min.js"></script>
</body>
