<?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"];
    $hide_var = "";
    if ($hide == 0) {
        $hide_var = 'style="display:none;"';
    }
    $mctr = $ctr;


    $f1 = "prodtype";
    $f2 = "prodcode";
    $f3 = "particulars";
    $f4 = "unit";
    $f5 = "qty";
    $f6 = "freeqty";
    $f7 = "totalqty";
    $f8 = "tcsamt";
    $f9 = "amount";
    $f10 = "discperc";
    $f11 = "discount";
    $f12 = "vat";
    $f13 = "vatadd";
    $f14 = "total";

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

    echo "<td>";
    echo "<select class='form-control form $f1' name='{$f1}_{$ctr}'>";
    echo "<option value=''></option>";
    echo "<option value='P'>P</option>";
    echo "<option value='L'>L</option>";
    echo "</select>";
    echo "</td>";

    Echo "<td><input type='text' class='form-control form $f2'              name='{$f2}_{$ctr}'  value=''></td>";
    echo "<td style='display:none' class='prodtd'>";
    echo "<select class='form-control form particulars' name=''>";
    echo "<option value=''></option>";

    $getpd1 = mysqli_query($conn, "SELECT * FROM `product` order by name") or die(mysqli_error($conn));
    while ($row1 = mysqli_fetch_array($getpd1)) {
        echo "<option value='$row1[prodcode]'>$row1[name]</option>";
    }
    echo "</select>";
    echo "</td>";
    echo "<td class='parttd'><input type='text' name='particulars_$ctr' class='particulars form-control form' value=''></td>";
    Echo "<td><input type='text' class='form-control form $f4'              name='{$f4}_{$ctr}'  value=''></td>";
    Echo "<td><input type='text' class='form-control form $f5'              name='{$f5}_{$ctr}'  value='0'></td>";
    Echo "<td><input type='text' class='form-control form $f6  text-right'  name='{$f6}_{$ctr}'  value='0'></td>";
    Echo "<td><input type='text' class='form-control form $f7  text-right'  name='{$f7}_{$ctr}'  value='0'></td>";
    Echo "<td><input type='text' class='form-control form $f8  text-right'  name='{$f8}_{$ctr}'  value='0'></td>";
    Echo "<td><input type='text' class='form-control form $f9  text-right'  name='{$f9}_{$ctr}'  value='0'></td>";
    Echo "<td><input type='text' class='form-control form disperc text-right'  name='{$f10}_{$ctr}' value='0'></td>";
    Echo "<td><input type='text' class='form-control form discamt text-right'  name='{$f11}_{$ctr}' value='0'></td>";
    Echo "<td><input type='text' class='form-control form $f12 text-right'  name='{$f12}_{$ctr}' value='0'></td>";
    Echo "<td><input type='text' class='form-control form $f13 text-right'  name='{$f13}_{$ctr}' value='0'></td>";
    Echo "<td><input type='text' class='form-control form $f14 text-right'  name='{$f14}_{$ctr}' value='0'  readonly tabindex='-1'></td>";
    Echo "</tr>";
    $ctr++;
    $mctr++;
} else {
    echo "ERROR";
}
?>
 