<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="guestprofile.css">
</head>
<body>
<!-- guesttemplate server connection -->

<?php

require 'database.php';

// echo "Haha.. Connected successfully";
//check if numeric to avoid sql injection
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
$sql = "SELECT *
FROM guest
WHERE GuestID = " . $_GET['id'];



$results = mysqli_query($conn, $sql);

if ($results === false) {
  // code...
  echo mysqli_error($conn);
} else {
  // code...
  $viewGuests= mysqli_fetch_assoc($results);



}
} else {
  $viewGuests = null;
}
 ?>


       <?php if ($viewGuests === null):?>
         <p>Article no found</p>
       <?php else: ?>
       <!-- <ul>


           <article class="">
             <h2><?= $article['title']; ?></h2>
             <p><?= $article['content']; ?></p>

           </article>


       </ul> -->
     
     



<!-- END of guesttemplate server connection -->




    <div class="guestprofile">
    <div class="qaContainer" style="width:600px;">
        <div class="guestinfo">
        <h2>First Name: <?= $viewGuests['GuestFirstName']; ?></h2>
        <h2>Last Name: <?= $viewGuests['GuestLastName']; ?></h2>
        <h2>Enrolled Date: <?= $viewGuests['GuestDate']; ?></h2>
        
        <?php endif; ?>
               
               
            </div>
        <div class="leftContainer" style="float:left;">
            
           <div> <a href="javascript:" onClick="showDiv('1');"><button style="width:100%">send email</button> </a></div> <br>
            <div><a href="javascript:" onClick="showDiv('2');"><button style="width:100%">Send Text Message</button></a></div><br />
            <div><a href="javascript:" onClick="showDiv('3');"><button style="width:100%">record</button></a></div><br />
            <div><a href="javascript:" onClick="showDiv('4');"><button style="width:100%">call</button></a></div><br />
            <div><a href="javascript:" onClick="showDiv('5');"><button style="width:100%">application</button></a></div><br />
            <div><a href="javascript:" onClick="showDiv('6');"><button style="width:100%">Approve Membership</button></a></div><br />
        </div>
        <div class="right">
        <div class="rightContainer" style="float:right;">
           <div id="div1" style="display:none;">
            <!-- start send mail -->
           <form action="mailprocessing.php"  method='post'>
  <div class="row">
    <div class="col-25">
      <label for="email">E-mail</label>
    </div>
    <div class="col-75">
      <input type="text" id="email" name="email" placeholder="Your name.." value="<?= $viewGuests['GuestEmail']; ?>" readonly>
    </div>
  </div>
  <div class="row">
    <div class="col-25">
      <label for="header">subject</label>
    </div>
    <div class="col-75">
      <input type="text" id="subject" name="subject" placeholder="Your last name..">
    </div>
  </div>  
  <div class="row">
    <div class="col-25">
      <label for="contain">Contain</label>
    </div>
    <div class="col-75">
      <textarea id="contain" name="message" placeholder="Write something.." style="height:200px"></textarea>
    </div>
  </div>
  <div class="row">
    <input type="submit" value="Submit">
  </div>
  </form></div> 
   <!-- end of send email -->
            <div id="div2" style="display:none;">Send Text Message</div>
            <div id="div3" style="display:none;">

            <!-- add new records and view records -->
                <div><a href="viewrecords.php"><p>View all records for <?= $viewGuests['GuestFirstName']; ?></p></a></div>
                <div>Add new record below</div><br />
             <form action="addnewrecords.php" method="post">
              <input type="date" name="date" id="date">
              <input type="hidden" id="GuestID" name="GuestID" value="<?= $viewGuests['GuestID']; ?>" readonly> <br />
              <textarea name="writerecord" id="writerecord" placeholder="start typing record" style="height:300px"></textarea>
              <center><input type="submit"></center>
             </form>
            </div>
            <div id="div4" style="display:none;"><p><br><a href="#" onClick="MyWindow=window.open('phone.html','MyWindow','width=600,height=300'); return false;">make a call</a></p></div>
            <div id="div5" style="display:none;">Applications</div>
            <div id="div6" style="display:none;">
    <!-- Approve Membership -->


            <h2> Approve Membership</h2>
            <h3> Verify and correct info</h3>
              <h3>before approve it</h3>
            
              <form action="approvemembership.php" method="post">
                First Name: <input type="text" name="FirstName" id="FirstName" value="<?= $viewGuests['GuestFirstName']; ?> " readonly><br />
                Last Name: <input type="text" name="LastName" id="LastName" value="<?= $viewGuests['GuestLastName']; ?>" readonly> <br />
                Phone Number: <input type="text" name="per_CellPhone" id="per_CellPhone" value="<?= $viewGuests['GuestPhoneNumber']; ?>" readonly><br />
                Email: <input type="text" name="per_Email" id="per_Email" value="<?= $viewGuests['GuestEmail']; ?>" readonly><br>
                Address : <input type="text" name="per_Address1" id="per_Address1"><br>
                City: <input type="text" name="per_City" id="per_City"><br>
                State: <input type="text" name="per_State" id="per_State"><br>
                ZipCode: <input type="text" name="per_Zip" id="per_Zip"><br>
                Country: <input type="text" name="per_Country" id="per_Country"><br>

                <center><input type="submit" name="" id=""></center>

              </form>
            
          </div>
        </div>
    </div>
</div>

        <script>
            function showDiv(id) {  
    for (var i=1;i<=6;i++)
    {
        document.getElementById('div'+i).style.display = 'none';
    }
    document.getElementById('div'+id).style.display = 'block';
}
        </script>
</body>
</html>