<?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"]) {
    $ctr2 = $_REQUEST["ctr"];
    $mctr = $ctr2;
    $mctr++;

    Echo "<tr>";
    Echo "<td><i class='fa fa-close remove'></i></td>";
    Echo "<td><input type = 'text' class = 'form-control form text-right srno' name = 'srno_$ctr2' value = '$mctr'></td>";
    Echo "<td>";
    Echo "<select class = 'form-control form select2 fetchpart_$ctr2' name='itempart_$ctr2' style='width:100%'>";
    Echo "<option value=''></option>";
    $gitempart = mysqli_query($conn, 'SELECT `code`, `name` FROM `itempart`')or die(mysqli_error($conn));
    while ($fetitempart = mysqli_fetch_object($gitempart)) {
        Echo "<option value = '$fetitempart->code'>$fetitempart->name</option>";
    }
    Echo "</select>";
    Echo "</td>";
    Echo "<td><input type = 'text' class = 'form-control form text-right' name='qty_$ctr2' value= ''></td>";
    Echo "<td><input type='text' class='form-control form text-right' name='volume_$ctr2' value=''></td>";
    Echo "<td><input type = 'text' class = 'form-control form text-right' name='cost_$ctr2' value = ''></td>";
    Echo "</tr>";

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