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

$zdb = $_SESSION["zdbyear_$dbname"];
mysqli_select_db($conn, $zdb);

if ($_REQUEST["code"]){
    $code = $_REQUEST["code"];
   

    if ($_REQUEST["para"] == "destination") 
    {
     $getvess = mysqli_query($conn, "SELECT `country` FROM `cargmain` WHERE vouchno = '$code'")or die(mysqli_error($conn));
     $mves = mysqli_fetch_array($getvess);
     $destcode = $mves['country'];
     
     $getvessel = mysqli_query($conn, "SELECT `name` FROM `country` WHERE code = '$destcode'")or die(mysqli_error($conn));
     $mdes = mysqli_fetch_array($getvessel);
     echo $mdes["name"];
    }

    if ($_REQUEST["para"] == "partylist") 
    {
     $getpart = mysqli_query($conn, "SELECT `partylist` FROM `cargmain` WHERE vouchno = '$code'")or die(mysqli_error($conn));
     $mpart = mysqli_fetch_array($getpart);
     echo $mpart["partylist"];
    }

    
    if ($_REQUEST["para"] == "namecargo") 
    {
     $getcarg = mysqli_query($conn, "SELECT `namecargo` FROM `cargmain` WHERE vouchno = '$code'")or die(mysqli_error($conn));
     $mcarg = mysqli_fetch_array($getcarg);
     echo $mcarg["namecargo"];
    }

    if ($_REQUEST["para"] == "exporter") 
    {
     $getexp = mysqli_query($conn, "SELECT `exporter` FROM `cargmain` WHERE vouchno = '$code'")or die(mysqli_error($conn));
     $mexp = mysqli_fetch_array($getexp);
     $expcode = $mexp['exporter'];
     
     $getname = mysqli_query($conn, "SELECT `name` FROM `exporter` WHERE code = '$expcode'")or die(mysqli_error($conn));
     $ename = mysqli_fetch_array($getname);
     echo $ename["name"];
    }

    if ($_REQUEST["para"] == "exportinv") 
    {
     $getexp1 = mysqli_query($conn, "SELECT `packlistno` FROM `cargmain` WHERE vouchno = '$code'")or die(mysqli_error($conn));
     $mexp1 = mysqli_fetch_array($getexp1);
     $expno = $mexp1["packlistno"];
     echo $expno;
    }
    
}
else {
    echo "ERROR";
}?>
