<?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;
    $mctr++;

    echo "<tr class='caltreat'>";
    echo " <td><i class='fa fa-trash remove' style='display:none;font-size:24px'></i></td>";

    echo "<td><input type='text' class='form-control form srno' value='$mctr' name='srno_$ctr'></td>";
    echo "<td>";
    echo "<input list='btreatment' name='btreatment_$ctr' class='btreatment form-control form ' autocomplete='off' value=''> ";
    echo "<datalist id='btreatment' char='#'>";
    echo "<option>";

    $mit = mysqli_query($conn, "SELECT `name` FROM `treatment` group by name") or die(mysqli_error($conn));

    while ($tit = mysqli_fetch_array($mit)) {
        $itname = $tit['name'];
        echo "<option value='$itname'>";
    }

    echo "</datalist>";
    echo "</td>";
    echo "<td><input type='text' class='form-control form text-right qty' value='' name='bqty_$ctr'></td>";
    echo "<td><input type='text' class='form-control form text-right duration' value='' name='bduration_$ctr'></td>";
    echo "<td><input type='textbox' name='brate_$ctr' class='rate text-right form-control form' value='' ></td>";
    echo "<td><input type='textbox' name='bamt_$ctr' class='amt text-right form-control form' value=''  readonly tabindex='-1'></td>";
    echo "<td class='text-center'>";
    echo "<input type='checkbox' name='baprov_$ctr' class='aprov form-control form' value='1' style='height:25px;width:25px' >";
    echo "</td>";
    echo "<td><input type='date' class='form-control form firstdate' value='' name='bfirstdate_$ctr'></td>";
    echo "</tr>";
    $ctr++;
} else {
    echo "ERROR";
}
