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

$Data = "";
$direction = "../assets/img/team/";
$sqlRetrive = "select ID,name,jobTitle,content,summary,image from team_ar";
$excuteSql = mysqli_query($connection,$sqlRetrive);
while($retriveData = mysqli_fetch_row($excuteSql))
{
    $Data .= "<div class='col-12 text-right'>
    <div class='card mb-3'>
        <div class='row no-gutters'>
            <div class='col-md-3'>
                <img src='$direction{$retriveData[5]}' class='card-img' alt='...' style='max-width:250px;'>
            </div>
            <div class='col-md-6'>
                <div class='card-body'>
                    <h5 class='card-title'>{$retriveData[1]}</h5>
                    <h5 class='card-title'>{$retriveData[2]}</h5>
                    <p class='card-text' style='text-align:justify;font-size:20px'>{$retriveData[4]}</p>
                </div>
            </div>
            <div class='col-md-3' style='padding: 10px;'>
                <button type='button' class='btn btn-info btn-block view-team' id='{$retriveData[0]}' data-toggle='modal' data-target='#showInfo'>عرض التفاصيل</button>
                
                <a href='edit-team.php?ID={$retriveData[0]}' class='btn btn-warning btn-block'>تعديل</a>
                
            </div>
        </div>
        <!-- End row -->

    </div>
    <!-- End card -->
</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-team">
                <h3>فريق خذ فرصة</h3>
            </div>
        </div>
        <!-- End row -->
        <div class='col-md text-right' style='margin:0 10px 10px 0px;'>
        <a class='btn btn-blue' href='add-team.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["updateSuccess"]) && $_SESSION["updateSuccess"] == 1)
{ 
?>
Swal.fire(
  'تم التعديل بنجاح',
  '',
  'success'
)
<?php
$_SESSION["updateSuccess"] = 0;
}
?>

  </script>
      <script>
    $(document).ready(function(){
    $('.view-team').click(function(){
        var infoID = $(this).attr("id");
        $.ajax({
            url: "showsingleteam.php",
            method:"post",
            data:{infoID,infoID},
            success:function(data)
            {
                $('#show-team').html(data);
                $('#showInfo').model("show");
            }
        });
    });
});

    </script>
</body>
</html>
<!-- Modal -->
<div class="modal fade " id="showInfo" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true" dir='rtl'>
  <div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">عرض التفاصيل</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body" id='show-team'>
        
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-danger" data-dismiss="modal" style='margin-right: .25rem;'>الغاء</button>
      </div>
    </div>
  </div>
</div>