<?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"];
    $procode = $_REQUEST["prodcode"];
    $srno = $_REQUEST["srno"];
    $srno++;
    $hide_var = "";
    if ($hide == 0) {
        $hide_var = 'style="display:none;"';
    }
    $mctr = $ctr;
    $mctr++;
    Echo "<tr class='curr'>";
    Echo "<td><i class='fa fa-close remove' $hide_var></i></td>";
    Echo "<td><input type='text' class='form-control form text-right srno4'      name='srno4'        value='$srno' readonly></td>";
    Echo "<td>";
    Echo "<select class='form-control form packing select2' name='packing' style='width:100%' >";
    Echo "<option value=''></option>";
    $getitm2 = mysqli_query($conn, "SELECT code, name FROM `packing` order by code")or die(mysqli_error($conn));
    while ($mitem2 = mysqli_fetch_array($getitm2)) {
        Echo "<option value='$mitem2[code]'>$mitem2[name]</option>";
    }
    Echo "</select>";
    Echo "</td>";
    Echo "<td>";
    Echo "<select class='form-control form unit select2' name='punit' style='width:100%' >";
    Echo "<option value=''></option>";
    $gunit2 = mysqli_query($conn, "SELECT code, name FROM `unit` order by code")or die(mysqli_error($conn));
    while ($munit2 = mysqli_fetch_array($gunit2)) {
        Echo "<option value='$munit2[name]'>$munit2[name]</option>";
    }
    Echo "</select>";
    Echo "</td>";
    Echo "<td><input type='hidden' class='form-control form prodcode'   name='relprod'  value='$procode'>
              <input type='number' class='form-control form text-right pqty'   name='pqty'  step='any'   value='0'></td>";
//    Echo "<td><input type='number' class='form-control form text-right pcost'   name='pcost_$ctr'  step='any'   value='0'></td>";
//    Echo "<td><input type='number' class='form-control form text-right pamount'   name='pamount_$ctr'  step='any'   value='0'></td>";
    Echo "</tr>";
    $ctr++;
} else {
    echo "ERROR";
}
?>
 