Files
MYSOPHAL/front/drh.book.newsletter.php
2025-11-09 10:02:18 +01:00

129 lines
3.8 KiB
PHP

<?php
error_reporting(E_ERROR | E_PARSE);
error_reporting(E_ALL ^ E_WARNING);
require_once('../lib/tcpdf/templates/tcpdf_include.php');
include('../model_controller/articles.list.php');
Session::checkLoginUser();
// --- DB check for user reading policy ---
function checkIfExist($id)
{
global $DB;
$stmt = $DB->prepare("SELECT * FROM `glpi_read_policy` WHERE user_id = ? AND document = 'cc2'");
$stmt->bind_param("i", $id);
$stmt->execute();
$result = $stmt->get_result();
return ($result->num_rows > 0);
}
function update_policy_read($id)
{
global $DB;
$stmt = $DB->prepare("INSERT INTO `glpi_read_policy` (`user_id`, `read`, `document`) VALUES (?, 1, 'cc2')");
$stmt->bind_param("i", $id);
$stmt->execute();
return $DB->insert_id();
}
$currentuserid = $_SESSION["glpiID"];
if (checkIfExist($currentuserid)) {
Html::redirect($CFG_GLPI['root_doc'] . "/front/central.php");
}
if (isset($_GET["readyes"]) && $_GET["readyes"] == 1) {
$lastId = update_policy_read($currentuserid);
if ($lastId) {
Html::redirect($CFG_GLPI['root_doc'] . "/front/central.php");
}
}
// Load image files from folder
$path = "";
$dir = "../file_upload/comu1/" . $path;
$images = [];
if (is_dir($dir)) {
$files = scandir($dir);
foreach ($files as $file) {
if (preg_match('/\.(jpg|jpeg|png|gif|webp)$/i', $file)) {
$images[] = $dir . '/' . $file;
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Newsletter Carousel</title>
<!-- Bootstrap 4 -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css">
<style>
body, html {
height: 100%;
margin: 0;
padding: 0;
}
.carousel-inner img {
object-fit: contain;
height: 100vh;
}
</style>
</head>
<body>
<!-- ✅ Mark as Read button -->
<div style="position: fixed; top: 20px; right: 20px; z-index: 1050;">
<a href="?readyes=1" class="btn btn-success">✅ Marquer comme lu</a>
</div>
<div class="container-fluid p-0">
<div id="newsletterCarousel" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<?php foreach ($images as $index => $img): ?>
<li data-target="#newsletterCarousel" data-slide-to="<?= $index ?>" class="<?= $index === 0 ? 'active' : '' ?>"></li>
<?php endforeach; ?>
</ol>
<div class="carousel-inner">
<?php foreach ($images as $index => $img): ?>
<div class="carousel-item <?= $index === 0 ? 'active' : '' ?>">
<img class="d-block w-100" src="<?= $img ?>" alt="Slide <?= $index + 1 ?>">
</div>
<?php endforeach; ?>
</div>
<a class="carousel-control-prev" href="#newsletterCarousel" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#newsletterCarousel" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
<!-- Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.12.9/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/js/bootstrap.min.js"></script>
</body>
</html>
<style>
.carousel-control-prev, .carousel-control-next {
color: blue;
background: #00000057;
}
.carousel-control-next, .carousel-control-prev{
width: 5% !important;
}
</style>