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

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


    Echo "<tr>";
    Echo "<input type='hidden' name='itemcode_$ctr' class='itemcode form-control form' value=''>";
    Echo "<td><i class='fa fa-close remove' $hide_var ></i></td>";
    Echo "<td><input type='text' name='srno_$ctr' class='srno form-control  form'  value='$mctr'></td>";

    Echo "<td><input type='text' name='hsncode_$ctr' required='true' class='hsncode form-control  form' value='' ></td>";
    echo "<td><input list='browsers' name='descrip1_$ctr' value='' maxlength='25' class='descrip1  form-control form '>";
    echo "<datalist id='browsers' class='datadescrip1'> ";
    echo "<option value=''></option>";
    if ($ms == "M") {
        $mitem = mysqli_query($conn, "SELECT `descrip1` FROM `matsup` ") or die(mysqli_error($conn));
    } else {
        $mitem = mysqli_query($conn, "SELECT `descrip1` FROM `manservice` ") or die(mysqli_error($conn));
    }
    while ($trow = mysqli_fetch_array($mitem)) {
        $tdescrip = $trow['descrip1'];
        echo "<option value='$tdescrip'>";
    }
    echo "</datalist>";
    echo "</td>";

    echo "<td><input list='browsers2' name='descrip2_$ctr' value='' maxlength='25' class='descrip2  form-control form '>";
    echo "<datalist id='browsers2' class='datadescrip2'> ";
    echo "<option value=''></option>";
    if ($ms == "M") {
        $mitem2 = mysqli_query($conn, "SELECT `descrip2` FROM `matsup` ") or die(mysqli_error($conn));
    } else {
        $mitem2 = mysqli_query($conn, "SELECT `descrip2` FROM `manservice` ") or die(mysqli_error($conn));
    }
    while ($trow2 = mysqli_fetch_array($mitem2)) {
        $tdescrip2 = $trow2['descrip2'];
        echo "<option value='$tdescrip2'>";
    }
    echo "</datalist>";
    echo "</td>";

    echo "<td><input type='number' name='qty_$ctr' class='qty form-control  text-right form' step='any' value='0' ></td>";
    echo "<td><input type='number' step='any' name='rate_$ctr' class='rate form-control text-right  form'  value='0' >
              <input type='hidden' step='any' name='amount_$ctr' class='amount form-control text-right  form'  value='0' readonly>
              <input type='hidden' name='discperc_$ctr' class='discperc form-control text-right  form'  value='0'>
              <input type='hidden' name='discamt_$ctr' class='discamt form-control text-right  form' value='0' ></td>";
    echo "<td><input type='text' name='subtot_$ctr' class='subtot form-control text-right  form'     value='0' tabindex='-1' readonly></td>";
    echo "<td><input type='text' name='gstrate_$ctr' class='gstrate form-control text-right  form'   value='0'>
              <input type='hidden' name='gstamt_$ctr' class='gstamt form-control text-right  form'   value='0'></td>";
    echo "<td><input type='text' name='cgstrate_$ctr' class='cgstrate form-control text-right  form' value='0' readonly tabindex='-1' ></td>";
    echo "<td><input type='text' name='cgstamt_$ctr' class='cgstamt form-control text-right  form'   value='0' readonly tabindex='-1' ></td>";
    echo "<td><input type='text' name='sgstrate_$ctr' class='sgstrate form-control text-right  form' value='0' readonly tabindex='-1'></td>";
    echo "<td><input type='text' name='sgstamt_$ctr' class='sgstamt form-control text-right  form'   value='0' readonly tabindex='-1'></td>";
    echo "<td><input type='text' name='igstrate_$ctr' class='igstrate form-control text-right  form' value='0' readonly tabindex='-1'></td>";
    echo "<td><input type='text' name='igstamt_$ctr' class='igstamt form-control text-right  form'   value='0' readonly tabindex='-1' ></td>";
    echo "<td><input type='text' name='total_$ctr' class='total form-control text-right  form'       value='0' readonly tabindex='-1'></td>";
    echo "</tr>";
    $ctr++;
} else {
    echo "ERROR";
}
?>
 