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

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

if ($_REQUEST["ctr"]) {
    $ctr = $_REQUEST["ctr"];
    $mctr = $ctr;
    $mctr++;
    $cmbgrp = $_REQUEST["cmbgrp"];
 
    echo "<tr>";
    echo "<td align='left' valign='top'><input type='text' size='6' maxlength='6' name='srno_$ctr' class='sno form-control' style='height:33px;' value='$mctr'/></td>";
    echo "<td align='left'>";
    echo "<input list='item' name='item_$ctr' class='item form-control' style='height:33px;'>";
    
    echo "<datalist id='item_$ctr'>";
    echo "<option value=''></option>";
    $mitem1 = mysqli_query($conn, "SELECT `name` FROM `item` WHERE `group` = '$cmbgrp' ORDER BY name") or die(mysqli_error($conn));
    while ($trow1 = mysqli_fetch_array($mitem1)) {
        echo "<option value='$trow1[name]'>";
    }
    echo "</datalist>";
    echo "</td>";
    
    echo "<td align='center' valign='top'>";
    echo "<select name='color_$ctr' style='height:34px;' class='form-control'>";
    echo "<option value=''></option>";
    $getcolors = mysqli_query($conn, "SELECT `code`, `name` FROM `color` ORDER BY name") or die(mysqli_error($conn));
    while ($wcol = mysqli_fetch_array($getcolors)) {
        echo "<option value='$wcol[code]' >$wcol[name]</option>";
    }

    echo "</select>";
    echo "</td>";

    echo "<td align='center' valign='top'><input type='text' size='4' maxlength='4' name='s5_$ctr'  class='s5 form-control' style='text-align:right;height:33px;' value='0'/></td>";
    echo "<td align='center' valign='top'><input type='text' size='4' maxlength='4'  name='s6_$ctr' class='s6 form-control' style='text-align:right;height:33px;' value='0'/></td>";
    echo "<td align='center' valign='top'><input type='text' size='4' maxlength='4'  name='s7_$ctr' class='s7 form-control'  style='text-align:right;height:33px;' value='0'/></td>";
    echo "<td align='center' valign='top'><input type='text' size='4' maxlength='4'  name='s8_$ctr' class='s8 form-control'  style='text-align:right;height:33px;' value='0'/></td>";
    echo "<td align='center' valign='top'><input type='text' size='4' maxlength='4'  name='s9_$ctr' class='s9 form-control'  style='text-align:right;height:33px;' value='0'/></td>";
    echo "<td align='center' valign='top'><input type='text' size='4' maxlength='4'  name='s10_$ctr' class='s10 form-control'  style='text-align:right;height:33px;' value='0'/></td>";
    echo "<td align='center' valign='top'><input type='text' size='4' maxlength='4'  name='s11_$ctr' class='s11 form-control'  style='text-align:right;height:33px;' value='0'/></td>";
    echo "<td align='center' valign='top'><input type='text' size='4' maxlength='4'  name='s12_$ctr' class='s12 form-control'  style='text-align:right;height:33px;' value='0'/></td>";
    echo "<td align='center' valign='top'><input type='text' size='4' maxlength='4'  name='soth_$ctr' class='soth form-control'  style='text-align:right;height:33px;' value='0'/></td>";
    echo "<td align='center' valign='top'><input type='text' size='4'  name='qty_$ctr' class='qty form-control'  style='text-align:right;height:33px;' value='0' readonly/></td>";
    echo "<td align='center' valign='top'><input type='text' size='4' name='mrp_$ctr' class='mrp form-control'  style='text-align:right;height:33px;' value='0'/></td>";
    echo "<td align='center' valign='top'><input type='text' size='4' name='rate_$ctr' class='rate form-control' style='text-align:right;height:33px;' value='0'/>
<input type='hidden' size='4'  name='amt_$ctr' class='amt form-control'  style='text-align:right;height:33px;' value='0' readonly/>                                          

</td>";

    echo "</tr>";
} else {
    echo "ERROR";
}
?>
