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

$direction = "../assets/img/our-program/";

// retrive all image from table
$Data = "";
$programSql = "
SELECT our_program_ar.ID, our_program_ar.name, our_program_ar.paragraph, our_program_ar.image, our_program_ar.insertDate,
our_program_ar.insertUsername, our_program_ar.updateDate, our_program_ar.updateUsername, our_program_ar.status ,
our_program_en.ID, our_program_en.name, our_program_en.paragraph, our_program_en.image, our_program_en.insertDate,
our_program_en.insertUsername, our_program_en.updateDate, our_program_en.updateUsername, our_program_en.status
FROM our_program_ar ,our_program_en where our_program_ar.ID = our_program_en.ID";
$executeSql = mysqli_query($connection,$programSql);
while($retriveData = mysqli_fetch_row($executeSql))
{
    if($retriveData[0] == 1)
    {
        $action = "<a href='show-joodcom.php' class='btn btn-primary'>عرض التفاصيل</a>";
    }
    elseif($retriveData[0] == 2)
    {
        $action = "<a href='show-makingStars.php' class='btn btn-primary'>عرض التفاصيل</a>";
    }
    $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[3]}' class='card-img' alt='...' style='max-width:300px;max-height:300px;'>
                </div>
                <div class='col-md-6'>
                    <div class='card-body'>
                        <h5 class='card-title'>{$retriveData[1]}</h5>
                        <p class='card-text'>{$retriveData[2]}</p>
                    </div>
                    <div class='card-body text-left'>
                    <h5 class='card-title'>{$retriveData[10]}</h5>
                    <p class='card-text'>{$retriveData[11]}</p>
                </div>
                </div>
                <div class='col-md-3'>
                <img src='$direction{$retriveData[12]}' class='card-img' alt='...' style='max-width:300px;max-height:300px;'>
                </div>
            </div>
            <!-- End row -->

            <div class='row no-gutters'>
                <div class='col-md-12'>
                    <div class='card-footer text-muted text-center'>
                        بواسطة : {$retriveData[5]}
                         | 
                        بتاريخ : {$retriveData[6]}
                        <div class='buttons text-left'>
                        {$action}
                        <a href='edit-program.php?ID={$retriveData[0]}' class='btn btn-warning'>تعديل</a>
                        </div>
                    </div>

                </div>
            </div>
            <!-- End row -->
        </div>
        <!-- End card -->
    </div>
    <!-- End col -->
    ";
}
?>
<!doctype html>
<html lang="ar">
  <head>
    <title>خذ فرصة</title>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- assets / css -->
    <?php include 'cssFile.php'; ?>

  </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-program">
                <h3>برامجنا</h3>
            </div>
        </div>
        <!-- End row -->

        <div class='row' style='margin-top:30px;'>

            <?php
                echo $Data;
            ?>

        </div>
        <!-- End row -->
    </div>
    <!-- End container -->
</div>
<!-- End content body -->
<!-- assets / js -->
    <?php include 'jsFile.php'; ?>

    <script>

<?php
if(!isset($_SESSION))
  session_start();
if(isset($_SESSION["updateinfo"]) && $_SESSION["updateinfo"] == 1)
{ 
?>
Swal.fire(
  'تم تعديل المعلومات بنجاح',
  '',
  'success'
)
<?php
$_SESSION["updateinfo"] = 0;
}
?>

  </script>
  </body>
</html>
<!-- onload="reloader()" --> 
