<?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"];
    $hide_var = "";
    if ($hide == 0) {
        $hide_var = 'style="display:none;"';
    }
    $mctr = $ctr;
    $mctr++;

    Echo "<tr>";
    Echo "<td><i class='fa fa-close remove' style='display:none;'></i></td>";
    Echo "<td><input type='text' class='form-control form text-right srno' name='srno_$ctr' value='$mctr'></td>";
    Echo "<td>";
    echo "<input list='brand' name='brand_$ctr' class='brand form-control form ' autocomplete='off' value=''> ";
    echo "<datalist id='brand' char='#'>";
    echo"<option>";

    $gbrand = mysqli_query($conn, 'SELECT * FROM `brand`')or die(mysqli_error($conn));
    while ($brand = mysqli_fetch_array($gbrand)) {
        Echo "<option value='$brand[name]'>";
    }
    echo "</datalist>";
    Echo "</td>";

    Echo "<td>";
    echo "<input list='itemcode' name='itemcode_$ctr' class='itemcode form-control form ' autocomplete='off' value=''> ";
    echo "<datalist id='itemcode' char='#'>";
    echo"<option>";

    $gitemcode = mysqli_query($conn, 'SELECT * FROM `item`')or die(mysqli_error($conn));
    while ($fitemcode = mysqli_fetch_array($gitemcode)) {
        Echo "<option value='$fitemcode[code]'></option>";
    }
    echo "</datalist>";
    Echo "</td>";


    Echo "<td>";
    echo "<input list='item' name='item_$ctr' class='item form-control form ' autocomplete='off' value=''> ";
    echo "<datalist id='item' char='#'>";
    echo"<option>";

    $gitem = mysqli_query($conn, 'SELECT * FROM `item`')or die(mysqli_error($conn));
    while ($item = mysqli_fetch_array($gitem)) {
        Echo "<option value='$item[name]'></option>";
    }
    echo "</datalist>";
    Echo "</td>";
    Echo "<td><input type='text' class='form-control form text-right qty'       name='qty_$ctr'         value=''></td>";
//    Echo "<td><input type='text' class='form-control form text-left unit'       name='unit_$ctr'         value=''></td>";
    Echo "<td><input type='text' class='form-control form text-right baleqty'       name='baleqty_$ctr'         value=''></td>";
    Echo "<td><input type='text' class='form-control form text-right totqty'    name='totqty_$ctr'      value='' readonly></td>";
    Echo "<td><input type='text' class='form-control form text-right rate'      name='rate_$ctr'        value=''></td>";
    Echo "<td><input type='text' class='form-control form text-right amount'    name='amount_$ctr'      value='' readonly>"
            . "<input type='hidden' class='containerno' value=''  name='containerno'_$ctr></td>";
    Echo "</tr >";
    $ctr++;
} else {
    echo "ERROR";
}
?>
 