<?php

require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include ("includes/function.php");

$zdb = $_SESSION["zdbyear_$dbname"];
mysqli_select_db($conn, $zdb);
$zroot = $_SESSION["zdir"];

if ($_REQUEST["vouchno"]) {
    $vouchno = $_REQUEST["vouchno"];
    $sdctr = $_REQUEST["schedcnt"];
    $gtsched = mysqli_query($conn, "Select a.*,b.name from `schedtreattemp` a, treatment b WHERE a. vouchno = '$vouchno' and a.treatment = b.code ") or die(mysqli_error($conn));

    $tctr = $sdctr;
    while ($rowsched = mysqli_fetch_array($gtsched)) {
        $tctr++;
        echo "<tr>";
        echo "<td></td>";
        echo "<td><input type='text' class='form-control form srno' value='$tctr' name='srno_$sdctr'></td>";
        echo "<td>";
        echo "<select id='streatment' name='streatment_$sdctr' class='form-control streatment form' style='width:100%'>";
        echo "<option value='$rowsched[treatment]'>$rowsched[name]</option>";
        echo "</select>";
        echo "</td>";
        echo "<td><input type='date' class='form-control form scheddate' value='$rowsched[scheddate]' name='scheddate_$sdctr'></td>";
        echo "<td><input type='text' class='form-control form remarks' value='' name='remarks_$sdctr'></td>";
        echo "<td><input type='date' class='form-control form compltdt' value='' name='compltdt_$sdctr'></td>";
        echo "</tr>";
        $sdctr++;
    }
    echo "<input type='hidden' name='schedcnt' id='schedcnt' value='$sdctr'>";
}
?>