<?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>";
    echo "<td><i class='fa fa-close remove' style=''></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 city select2 fetchpart_$ctr' name='city_$ctr' style='width:100%'  required>";
    echo "<option value='$tran[city]'>$trtype[name]</option>";
    $getcity = mysqli_query($conn, "SELECT `code`,`name` FROM `city` WHERE code = '2' OR code = '3' ORDER BY `name` DESC") or die(mysqli_error($conn));
    while ($fetcity = mysqli_fetch_array($getcity)) {
        echo "<option value='$fetcity[code]'>$fetcity[name]</option>";
    }
    echo "<option value='99'>OTHER</option>";
    echo "</select>";
    echo "</td>";

    echo "<td>";
    echo "<select class='form-control form hotelnm select2 fetchpart_$ctr' name='hotelnm_$ctr' style='width:100%'  required>";
    echo "<option value='$tran[code]'>$trtype[hotelnm]</option>";
    $gethotel = mysqli_query($conn, "SELECT `code`,`hotelnm` FROM `hotels` ORDER BY `hotelnm`") or die(mysqli_error($conn));
    while ($fethotel = mysqli_fetch_array($gethotel)) {
        echo "<option value='$fethotel[code]'>$fethotel[hotelnm]</option>";
    }
    echo "</select>";
    echo "</td>";

    echo "<td><input type='date' class='form-control form checkin' name='checkin_$ctr' value='$tran[checkin]'></td>";
    echo "<td><input type='date' class='form-control form checkout' name='checkout_$ctr' value='$tran[checkout]'></td>";

    echo "<td><input type='text' class='form-control form roomtype' name='roomtype_$ctr' value='$tran[roomtype]'></td>";
    echo "<td><input type='number' class='text-right form-control form roomsno' name='roomsno_$ctr' value='$tran[roomsno]'></td>";
    echo "<td><input type='number' class='text-right form-control form nonights' name='nonights_$ctr' value='$tran[nonights]'></td>";
    echo "<td><input type='text' class='form-control form mealplan' name='mealplan_$ctr' value='$tran[mealplan]'></td>";

    echo "</tr>";
    $ctr++;
} else {
    echo "ERROR";
}
?>