<?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 (isset($_REQUEST["ctr"])) {
    $ctr = $_REQUEST["ctr"];
    $mctr = $ctr;
    $mctr++;
    $hide = $_REQUEST["hide"];
    $aflag = $_REQUEST["addflag"];
    $itemname = $_REQUEST["item"];
    $unit = $_REQUEST["unit"];


    $hide_var = "";
    if ($hide == 0) {
        $hide_var = 'style="display:none;"';
    }
//    $mctr = $ctr;    
    echo "<tr>";
    echo "<td align='center' valign='top'><span class='remove fa fa-times' name='remove' value='remove' $hide_var></span></td>";
    Echo "<td><input type='text' value='$mctr'  name='srno_$ctr'  class='srno form-control form text-right' readonly></td>";

    Echo "<td>";
    Echo "<select class='select2 form form-control detailpart item' name='itemname_$ctr' style='width:100%'>";
    Echo "<option value='$itemname'>$itemname</option>";
    $getditem = mysqli_query($conn, "SELECT `code`, `name` FROM `item` GROUP BY `name` ORDER BY `name` ")or die(mysqli_error($conn));
    while ($ditem = mysqli_fetch_array($getditem)) {
        Echo "<option value='$ditem[name]'>$ditem[name]</option>";
    }
    Echo "</select>";
    Echo "<input type='hidden' class='itemcode' name='itemcode_$ctr' value=''>";

    Echo "</td>";
    Echo "<td>";
    Echo "<select class='form form-control detailpart size' name='size_$ctr' style='width:100%'>";
    Echo "<option value=''></option>";
    Echo "</select>";
    Echo "</td>";

    Echo "<td>";
    Echo "<select class='form form-control detailpart actsize' name='actsize_$ctr' style='width:100%'>";
    Echo "<option value=''></option>";
    Echo "</select>";
    Echo "</td>";
//    Echo "<td><input type='text' class='form-control form company' name='company_$ctr' value=''></td>";
    Echo "<td><input type='text' class='form-control form unit' name='unit_$ctr' value='$unit'></td>";
    Echo "<td><input type='text' class='form-control text-right form numeric opening' name='opening_$ctr'   value=''></td>";
    Echo "<td><input type='text' class='form-control text-right form numeric minimum' name='minimum_$ctr' value=''></td>";
    Echo "</tr>";

    $ctr++;
    $mctr++;
} else {
    echo "ERROR";
}
?>
 