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

$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$myyear = $_SESSION[$myyear];
mysqli_select_db($conn, $zdb);
$zroot = $_SESSION["zdbroot"];

$formname = 'Visa Register';
$file = 'visa_print_fr.php';

$country = $_POST["country"];

$countrycond ="";

if (!empty($country)) {
    $countrycond = " AND `country`= '$country'";
}

$getpmain = mysqli_query($conn, "SELECT * FROM `visamain` WHERE code !='' $countrycond ")or die(mysqli_error($conn));
          
$getno = mysqli_num_rows($getpmain);

if (isset($_POST["view"]) || ($_GET["view"])) {


    include("includes/linkshead.php");
    ?>
    <style type="text/css">
        #tabital{
            font-style: italic;
        }
        #font1{
            font-style: italic;
        }
        #boldfont{
            font-weight: bold; 
        }


    </style>
    </head>
    <body>


        <div class="container-fluid">
            <?php
            include("includes/head_rep2.php");

                ?>
                <div class="row">
                    <div class="col-lg-12 pad">
           
                        <table style="background: white;width: 60%" class="table table-condensed table-striped table-hover table-bordered">
                            
                            <tbody>
                                <?php
                                $ctr = 0;

                                while ($pmain = mysqli_fetch_array($getpmain)) {


                                    $code = $pmain['code'];
                                    $country = $pmain['country'];

                                    $ctr++;
                                    // Echo"<tr data-href='purchase.php?mode=edit&vouchno=$voucher' class='clickable-row2' [target]='_blank'>";
                                    Echo"<tr data-href='visa.php?mode=edit&code=$code' class='clickable-row2' [target]='_blank'>";
                                    Echo"<td style='font-size:14px;font-weight:bold'>Country :&nbsp;  $country</td>";
                                    Echo"</tr>";



                                        Echo "<tr style='height:10px;'>";
                                        Echo "<td colspan='25'>";
                                        Echo "<table style='width:100%;' class='table table-condensed table-hover table-bordered'>";
                                        Echo "<thead class='mySearchTr'>";
                                        Echo "<tr>";
                                        Echo "<th style='width:2%;'>Sr</th>";
                                        Echo "<th style='width:10%;'>From</th>";
                                        Echo "<th style='width:10%;'>To</th>";
                                        Echo "<th style='width:10%;' class='text-right'>B2C Rate</th>";
                                        Echo "<th style='width:10%;' class='text-right'>B2B Rate</th>";
                                        Echo "</tr>";
                                        Echo "<thead>";
                                        Echo "<tr>";


                                        $ctr2 = 0;
                                        $pctr2 = 0;
                              

                                        $gettran = mysqli_query($conn, "SELECT *,DATE_FORMAT(`visafrom`, '%d-%m-%Y')AS visafrom,
                                                                        DATE_FORMAT(`visafrom`, '%d-%m-%Y')AS visafrom
                                                                        FROM `visatran` WHERE `code`='$pmain[code]' order by srno") or die(mysqli_error($conn));
                                        while ($tran = mysqli_fetch_array($gettran)) {

                                            $ctr2++;
                                            Echo "<tr>";
                                            Echo "<td>$ctr2</td>";
                                            Echo "<td >$tran[visafrom]</td>";
                                            Echo "<td>$tran[visato]</td>";
                                            Echo "<td class='text-right'>$tran[b2crate]</td>";
                                            Echo "<td class='text-right'>$tran[b2brate]</td>";
                                            Echo "</tr>";

                                        }

                                        Echo "</table>";
                                    
                                }

                            
                                ?>
                            </tbody>
                        </table>
                    </div> 
                </div>

                <?php
            }
            ?>
        </div>
        <?php include("includes/linksfoot.php");
        ?>
    </body>
    </html>
