<?php 
error_reporting(0); 
session_start();
if(isset($_SESSION['SESS_ADMINLOGGEDIN']) == FALSE) {
    header("Location: " . $config_basedir."adminlogin.php");
}
require("config.php");
require("db.php");
require("functions.php");
require("aheader.php");
?>

<?php


$validid = pf_validate_number($_GET['id'], "redirect", $config_basedir . "adminorders.php");
echo '<hr><div class="container" align="center" style="margin-top:20px;">


        <h3>User Details</h3>';

echo "<a href='adminverify.php'><-- go back to the main screen</a>";

$ordsql = "SELECT * from logins WHERE id = " . $validid; 
$ordres = mysql_query($ordsql);
$ordrow = mysql_fetch_assoc($ordres);

echo "<table cellpadding=10>";
echo "<tr><td><strong>Member Id</strong></td><td>" . $ordrow['id'] . "</td></tr>";
echo "<tr>";
echo "<td><strong>Address</strong></td>";
echo "<td>" . $ordrow['firstname'] . " " . $ordrow['lastname'] . "<br>";
echo $ordrow['country'] . "<br>";
echo $ordrow['state'] . "<br>";
echo $ordrow['city'] . "<br>";
echo $ordrow['currency'] . "<br>";

echo "</td></tr>";
echo "<tr><td><strong>Fullname </strong></td><td>"  . $ordrow['firstname'] . " " . $ordrow['lastname'] .  "</td></tr>";
echo "<tr><td><strong>Phone</strong></td><td>" . $ordrow['phone'] . "</td></tr>";
echo "<tr><td><strong>Email</strong></td><td><a href='mailto:" . $ordrow['email'] . "'>" . $ordrow['email'] . "</a></td></tr>";
echo "<tr><td><strong>Verified</strong></td><td>" . $ordrow['verified'] . "</td></tr>";
echo "<tr><td><strong>Balance</strong></td><td>" . $ordrow['balance'] . "</td></tr>";
echo "</table>";

$seller=$ordrow['id'];
$usersql = mysql_query("SELECT * FROM logins WHERE id=$seller");
while($userrow = mysql_fetch_assoc($usersql))
{
    if(empty($userrow['id'])) {
        echo "<div align='center'><img src='./productimages/dummy.jpg' alt='" . $userrow['username'] . "' onerror='imgError(this);'></div>";
    }
    else {
        echo "<br><br><strong>FrontImage</strong><div align='center'><img src='./productimages/" . $userrow['id'] . "front.jpg'class='prodimg' alt='" . $userrow['username'] . "'></div>";
        echo "<br><br><strong>BackImage</strong><div align='center'><img src='./productimages/" . $userrow['id'] . "back.jpg'class='prodimg' alt='" . $userrow['username'] . "'></div>";
    }
}

if (isset($_POST['details'])) {

    $ver = mysql_real_escape_string($_POST['details']);
    $sql = mysql_query("UPDATE logins SET balance=$ver WHERE id='$seller'") or die (mysql_error());
    $success="<div class='success' style='margin-bottom:50px;'><img src='images2/download.png'>Balance Set Successfully</div>";
}if (isset($_POST['message'])) {

    $ver1 = mysql_real_escape_string($_POST['subject']);
    $ver2 = mysql_real_escape_string($_POST['message']);
    $addresssql = mysql_query("INSERT INTO `message` (`log_id`, `subject`, `message`,`date`) VALUES ('$seller','$ver1','$ver2',now())");
    $success="<div class='success' style='margin-bottom:50px;'><img src='images2/download.png'>Message Sent</div>";
}
echo "";
?>
<?php echo $success?>
<form action="" enctype="multipart/form-data" name="myForm" id="myform" method="post" ><div class="container" align="center">
    <div class="col-md-5" align="right"><label for="details" style="margin-top:12px;">Set Balance :</label></div><div class="col-md-7" align="left">
    <input type="number" name="details" id="details" min="1"/>
    </div></div><div clas="container" align="center"><div class="col span-3-of-3"><label>
    <input type="submit" name="button" id="btn-mlogin" value="Set" />
    </label></div></div>
</form><form action="" enctype="multipart/form-data" name="myForm" id="myform" method="post" ><div class="container" align="center">
<div class="col-md-5" align="right"><label for="details" style="margin-top:12px;">Subject :</label></div><div class="col-md-7" align="left">
<input type="text" name="subject" id="details" min="1"/>
</div></div><div class="container" align="center">
    <div class="col-md-5" align="right"><label for="details" style="margin-top:12px;">Message :</label></div><div class="col-md-7" align="left">
<textarea name="message" id="details" cols="64" rows="5" min="10"></textarea>
    </div></div><div clas="container" align="center"><div class="col span-3-of-3"><label>
    <input type="submit" name="button" id="btn-mlogin" value="Message" />
    </label></div></div>
</form>
</div></div>
<?php
require ("footer.php");
?>