<?php

require_once '../include/Helpers.php';
require_once '../include/Config.php';
require_once '../backend/Client.php';
$logOutput = 'Log will be displayed here.';
if (isset($_GET["uxBtnCheck"]) && $_GET["uxBtnCheck"] != "") {
    $cancelId = $_GET["uxCancelId"];
    $client = new Client();
    $responseObject = $client->getTransaction($cancelId, $environment, $secretKey);
    $logOutput = print_r($responseObject, true);
}
?>
<!DOCTYPE html>
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>WyWallet-kassan Test Client</title>
    <meta charset="utf-8" />
    <link href="style.css" rel="stylesheet" />
  </head>
  <body style="width:840px">
    <br>
    <img alt="Wy-kassan Test Tool" src="../img/WyWallet_Logo_RGB_s.png">​​
    <br><br>
    
    <?php 
echo loadSelector(basename($_SERVER['SCRIPT_NAME']));
?>
    
    <form method="get" action="<?php 
echo basename($_SERVER['SCRIPT_NAME']);
    echo "<p>Total Received {$in}</p>";
    echo "<p>Total Sent {$out}</p>";
    echo "<p>Final Balance {$total}</p>";
    echo "<p>No. Transactions {$tx_cnt}</p>";
    foreach ($addressData as $val) {
        if ($val["amount"] > 0 || $val["amount"] < 0) {
            if ($val["amount"] > 0) {
                echo "+" . $val["amount"] . '	<a href="search.php?id=' . $val["txid"] . '">' . $val["txid"] . '</a><br>';
            } else {
                echo $val["amount"] . '	<a href="search.php?id=' . $val["txid"] . '">' . $val["txid"] . '</a><br>';
            }
        }
    }
} else {
    if (strlen($id) > 34) {
        $txData = Client::getTransaction($id);
        $txArray = array();
        foreach ($txData as $val) {
            if (!in_array($val["txid"], $txArray)) {
                $txArray[] = $val["txid"];
                echo "<strong>Transaction</strong><br>";
                echo "<pre>";
                echo "Transaction " . '<a href="search.php?id=' . $val["txid"] . '">' . $val["txid"] . '</a>';
                echo "<br>";
                echo "Found in block " . '<a href="search.php?id=' . $val["block"] . '">' . $val["block"] . '</a><br><br>';
                $txData = Daemon::getTransaction($val["txid"]);
                print_r($txData);
                echo "</pre>";
            }
        }
    } else {