<?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 style='text-align:center'><i class='fa fa-close remove' ></i></td>";
    echo "<td><input type='text' name='rsrno_$ctr' value='$mctr' class='form-control form'></td>";
    echo "<td>";
    echo "<select class='form-control form picktype fetchpart_$ctr select2' name='picktype_$ctr' style='width:100%'  >";
    echo "<option value=''></option>";
    echo "<option value='A'>Arrival</option>";
    echo "<option value='I'>Internal</option>";
    echo "<option value='D'>Departure</option>";

    echo "</select>";
    echo "</td>";
    Echo "<td>";
    echo "<input list='rfrom' name='rfrom_$ctr' class='rfrom form-control form ' autocomplete='off' value=''> ";
    echo "<datalist id='rfrom' char='#'>";
    echo"<option>";

    $msi = mysqli_query($conn, "SELECT `fromplace` FROM `transent` group by fromplace") or die(mysqli_error($conn));

    while ($tsi = mysqli_fetch_array($msi)) {
        $szname = $tsi['fromplace'];
        echo "<option value='$szname'>";
    }
    echo "</datalist>";
    echo "</td>";
    echo "<td>";
    echo "<input list='rto' name='rto_$ctr' class='rto form-control form ' autocomplete='off' value=''> ";
    echo "<datalist id='rto' char='#'>";
    echo"<option>";

    $msi2 = mysqli_query($conn, "SELECT `toplace` FROM `transent` group by toplace") or die(mysqli_error($conn));

    while ($tsi2 = mysqli_fetch_array($msi2)) {
        $szname2 = $tsi2['toplace'];
        echo "<option value='$szname2'>";
    }
    echo "</datalist>";
    echo "</td>";
    echo "<td><input type='datetime-local' name='rpickuptime_$ctr' value='' class='form-control form rpickuptime'></td>";
    Echo "<td>";
    Echo "<select class='form-control form rvehicle select2 fetchpart_$ctr'  name='rvehicle_$ctr' style='width:100%'  required>";
    Echo "<option value=''></option>";
    $git = mysqli_query($conn, "SELECT `code`,`vehtype` FROM `vehicle` ORDER BY `vehtype`")or die(mysqli_error($conn));
    while ($itm = mysqli_fetch_array($git)) {
        Echo "<option value='$itm[code]'>$itm[vehtype]</option>";
    }
    Echo "</select>";
    Echo "</td>";
    echo "<td><input type='number' name='rnopax_$ctr' value='0' class='form-control form rnopax text-right'></td>";
    echo "<td><input type='number' name='rnoveh_$ctr' value='0' class='form-control form rnoveh text-right'></td>";
    echo "<td><input type='number' name='rrate_$ctr' value='0' class='form-control form rrate text-right'></td>";
    echo "<td><input type='number' name='ramount_$ctr' value='0' class='form-control form ramount text-right' readonly>"
    . "<input type='hidden' name='rroe_$ctr' value='0' class='form-control form rroe text-right'>"
    . "<input type='hidden' name='rinramt_$ctr' value='0' class='form-control form rinramt text-right'></td>";
    echo "<td><input type='text' name='rcnfno_$ctr' value='' class='form-control form rcnfno'></td>";
    echo "<td><input type='text' name='rdescrip_$ctr' value='' class='form-control form rdescrip'></td>";

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