<?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];
$zroot = $_SESSION["zdir"];

if ($_REQUEST["ctr"]) {
    $ctr = $_REQUEST["ctr"];
    $hide = $_REQUEST["hide"];
    $hide_var = "";
    if ($hide == 0) {
        $hide_var = 'style="display:none;"';
    }
    $mctr = $ctr;
    $mctr++;

    Echo "<tr>";
    echo "<td><input type='checkbox' style='border:none;position: inherit;height:25px;width:25px;' align='center' name= 'prncomp_$ctr' value='1' class='form-control form'></td>";

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

    Echo "<td>";
    Echo "<select class='form-control form city select2 fetchpart_$ctr' name='city_$ctr' style='width:100%'  >";
    Echo "<option value=''></option>";
    $gcity = mysqli_query($conn, "SELECT `code`,`name` FROM `city` ORDER BY `name`")or die(mysqli_error($conn));
    while ($icity = mysqli_fetch_array($gcity)) {
        Echo "<option value='$icity[code]'>$icity[name]</option>";
    }
    Echo "</select>";
    Echo "</td>";

    Echo "<td>";
    Echo "<select class='form-control form hotelnm select2 fetchpart_$ctr' name='hotelnm_$ctr' style='width:100%'  >";
    Echo "<option value=''></option>";
    $mhotl = mysqli_query($conn, "SELECT code,hotelnm FROM hotels  order by hotelnm ") or die(mysqli_error($conn));
    while ($thotl = mysqli_fetch_array($mhotl)) {
        echo "<option value='$thotl[code]'>$thotl[hotelnm]</option>";
    }
    Echo "</select>";
    Echo "</td>";

    Echo "<td><input type='date' class='form-control form checkin'        name='checkin_$ctr' value=''></td>";
    Echo "<td><input type='date' class='form-control form checkout'        name='checkout_$ctr' value=''></td>";
    Echo "<td><input type='number' class='form-control text-center form nonights'        name='nonights_$ctr' value=''></td>";
    Echo "<td><input type='number' class='form-control text-center form hotelpax'        name='hotelpax_$ctr' value=''></td>";

    // Echo "<td>";
    // Echo "<select class='form-control form roomcatg select2 fetchpart_$ctr' name='roomcatg_$ctr' style='width:100%'  required>";
    // Echo "<option value=''></option>";
    // $git = mysqli_query($conn, "SELECT `code`,`name` FROM `roomcatg` ORDER BY `name`")or die(mysqli_error($conn));
    // while ($itm = mysqli_fetch_array($git)) {
    //     Echo "<option value='$itm[code]'>$itm[name]</option>";
    // }
    // Echo "</select>";
    // Echo "</td>";
    echo "<td>";
    echo "<select class='form-control form roomview select2 fetchpart_$ctr' name='roomview_$ctr' style='width:100%'  >";
    echo "<option value=''></option>";
    $gitr = mysqli_query($conn, "SELECT `code`,`name` FROM `roomview` ORDER BY `name`") or die(mysqli_error($conn));
    while ($itr = mysqli_fetch_array($gitr)) {
        echo "<option value='$itr[code]'>$itr[name]</option>";
    }
    echo "</select>";
    echo "</td>";
    Echo "<td>";
    Echo "<select class='form-control form roomtype select2 fetchpart_$ctr' name='roomtype_$ctr' style='width:100%'  required>";
    Echo "<option value=''></option>";
    $git2 = mysqli_query($conn, "SELECT `code`,`name` FROM `roomtype` ORDER BY `name`")or die(mysqli_error($conn));
    while ($itm2 = mysqli_fetch_array($git2)) {
        Echo "<option value='$itm2[code]'>$itm2[name]</option>";
    }

    Echo "</select>";
    Echo "</td>";

    Echo "<td><input type='text' class='form-control form text-right qty'    name='qty_$ctr'  value='0'></td>";
    Echo "<td><input type='text' class='form-control form text-right rate'    name='rate_$ctr'  value='0'></td>";
    Echo "<td><input type='text' class='form-control form text-right hamount'  name='amount_$ctr'  value='0' readonly ></td>";

    echo "<td>";
    echo "<select class='form-control form mealtype select2  fetchpart_$ctr' name='mealtype_$ctr' style='width:100%'>";
    echo "<option value=''></option>";
    $gitmeal = mysqli_query($conn, "SELECT `code`,`name` FROM $zroot.`mealtype` ORDER BY `name`") or die(mysqli_error($conn));
    while ($itmeal = mysqli_fetch_array($gitmeal)) {
        echo "<option value='$itmeal[code]'>$itmeal[name]</option>";
    }
    echo "</select>";
    echo "</td>";

    echo "<td><input type='text' class='form-control form cnfno'  name='cnfno_$ctr'  value='' ></td>";
    Echo "<td><input type='text' class='form-control form remarks'  name='remarks_$ctr'  value='' ></td>";
    Echo "</tr>";
    $ctr++;
} else {
    echo "ERROR";
}
?>
 