<?php

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

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

$mofano = trim($_REQUEST["mofano"]);
$myvouch = $_REQUEST["myvouch"];

$m = 0 ;

$getbroker = mysqli_query($conn, "SELECT `myvouch`,DATE_FORMAT(`vouchdt`, '%d-%m-%Y') as vouchdt,`passport` FROM `visatran` WHERE mofano = '$mofano' and myvouch != '$myvouch' ") or die(mysqli_error($conn));
if (mysqli_num_rows($getbroker) > 0) {
    $fetbrok = mysqli_fetch_array($getbroker) ;
    $m = 1 ;
} else {
    
   $getbroker1 = mysqli_query($conn, "SELECT `myvouch`,DATE_FORMAT(`vouchdt`, '%d-%m-%Y') as vouchdt, `passport` FROM `visatran` WHERE mofano2 = '$mofano' and myvouch != '$myvouch' ") or die(mysqli_error($conn));
   if (mysqli_num_rows($getbroker1) > 0) {
       $fetbrok = mysqli_fetch_array($getbroker1) ;
       $m = 1 ;
   } 
}
if ($m == 1) {
         $success = true;
         $rows = array('success' => $success,       
            'vouchdt' => $fetbrok['vouchdt'],
            'myvouch' => $fetbrok['myvouch'],
            'passport' => $fetbrok['passport'],
             );
         header("Content-type: application\json"); 
echo json_encode($rows);
 
}

?>