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

 $active_tab = "dashboard"; 

 if (isset($_POST['save_data'])) {
  
 $readingdate = $_POST ['reading'];
 $duedate = $_POST ['due'];
 $disconnectiondate = $_POST ['disconnection'];

  $update_reading= "UPDATE tbl_reading_sched SET reading_date = '$readingdate',due_date = '$duedate',disconnection_date = '$disconnectiondate'  WHERE status = 1";
  mysqli_query($conn, $update_reading);
   
      $success = '<span class="text-success"><b>Successfully Upgraded!</b></span>';
  
 
 }


 if (isset($_POST['btn-genfilter'])) {
  
  $genpayment_date = $_POST['payment_date'];
  $payfor = $_POST['payfor'];


  if ($genpayment_date =='all') {
    $sql_user_details = "SELECT sum(amount) as totalcollection FROM tbl_payments LEFT JOIN tbl_user_account ON tbl_user_account.unique_id = tbl_payments.unique_id  order by Reading_date desc";
  

  }else {
    $sql_user_details = "SELECT sum(amount) as totalcollection  FROM tbl_payments LEFT JOIN tbl_user_account ON tbl_user_account.unique_id = tbl_payments.unique_id  where tbl_payments.payment_date = '$genpayment_date' or tbl_payments.payment_type = '$payfor' order by Reading_date desc";
}

$result_user_details = mysqli_query($conn, $sql_user_details);
$row_user_details = mysqli_fetch_assoc($result_user_details);
$totalcollection = $row_user_details['totalcollection'];


  ?>

  <script language="javascript">
       window.location.href = 'https://admin.amwd-services.com/dashboard/indexpaymentrecords.php?filter_date=<?php echo $genpayment_date ?>&&payfor=<?php echo $payfor;?>&&tc=<?php echo $totalcollection;?>';
     </script>
     <?php
  } 
  $genpayment_date = $_GET['filter_date']; 
 $payfor = $_GET['payfor'];
 $totalcollection = $_GET['tc'];?>
 

  
  
  
  
<!DOCTYPE html>
<html>
<head>
  <title>AWS Admin  Dashboard</title>

 
</head>
<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>
  <!-- Ionicons -->
  <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
  <!-- DataTables -->
  <link rel="stylesheet" href="plugins/datatables-bs4/css/dataTables.bootstrap4.min.css">
  <link rel="stylesheet" href="plugins/datatables-responsive/css/responsive.bootstrap4.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="dist/css/adminlte.min.css">
 
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs4/jszip-2.5.0/dt-1.10.20/b-1.6.1/b-colvis-1.6.1/b-html5-1.6.1/b-print-1.6.1/r-2.2.3/datatables.min.css" />
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts.js"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/v/bs4/jszip-2.5.0/dt-1.10.20/b-1.6.1/b-colvis-1.6.1/b-html5-1.6.1/b-print-1.6.1/r-2.2.3/datatables.min.js"></script>


  <?php include_once('linkStyle.php'); ?>
  
<style>
  .currencyinput {
    border: 1px inset #ccc;
}
.currencyinput input {
    border: 0;
}
  </style>
<div id="preloader" style="display:none;"></div>
<div class="wrapper">
  <nav class="main-header navbar navbar-expand navbar-white navbar-light">
    <ul class="navbar-nav">
   
      <li class="nav-item ml-2">
        <span class="brand-text title-form-brand font-weight-bolder fontSize-20">Dashboard</span>
      </li>
    </ul>

    <ul class="navbar-nav ml-auto">
      <li class="nav-item minBars">
        <a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>
      </li>
      <li class="nav-item dropdown" id="dropDownFullScreen">
        <a class="nav-link" data-toggle="dropdown" href="#">
          <i class="fas fa-user"></i>
        </a>
        <div class="dropdown-menu dropdown-menu-sm dropdown-menu-right">
          <a href="#" class="dropdown-item">
            <i class="fas fa-user mr-2"></i> 
            <span class="text-muted text-sm">Profile</span>
          </a>
          <div class="dropdown-divider"></div>
          <a href="../logout.php" class="dropdown-item dropdown-footer">Logout</a>
        </div>
      </li>
    </ul>
  </nav>
  <!-- /.navbar -->
  <?php include_once('navbar.php'); ?>

  <div class="content-wrapper" style="min-height: 363px;background: #fff;">

     
     
  <?php  
   
  
   include_once('referral_link.php'); 
      include_once('all_waterbill_pendings.php'); 
  ?>
  </div>

   
  
  <aside class="control-sidebar control-sidebar-dark">
  </aside>
</div>
<!-- ./wrapper -->
 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
	<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>

<script src="plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- DataTables -->
<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>
<!-- AdminLTE App -->
<script src="dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="dist/js/demo.js"></script>


  
  
<script src="https://cdn.datatables.net/buttons/2.3.2/js/dataTables.buttons.min.js"></script>

<script src="https://cdn.datatables.net/buttons/2.3.2/js/buttons.bootstrap4.min.js"></script>
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
<script src="https://cdn.datatables.net/buttons/2.3.2/js/buttons.html5.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.3.2/js/buttons.print.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.3.2/js/buttons.colVis.min.js"></script>

 
 
<!-- page script -->
<script>
 
 
$(function () {
  
   
  $('#example2').DataTable({
      "paging": true,
      "lengthChange": false,
      "searching": true,
      "ordering": true,
      "info": true,
      "autoWidth": false,
      "responsive": true,

      
      dom: 'Bfrtip',
      buttons: [
            { extend: 'copyHtml5', footer: true },
            { extend: 'excelHtml5', footer: true },
            { extend: 'pdfHtml5', footer: true },
            { extend: 'print', footer: true }
        ]
    
 
 } );
  

  $('#waterbillpendings').DataTable({
      "paging": true,
      "lengthChange": false,
      "searching": true,
      "ordering": true,
      "info": true,
      "autoWidth": false,
      "responsive": true,

      
      dom: 'Bfrtip',
      buttons: [
            { extend: 'copyHtml5', footer: true },
            { extend: 'excelHtml5', footer: true },
            { extend: 'pdfHtml5', footer: true },
            { extend: 'print', footer: true }
        ]
    
 
 } );
  
});
</script>

<script type="text/javascript"> 

//add meter reading
$(document).on("click", ".addmeterreading", function (e) {
  var id1 = $(this).attr("data-id");
  var acctholder1 = $(this).attr("data-name");
  var prevreading = $(this).attr("data-prevreading");

  $("#id_u1").val(id1);
  $("#txt_acct_holder1").val(acctholder1);
  $("#id-1").val(prevreading);
 
});

 

$(function () {
  $("#id-1, #id-2, #id-3,#id-4,#id-5").keyup(function () {
      (+$("#id-3").val
    (+$("#id-2").val() - +$("#id-1").val())) ;
  
    (+$("#id-5").val
    (+$("#id-3").val() * +$("#id-4").val())) ;

  });
});
</script>


</body>
</html>
	<script src="index_3.js"></script>
  