<?php require_once 'includes/main.php'; logged_in('user_id'); ?>
<?php require_once 'elements/head.php'; ?>
<?php 

$id = (int)$_GET['id'];

$sql = "SELECT * FROM listings WHERE id = '{$id}' LIMIT 1";
if(fetch_rows($sql) < 1){

   $_SESSION['messages'][] = "Listing could not be found";
   header("Location: ".URL);
   exit;

}else{

   $x = fetch_records($sql);

}

?>

<!-- META: TITLE -->
<title><?php echo $set['points_title']; ?> - <?php echo $set['website_name']; ?></title>

</head>

<body>

<?php include_once 'elements/header.php'; ?>

<?php include_once 'elements/sidebar/dashboard.php'; ?>

<!-- CONTENT -->
<section class="Content R">

   <h2 class="GLOB-Title"><?php echo $x['name']; ?>: <span class="FR"><?php echo comma_number($x['points']); ?> Points</span></h2>

   <!-- FORM -->
   <form class="Form" onsubmit="exForm(event, this, 'ex/add.points.php')" method="POST">

      <!-- ID -->
      <input type="hidden" class="H" name="id" value="<?php echo $id; ?>">

      <!-- TEXTFIELD: TEXT -->
      <!-- TEXTFIELD: DISABLED -->
      <div class="field">
         <div class="icon"><img src="images/icons/points.png" width="100%" height="100%"></div>
         <input type="text" name="left" class="textfield short" maxlength="10" id="left" placeholder="Left" value="<?php echo $x['points']; ?>" disabled>
      </div>

      <!-- TEXTFIELD: TEXT -->
      <!-- TEXTFIELD: DISABLED -->
      <div class="field">
         <div class="icon"><img src="images/icons/points.png" width="100%" height="100%"></div>
         <input type="text" name="balance" class="textfield short" maxlength="10" id="balance" placeholder="Balance" value="<?php echo $u['points']; ?>" disabled>
      </div>

      <!-- TEXTFIELD: TEXT -->
      <div class="field">
         <div class="icon"><img src="images/icons/points.png" width="100%" height="100%"></div>
         <input type="text" name="add" class="textfield short" maxlength="10" id="add" placeholder="Add" onkeyup="addPoints(this);" value="">
      </div>

      <!-- TEXTFIELD: TEXT -->
      <!-- TEXTFIELD: DISABLED -->
      <div class="field">
         <div class="icon"><img src="images/icons/points.png" width="100%" height="100%"></div>
         <input type="text" name="updated" class="textfield short" maxlength="10" id="updated" placeholder="Updated" value="" disabled>
      </div>

      <div class="ERRORS"></div>

      <!-- SUBMIT -->
      <div class="submit">
         <input type="submit" value="Add Points">
      </div>
      <!-- SUBMIT -->

   </form>
   <!-- FORM -->

</section>
<!-- CONTENT -->

<?php include_once 'elements/footer.php'; ?>

</body>
</html>
