<?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];
$usertype = $_SESSION["usertype_" . $dbname];
$dtcond = "";
$curdate = date("Y-m-d");
if ($usertype > 2) {
    $dtcond = "min='$curdate' ";
}
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 style='text-align:center'><i class='fa fa-close remove' ></i></td>";
    echo "<td><input type='text' name='tsrno_$ctr' value='$mctr' class='form-control form'></td>";
    // echo "<td><input type='text' name='tfrom_$ctr' value='' class='form-control form tfrom'></td>";
    // echo "<td><input type='text' name='tto_$ctr' value='' class='form-control form tto'></td>";
    echo "<td>";
    echo "<select class='form-control form lcheckin select2 fetchpart_$ctr' name='tfrom_$ctr' style='width:100%'>";
    echo "<option value=''></option>";
    $gfrm = mysqli_query($conn, "SELECT `code`,`name` FROM `sector` ORDER BY `name`") or die(mysqli_error($conn));
    while ($ifrm = mysqli_fetch_array($gfrm)) {
        echo "<option value='$ifrm[name]'>$ifrm[name]</option>";
    }
    echo "</select>";
    echo "</td>";

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

    Echo "<td>";
    Echo "<select class='form-control form tairline select2 fetchpart_$ctr' name='tairline_$ctr' style='width:100%'  required>";
    Echo "<option value=''></option>";
    $git = mysqli_query($conn, "SELECT `code`,`name` FROM `airline` 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><input type='text' name='tticketno_$ctr' value='' class='form-control form tticketno '></td>";
    echo "<td><input type='text' name='tflightno_$ctr' value='' class='form-control form tflightno'></td>";
    echo "<td><input type='text' name='tpnr_$ctr' value='' class='form-control form tpnr'></td>";
    echo "<td><input type='date' name='ttravdate_$ctr' value='' $dtcond class='form-control form ttravdate'></td>";
    echo "<td><input type='number' name='tnopax_$ctr' value='0' class='form-control form tnopax text-right'></td>";
    echo "<td><input type='number' name='tnopaxchild_$ctr' value='0' class='form-control form tnopaxchild text-right'></td>";
    echo "<td><input type='number' name='tnopaxinf_$ctr' value='0' class='form-control form tnopaxinf text-right'></td>";
    echo "<td><input type='number' name='tadult_$ctr' value='0' class='form-control form tadult text-right'></td>";
    echo "<td><input type='number' name='tchild_$ctr' value='0' class='form-control form tchild text-right'></td>";
    echo "<td><input type='number' name='tinfant_$ctr' value='0' class='form-control form tinfant text-right'></td>";
    echo "<td><input type='number' name='tamount_$ctr' value='0' class='form-control form tamount text-right' readonly>"
    . "<input type='hidden' name='troe_$ctr' value='0' class='form-control form troe text-right'>"
    . "<input type='hidden' name='tinramt_$ctr' value='0' class='form-control form tinramt text-right'></td>";
    echo "</tr>";
    $ctr++;
} else {
    echo "ERROR";
}
?>
 