<!DOCTYPE HTML>
<html> 
<head>

<style> 

.header {
  padding: 30px;
  text-align: center;
  color: white;
  font-size: 30px;
}


/* Style inputs with type="text", select elements and textareas */
input[type=text], select, textarea {
  width: 100%; /* Full width */
  padding: 12px; /* Some padding */ 
  border: 1px solid #ccc; /* Gray border */
  border-radius: 4px; /* Rounded borders */
  box-sizing: border-box; /* Make sure that padding and width stays in place */
  margin-top: 6px; /* Add a top margin */
  margin-bottom: 16px; /* Bottom margin */
  resize: vertical /* Allow the user to vertically resize the textarea (not horizontally) */
}

/* Style the submit button with a specific background color etc */
input[type=submit] {
  background-color: #4CAF50;
  color: white;
  padding: 12px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

/* When moving the mouse over the submit button, add a darker green color */
input[type=submit]:hover {
  background-color: #45a049;
}

/* Add a background color and some padding around the form */
.container {
  border-radius: 5px;
  background-color: #f2f2f2;
  padding: 20px;
}
</style>


</head>


<body > 

<?php
$q = $_GET['q']; 
require('config.php');
$linkID = new PDO('mysql:host='.Config::DB_HOST.';dbname='.Config::DB_NAME, Config::DB_USERNAME, Config::DB_PASSWORD);
$linkID->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Setting ERRMODE
$result = $linkID->query("SELECT id, name FROM ea_services")->fetchAll(PDO::FETCH_ASSOC);
if($q !== ''){
    $result1 = $linkID->query("SELECT * FROM waitlist WHERE hash="."'".$q."'")->fetchAll(PDO::FETCH_ASSOC);
    foreach($result1 as $m){
        

?>
<div class="header" style="background:<?= Config::FRONTEND_COLOR; ?>" >
<span><img src="amjaylogo1.png"><h2 style="color:white; font-family:san-serif;">Waitlist - EDIT RECORD</h2></span>
</div>

<form action="waitlisteditprocess.php" method="post">
    
<div id="container" style="padding-left: 13px; font-family:san-serif;" ><br>

<label for="waitlist-service" style="color:red">Service: **PICK A SERVICE</label>

<select id="waitlist-service" name="waitlist-service">
    
<?php
foreach($result as $r){
    $bro =' '; 
    if($r['id'] == $m['service']){
        $bro = 'selected'; 
    }else{
            $bro =' '; 
    }
echo '<option value='.'"'.$r['id'].'"'.' '.$bro.'>'.$r['name'].'</option>';  
}

echo '</select>';
?>


<br>
<input type="hidden" id="waitlistid" name="waitlistid" value="<?= $m['id'] ?>"> 
<input type="hidden" id="waitlisthash" name="waitlisthash" value="<?= $m['hash'] ?>"> 

<label for="waitlist-firstname">First Name*</label>
<input type="text" id="waitlist-firstname" name="waitlist-firstname" value="<?= $m['firstname'] ?>" required><br>

<label for="waitlist-lastname">Last Name*</label>
<input type="text" id="waitlist-lastname" name="waitlist-lastname" value="<?= $m['lastname'] ?>" required> <br>

<label for="waitlist-phonenumber">Phone Number*</label>
<input type="text" id="waitlist-phonenumber" name="waitlist-phonenumber" value="<?= $m['phonenumber'] ?>" required> <br>

<label for="waitlist-email">Email*</label>
<input type="text" id="waitlist-email" name="waitlist-email" value="<?= $m['email'] ?>" required> <br>

    <label for="waitlist-birthdate">Birthdate*</label>
    <input type="text" id="waitlist-birthdate" name="waitlist-birthdate" value="<?= $m['birthdate'] ?>" required> <br>

    <label for="waitlist-notes">Notes</label>
<textarea id="waitlist-notes" name="waitlist-notes" ><?= $m['notes'] ?></textarea><br>

<label for="waitlist-pharmacy-notes">Pharmacy Notes</label>
<textarea id="waitlist-pharmacy-notes" name="waitlist-pharmacy-notes" ><?= $m['pharmacynotes'] ?></textarea><br>

<input type="submit" value="Submit" name="EDIT">
 </div>

</form>
<?php
    }
}
?>
</body>
</html>