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

$formname = 'Feedback Data';
$maindb = 'feedback';
$printfile = "";
$file = 'savefeed.php';
$trandbexist = 0;
$grid = '';
$keyfld = "vouchno";
$keycond = " ";
$focusfield = "name";
$mgrpcode = '009';

$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn,$zdb);
//browse($zdb);
if (isset($_GET["submit"])) {

    $a = 1;
    $vouch = $_GET["vouchno"];
    $trip = $_GET["trip"];
    $service1 = $_GET["service1"];
    $hotel1 = $_GET["hotel1"];
    $service2 = $_GET["service2"];
    $hotel2 = $_GET["hotel2"];
    $service3 = $_GET["service3"];
    $hotel3 = $_GET["hotel3"];
    $service4 = $_GET["service4"];
    $hotel4 = $_GET["hotel4"];
    $service5 = $_GET["service5"];
    $hotel5 = $_GET["hotel5"];
    $offers = $_GET["offers"];
    $date = $_GET["date"];
    $destination = $_GET["destination"];
    $comments = $_GET["comments"];
    $address = $_GET["address"];
    $travel = $_GET["travel"];
//    $username = $_POST["username"];
//    $username = $_SESSION["username_" . $dbname];
//    browse($vouch);
    $getquery = mysqli_query($conn,"Select * from `feedback` where vouchno='$vouch'") or die(mysqli_error($conn));
    $quetot = mysqli_num_rows($getquery);

//    if ($a == 1) {

    if ($quetot > 0) {

        mysqli_query($conn,"UPDATE `$maindb`  SET `trip`='$trip', `service1`='$service1',  `hotel1`='$hotel1', `service2`='$service2', `hotel2`='$hotel2',
                                                `service3`='$service3',  `hotel3`='$hotel3', `service4`='$service4',  `hotel4`='$hotel4', `service5`='$service5',
                                                `hotel5`='$hotel5', `offers`='$offers', `comments`='$comments',`date`='$date', `address`='$address', `travel`='$travel' where vouchno = '$vouch' ") or die(mysqli_error($conn));

        mysqli_query($conn,"UPDATE `confmain`  SET `feedrecd`='Y'  where vouchno = '$vouch' ") or die(mysqli_error($conn));
//        header("refresh: 1; $file?$keyfld=$mvouch&mode=edit");
//            header("refresh: 1; $file?mode=true");
    } else {

        mysqli_query($conn,"INSERT INTO `$maindb`(vouchno, `trip`, `service1`, `hotel1`, `service2`, `hotel2`, `service3`, `hotel3`, `service4`, 
                                               `hotel4`, `service5`, `hotel5`, `offers`, `comments`,`address`, `date`,`travel` )
                                        VALUES('$vouch', '$trip', '$service1', '$hotel1', '$service2', '$hotel2', '$service3', '$hotel3', '$service4',
                                               '$hotel4', '$service5', '$hotel5', '$offers', '$comments', '$address','$date','$travel')") or die(mysqli_error($conn));

        mysqli_query($conn,"UPDATE `confmain`  SET `feedrecd`='Y'  where vouchno = '$vouch' ") or die(mysqli_error($conn));
//            header("refresh: 1; $file?$keyfld=$mvouch&mode=edit");
        

//            updmess();
//            header("refresh: 1; $grid");
    }
    echo "<script>
            window.close();
            </script>";
}
//}
?>

</head>
<body>
    <form action='' method='POST'>
        <!-- Default box -->
    </form>
</body>
</html>
