<div class="container" style="margin-top: 20px;">
  <form method="get" action="Trans_New"> <input type="text" placeholder="input A/C no and enter" name="no"></form>
</div>

<?php
    if(isset($_GET["no"]) && isset($_GET["type"])&&$_GET["type"]=="Loan"){
        echo '
        <div class="container" style="margin-top: 20px;"> <h5>New Transaction : '.$GLOBALS['post_info'].' </h5><hr></div>
        <div class="container">
        <table class="table table-striped table-bordered table-hover table-responsive">
          <tr>
            <th>Name</th>
            <th>Phone</th>
            <th>AC No</th>
            <th>Remaining Amount</th>
            <th>Installment</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_ACNO` = '".$_GET["no"]."' ";
        $result = $conn->query($sql);
  
        if ($result->num_rows > 0) {
            while($row = $result->fetch_assoc()) {
                //$ID=$row["GC_ID"];
          echo "
          <tr>
            <td>".$row["AA_NAME"].    "</td>                
            <td>".$row["AA_PHONE"].  "</td>
            <td>".$row["AA_ACNO"]."</td>
            <td>".$row["AA_BAL"].  '</td>
            <td>
            <form method="post" enctype="multipart/form-data">
            <input type="hidden" name="FORM_NAME" value="add_installment">
            <input type="text" name="add_i" value="'.$row['AA_INSTALLMENT'].'">
            <input type="hidden" name="AA_ACNO" value="'.$row['AA_ACNO'].'"><input type="submit" class="btn-info" value="Receive"></form>
            </td>
          </tr>';
            }
        } else {echo "Check A/C no.";};
        $conn->close();

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


  if(isset($_GET["no"]) && isset($_GET["type"])&&$_GET["type"]=="Recurring"){
    echo '
    <div class="container" style="margin-top: 70px;"> <h5>New Transaction : '.$GLOBALS['post_info'].' </h5><hr></div>
    <div class="container">
    <table class="table table-striped table-bordered table-hover table-responsive">
      <tr>
        <th>Name</th>
        <th>Phone</th>
        <th>AC No</th>
        <th>Total Deposite</th>
        <th>Installment</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_ACNO` = '".$_GET["no"]."' ";
    $result = $conn->query($sql);

    if ($result->num_rows > 0) {
        while($row = $result->fetch_assoc()) {
            //$ID=$row["GC_ID"];
      echo "
      <tr>
        <td>".$row["AA_NAME"].    "</td>                
        <td>".$row["AA_PHONE"].  "</td>
        <td>".$row["AA_ACNO"]."</td>
        <td>".$row["AA_BAL"].  '</td>
        <td>
        <form method="post" enctype="multipart/form-data">
        <input type="hidden" name="FORM_NAME" value="add_installment">
        <input type="text" name="add_i" value="'.$row['AA_INSTALLMENT'].'">
        <input type="hidden" name="AA_ACNO" value="'.$row['AA_ACNO'].'"><input type="submit" class="btn-info" value="Receive"></form>
        </td>
      </tr>';
        }
    } else {echo "Check A/C no.";};
    $conn->close();

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

<div class="container" style="margin-top: 70px;">
  <h5>Past Transactions::::</h5><hr>
</div>

<?php

if(isset($_GET["no"])){
  echo '
  <div class="container">
  <table class="table table-striped table-bordered table-hover table-responsive">
    <tr>
      <th>SL</th>
      <th>Tr No</th>
      <th>TimeStamp</th>
      <th>User</th>
      <th>A/C No</th>
      <th>Amount</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_tran']."` WHERE  `AT_ACID` =  '".$_GET['no']."'";
    $sql = "SELECT * FROM `".$GLOBALS['arif_tran']."` WHERE  `AT_ACID` =  '".$_GET['no']."'  ORDER BY `".$GLOBALS['arif_tran']."`.`AT_ID` DESC";
    $result = $conn->query($sql);
    $i=0;
    if ($result->num_rows > 0) {
        while($row = $result->fetch_assoc()) {
            //$ID=$row["GC_ID"];
            $i++;
            echo "
            <tr>
              <td>".$i.    "</td>                
              <td>".$row["AT_ID"].    "</td>                
              <td>".$row["AT_TIMESTAMP"].  "</td>
              <td>".$row["AT_USER"]. "</td>
              <td>".$row["AT_ACID"].   "</td>
              <td>".$row["AT_AMOUNT"].   "</td>
            </tr>";
        }
    } else echo "No Past record Found";
    $conn->close();
    echo '
    </table>
    </div>
    ';
  }
?>