<?php
  session_start();
  require_once('../connect.php');
  require_once('sql_required.php');
  $datetoday = date('Y-m-d'); 

  $active_tab = "dashboard"; 
  error_reporting(E_ALL);
  ini_set('display_errors', 1);

  $unique_id      = $_GET['mid'];
  $acct_holder    = $_GET['acctholder'];
  $prev_reading   = $_GET['prev_reading'];
  $total_reading  = $_GET['total_reading'];
  $pres_reading   = $_GET['pres_reading']; 
  $billing_amount = $_GET['billing_amount'];
  $reading_date   = $_GET['reading_date'];
  $disconnection  = $_GET['disconnection'];
  $duedate        = $_GET['duedate'];
  $collection_date = $datetoday;
?>

<!DOCTYPE html>
<html lang="en">
<body class="hold-transition layout-footer-fixed layout-fixed sidebar-collapse">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.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="dist/css/adminlte.min.css">

<?php include_once('linkStyle.php'); ?>
  
  <style>
    .currencyinput {
      border: 1px inset #ccc;
  }
  .currencyinput input {
      border: 0;
  }
  
   
      
      @media print{
        #print {
          display:none;
        }
      }
      @media print {
        #PrintButton {
          display: none;
        }
      }
      
      @page {
        size: auto;   /* auto is the initial value */
        margin: 0;  /* this affects the margin in the printer settings */
      }
  
          .print-size {
              font-size:45px;
          }
    </style>

<div class="wrapper">
 
    <div class="content-wrapper" style="min-height: 363px;background: #fff; font-size: 23px; padding: 20px;">
 
    <div style="text-align: right;">
    <button id="PrintButton" class="btn-print" onclick="PrintPage()">Print</button>  
    <button onclick="window.location.href='printlogs_reading.php'"><< Back to list</button>
</div>

 
 <img src="images/logo2.png" width="10%" > 
  
 
 <div class="print-size">
    <?php
    if ($total_reading < 5) {
      $billing_amount = 300;
    }
    echo '<b>Transaction Date:</b> <br>' . $collection_date . '<br>';
    echo '<b> Account #:</b>  ' . $unique_id . '<br>';
    echo '<b> Account Name:  </b>';
    echo '<p style="font-size:50px;">' . $acct_holder . '</p>';
    echo '<hr>';
    echo '<b> Previous Reading:  </b>' . $prev_reading . '<br>';
    echo '<b> Current Reading:  </b>' . $pres_reading . '<br>';
    echo '<b> Total Reading:  </b>' . $total_reading . '<br>';
    echo '<b> Total Bill:  </b> &#8369;' . $billing_amount . '<br>';
    echo '<b> Reading Period:  </b>' . $reading_date . '<br>';
    echo '<b> Due Date:  </b>' . $duedate . '<br>';
    echo '<b> Disconnection:  </b>' . $disconnection . '<br>';
    echo '<hr>';
    echo '<b> REMAINING BALANCES:  </b><br>';
    echo '<b> Water Bill:  </b> &#8369;' . $totalunpaidwaterbillbill . '<br>';
    echo '<b> Meter Device:  </b> &#8369;' . $totalunpaidmeterfee . '<br>';
    ?>

  </div>

 
<script>
  function PrintPage() {
    window.print();
  }
 

    // When print finishes, automatically redirect after 5 seconds
    window.onafterprint = function() {
        setTimeout(function() {
            window.location.href = 'printlogs_reading.php';
        }, 16000);
    };

    // Auto trigger print when page loads
    window.addEventListener('DOMContentLoaded', function () {
        PrintPage();
        setTimeout(function(){ window.close(); }, 750);
    });

</script>



</body>
</html>
