<?php

require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include ('includes/function.php');

$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn, $zdb);
$admin = $_SESSION["admin_" . $dbname];

if ($_REQUEST["ctr"]) {
    $ctr = $_REQUEST["ctr"];
    $hide = $_REQUEST["hide"];
    $party = $_REQUEST["party"];
    $hide_var = "";
    $data = "";
//    if (!empty($party)) {

    $getprevbill = mysqli_query($conn, "SELECT * FROM `prevbill` WHERE `accode` = '$party'") or die(mysqli_error($conn));
    while ($fprevbill = mysqli_fetch_array($getprevbill)) {

        if ($hide == 0) {
            $hide_var = 'style="display:none;"';
        }
        $mctr = $ctr;
        $mctr++;

        $data.= "<tr>" .
                "<td><i class='fa fa-close remove' $hide_var ></i></td>" .
                "<td><input type='text' class='form-control pyear focusFld_$ctr'   name='year_$ctr'   maxlength='4' value='$fprevbill[yearno]' required></td>" .
                "<td><input type='text' class='form-control billno'   name='billno_$ctr'  value='$fprevbill[billno]' maxlength='15'></td>" .
                "<td><input type='date' class='form-control billdate'  value='$fprevbill[billdate]'  name='billdate_$ctr'></td>" .
                "<td><input type='number' class='form-control billamt text-right'   name='billamt_$ctr'  value='$fprevbill[billamt]' ></td>" .
                "</tr>";
        $ctr++;
    }
    echo $data;
//    }
}
?> 