<?php

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

$formname = 'Visa Update ';
$maindb = 'pax';
$file = 'visaupd.php';
$zdb = $_SESSION["zdbyear_" . $dbname];
$series = $_SESSION["society_" . $dbname];
mysqli_select_db($conn,$zdb);

$siscon = mysqli_real_escape_string($conn,$_GET["siscon"]);
$dcode = mysqli_real_escape_string($conn,$_GET["code"]);
$colorcode = "#FF8C00";

$stype = mysqli_real_escape_string($conn,$_GET["stype"]);

$sterm = mysqli_real_escape_string($conn,$_GET["sterm"]);

$termcond = '';
$dcodecond = '';
$cond = '';
if (!empty($sterm)) {
    if ($stype == 1) {
        $termcond = " AND paxid LIKE '%$sterm%'";
    } elseif($stype == 2) {
        $termcond = " AND surname LIKE '%$sterm%'";
    } 
     elseif($stype == 3) {
        $termcond = " AND hajino LIKE '%$sterm%'";
    } 
     elseif($stype == 4) {
        $termcond = " AND visano LIKE '%$sterm%'";
    } 
//    elseif($stype == 3){
//        $termcond = " and wing = '%$sterm%'";
//    }
}
if (!empty($dcode)) {
    if ($dcode == 1) {
        $dcodecond = "order by `paxid`";
    } elseif($dcode == 2) {
        $dcodecond = "order by `surname`";
    } 
//    elseif($stype == 3){
//        $termcond = " and wing = '%$sterm%'";
//    }
}
if (!empty($siscon)) {
        $sisconcond = "AND `company`='$siscon' ";
}

//print $dcode;
//if (!empty($dcode) || $dcode != '') {
//    $result = mysqli_query($conn,"SELECT * FROM `p` WHERE `grpcode`!='011' and `grpcode`!='012' and
//                         `series` = '$series' $termcond $cond ORDER BY name") or die(mysqli_error($conn));
    $result = mysqli_query($conn,"SELECT * FROM `pax` where paxid !=''  $termcond $sisconcond  order by hajino ") or die(mysqli_error($conn));
    $flag = "";
//}

$ctr = 0;
echo "<br>";


echo '<table id="openbal" class="table table-bordered table-responsive " border="" width="100%" height="auto" style="" align="center">';
echo "<tr style='background-color: #6082BF'>";
echo "<th><label class='control-label right'>Pax Id</label></th>";
echo "<th><label class='control-label right'>Haji No.</label></th>";
echo "<th><label class='control-label right'>Name</label></th>";
echo "<th><label class='control-label right'>Visa No</label></th>";
echo "<th align='right'><label class='control-label right'>Application No</label></th>";
echo "<th align='right'><label class='control-label right'>Passport No</label></th>";
echo "<th align='right'><label class='control-label right'>Issue Place</label></th>";
echo '</tr>';
while ($row = mysqli_fetch_array($result)) {
    $name= $row['surname']." ".$row['name']." ".$row['midname'];
//    $dc = $row[dc];
//    $grpcode = $row['grpcode'];
//
//    if ($grpcode == '010') {
//        $read = 'readonly';
//    } else {
//        $read = '';
//    }
    echo "<tr>";
    echo '<td align="center" style="width: 5%">
             <input type="text" size="30"  maxlength="4"  name="paxid_' . $ctr . '"  value="' . $row["paxid"] . '" class="acname form-control " readonly/></td>';
    echo '<td align="center" style="width: 5%">
             <input type="text" size="30"  maxlength="4"  name="hajino_' . $ctr . '"  value="' . $row["hajino"] . '" class="acname form-control " readonly/></td>';
    echo '<td align="center" style="width: 30%">
         <input type="text" size="4" maxlength="6" style="text-align: left;" name="name_' . $ctr . '" value="' . $name . '" class="init form-control right"  readonly/></td>';
   
    echo '<td align="left" style="width: 10%">
    <input type="text" size="4"   name="visano_' . $ctr . '" value="' . $row["visano"] . '" class="visano form-control right" style="text-align:left; padding-left: 5px;"/></td>';
    echo '<td align="left" style="width: 10%">
    <input type="text" size="4"   name="mofa_' . $ctr . '" value="' . $row["mofa"] . '" class="mofa form-control right" style="text-align:left; padding-left: 5px;"/></td>';
    echo '<td align="left" style="width: 10%">
    <input type="text" size="4"   name="passportno_' . $ctr . '" value="' . $row["passportno"] . '" class="passportno form-control right" style="text-align:left; padding-left: 5px;"/></td>';
    echo '<td align="left" style="width: 10%">
    <input type="text" size="4"   name="visaisspl_' . $ctr . '" value="' . $row["visaisspl"] . '" class="visaisspl form-control right" style="text-align:left; padding-left: 5px;"/></td>';

    echo '</tr>';
    $ctr++;
}

echo "<input type='hidden' name='count' value='$ctr'>";
echo "</table>";
?>