<?php
include '../connection.php';
if(!isset($_SESSION)){session_start();}
if(!isset($_SESSION["ID"])){header('Location: index.php');}

if(isset($_GET["ID"]))
{
    $id = $_GET["ID"];
    $updateSql = "update contactus set status=0 where ID={$id}";
    $executeSql = mysqli_query($connection,$updateSql);
    $_SESSION["done"] = 1;
}
$Data = "";
$sqlRetrive = 'select ID,name,email,phone,subject,content,createDate from contactus where status = 1';
$executeSql = mysqli_query($connection,$sqlRetrive);

while($retriveData = mysqli_fetch_row($executeSql))
{
    $Data .="
    <div class='col-md-10 mt-3'>
    <div class='card text-right'>
    <div class='card-header text-center'>
      {$retriveData[4]}
    </div>
    <div class='card-body'>
      <p class='card-text'>{$retriveData[5]}</p>
      <footer class='blockquote-footer'>الإسم : $retriveData[1]</footer>
      <footer class='blockquote-footer'>البريد الإلكتروني : $retriveData[2]</footer>
      <footer class='blockquote-footer'>رقم الهاتف : $retriveData[3]</footer>


      <a href='show-contactus.php?ID=$retriveData[0]' class='btn btn-warning' style='float:left;color:#000'>تم الإنتهاء</a>
    </div>
    <div class='card-footer text-muted text-center'>
      $retriveData[6]
    </div>
  </div>
    </div>
    <!-- End col -->
    ";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>خذ فرصة</title>
    <?php include 'cssFile.php'; ?>
    <style>
    .blockquote-footer
    {
        font-size:16px;
    }
    </style>
</head>
<body dir='rtl'>
    <?php include 'navbar.php';?>

    <div class="content-body">
        <div class='container' style='margin-top:30px;'>
        <div class="row justify-content-center">
            <div class="col-md-3 text-center col-contact">
                <h3>تواصل معنا</h3>
            </div>
        </div>
        <!-- End row -->
        <div class='col-md text-right' style='margin:0 10px 10px 0px;'>
        <a class='btn btn-pink' href='show-contactusEnd.php'>عرض</a>
      </div>
      <!-- End col -->

      <div class='row justify-content-center'>

        <?php
             echo $Data;
        ?>

    </div>
    <!-- End row -->


        </div>
        <!-- End container -->
    </div>
    <!-- End content-body -->

    <?php include 'jsFile.php'; ?>
    <script>
    <?php
if(!isset($_SESSION))
  session_start();
if(isset($_SESSION["done"]) && $_SESSION["done"] == 1)
{ 
?>
Swal.fire(
  'تم الإخفاء بنجاح',
  '',
  'success'
)
<?php
$_SESSION["done"] = 0;
}
?>

  </script>
</body>
</html>