<?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"];
    $rd = $_REQUEST["rd"];

    if ($rd != "") {
        $read = "required";
    } else {
        $read = 'readonly';
    }
    $hide_var = "";

    if ($hide == 0) {
        $hide_var = 'style="display:none;"';
    }
    $mctr = $ctr;
    //    $mctr++;
    $ctr--;
    echo "<tr>";
    echo "<td class='text-center'><i class='fa fa-close remove' $hide_var ></i></td>";
    echo "<td><input type='text' name='srno[]' class='srno form-control  form '  value='$mctr' readonly></td>";

    echo "<td>";
    echo "<select class='form-control form item select2 fetchpart_$ctr' name='item[]' style='width:100%'>";
    echo "<option value=''></option>";
    $gitem3 = mysqli_query($conn, "SELECT `accode`,`name` FROM `accmast` WHERE `grpcode` = '012' order by name ") or die(mysqli_error($conn));
    while ($item3 = mysqli_fetch_array($gitem3)) {
        echo "<option value='$item3[accode]'>$item3[name]</option>";
    }
    echo "</select>";
    echo "</td>";

    echo "<td><input type='number' step='any' name='qty[]' class='qty form-control  text-right form' value='0'></td>";
    echo "<td><input type='text' name='unit[]' class='unit form-control  form' value='' readonly></td>";
    echo "</tr>";
    
    $ctr++;
} else {
    echo "ERROR";
}
?>