<div class="container" style="background-color:#e0a3a3;padding:8px;">
  <ul class="nav nav-pills nav-justified">
    <li <?php if(isset($_GET['Type']) && $_GET['Type']=="FD") echo'class="active"';?>><a href="View_AC?Type=FD">Fixed Deposits</a></li>
    <li <?php if(isset($_GET['Type']) && $_GET['Type']=="Loan") echo'class="active"';?>><a href="View_AC?Type=Loan">Loan A/C</a></li>
    <li <?php if(isset($_GET['Type']) && $_GET['Type']=="Recurring") echo'class="active"';?>><a href="View_AC?Type=Recurring">Recurring A/Cs</a></li>
  </ul>
</div>


<?php
function view_list_ac($type) {
echo '
<div class="container" style="margin-top: 70px;">
<h5>VIEW CUSTOMERS</h5><hr>
</div>
<div class="container">
<table class="table table-striped table-bordered table-hover table-responsive">
  <tr>
    <th>SL</th>
    <th>Type</th>
    <th>AC No</th>
    <th>Name</th>
    <th>PHONE</th>
    <th>Balance</th>
  </tr>';
  $conn = new mysqli($GLOBALS['host'], $GLOBALS['user'], $GLOBALS['pass'], $GLOBALS['db']);
  if ($conn->connect_error) {
      die("Connection failed: " . $conn->connect_error);
  }

  $sql = "SELECT * FROM `".$GLOBALS['arif_ac']."` WHERE `AA_TYPE`='".$type."' ORDER BY `AA_ID` DESC";
  $result = $conn->query($sql);

  if ($result->num_rows > 0) {
      while($row = $result->fetch_assoc()) {
          //$ID=$row["GC_ID"];
          $tt=$row["AA_ID"]-10;
          echo "
          <tr>
            <td>".$tt.    "</td>                
            <td>".$row["AA_ACTYPE"].",".$row["AA_TYPE"].  "</td>
            <td><a href='./Details?no=".$row["AA_ACNO"]."&type=".$row["AA_TYPE"]."'>".$row["AA_ACNO"]."</a> &nbsp;&nbsp; <a href='./Trans_New?no=".$row["AA_ACNO"]."&type=".$row["AA_TYPE"]."'>Transact</a></td>
            <td>".$row["AA_NAME"].  "</td>
            <td>".$row["AA_PHONE"]. "</td>
            <td>".$row["AA_BAL"].   "</td>
          </tr>";
      }
  } else {
      echo "0 results";
  };
  $conn->close();

echo '
</table>
</div>
';
}


if(isset($_GET['Type']) && $_GET['Type']=="Loan") view_list_ac('Loan');
if(isset($_GET['Type']) && $_GET['Type']=="Recurring") view_list_ac('Recurring');
if(isset($_GET['Type']) && $_GET['Type']=="FD") view_list_ac('FD');
?>



