| Current Path : /home/h/a/p/happyrenas/myreco.online/administration/gestion/ |
Linux webd005.cluster105.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 |
| Current File : /home/h/a/p/happyrenas/myreco.online/administration/gestion/lieux_visite.php |
<?
set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ . '/../');
include("../../configuration.php");
include("../../includes/fonctions.php");
setlocale(LC_TIME, 'fr_FR.UTF-8');
///////////////////////
//PARAMETRES DE LA PAGE
///////////////////////
$totem = "lieux_visite";
$page = "lieux_visite";
$ariane = "lieux_visite";
$ariane1 = "lieux_visite";
$titre = "lieux_visite";
///////////////////////
//RECUPERATION ET TRAITEMENT
///////////////////////
$action = $db->escape($_REQUEST['action']);
$miseajour = $db->escape($_REQUEST['miseajour']);
$query = $_GET['query'] ?? 'proche';
$categorie = $_GET['categorie'] ?? 'a_voir';
$zones = [$query]; // tableau avec UNE seule zone sélectionnée
$categories = [$categorie]; // tableau avec UNE seule catégorie sélectionnée
?>
<!DOCTYPE html>
<html lang="fr">
<?include("includes/head.php");?>
<body id="kt_body" class="page-loading-enabled page-loading header-fixed header-mobile-fixed subheader-enabled subheader-fixed aside-enabled aside-fixed page-loading" style="background-color:#ECE8E4!important;">
<div id="halt_loader_overlay"></div><div id="halt_loader" class=""><i class="fa fa-spinner fa-spin"></i> <?echo $trad['Chargement des informations, merci de patienter'] ?? '⚠️';?></div>
<div class="d-flex flex-column flex-root">
<!--begin::Page-->
<div class="d-flex flex-row flex-column-fluid page">
<?include("includes/header_left.php");?>
<!--begin::Wrapper-->
<div class="d-flex flex-column flex-row-fluid wrapper" id="kt_wrapper">
<?include("includes/header_top.php");?>
<!--begin::Content-->
<div class="content d-flex flex-column flex-column-fluid" id="kt_content">
<!--begin::Subheader-->
<div class="subheader py-2 py-4 subheader-solid" id="kt_subheader">
<div class="container-fluid d-flex align-items-center justify-content-between flex-wrap flex-sm-nowrap">
<div class="d-flex align-items-center">
<div class="btn-group ml-2">
<a class="btn btn-secondary btn-sm" href="index.php?token=<?echo $token;?>"><?echo $trad['Mon compte'] ?? '⚠️';?></a>
</div>
<div class="btn-group ml-2">
<a class="btn btn-secondary btn-sm" href="etablissement_ajout.php?token=<?echo $token;?>"><?echo $trad['Supprimer un lieu'] ?? '⚠️';?></a>
</div>
<div class="btn-group ml-2">
<a class="btn btn-primary btn-sm" href="#"><?echo $trad['Supprimer un lieu'] ?? '⚠️';?></a>
</div>
<div class="btn-group ml-2">
<a class="btn btn-secondary btn-sm" href="mon_qrcode.php?token=<?echo $token;?>"><?echo $trad['Mon QR code'] ?? '⚠️';?></a>
</div>
<div class="btn-group ml-2">
<a class="btn btn-secondary btn-sm" href="ma_carte.php?token=<?echo $token;?>"><?echo $trad['Ma carte'] ?? '⚠️';?></a>
</div>
<div class="btn-group ml-2">
<a class="btn btn-secondary btn-sm" href="find.php?token=<?echo $token;?>"><?echo $trad['find'] ?? '⚠️';?></a>
</div>
</div>
</div>
</div>
<!--end::Subheader-->
<?
$myquery = "SELECT * from heb where token='".$token."'";
$fiche = $db->get_row($myquery);
$tableau_liste = recupererLieuxCarte($fiche, $zones, $categories, true);
?>
<div class="d-flex flex-column-fluid">
<div class="container-fluid">
<div class="row">
<div class="col-xl-12" >
<div class="card card-custom" style="border: 1px solid <?echo $couleur_bordure;?>;">
<div class="card-header card-header-tabs-line">
<h3 class="card-title "><?echo $trad['Ajouter un lieu'] ?? '⚠️';?></h3>
<div class="card-toolbar">
</div>
</div>
<div class="card-body">
<div class="row d-flex justify-content-between align-items-center mb-5">
<?php
$leszones = ['proche' => '0-30km', 'median' => '30-60km', 'lointain' => '60-100km'];
foreach ($leszones as $key => $label): ?>
<div class="col-4">
<a class="ml-1 btn btn-secondary btn-block text-dark<?= isActive($query, $key) ?>"
href="lieux_visite.php?token=<?= urlencode($token) ?>&query=<?= $key ?>&categorie=<?= urlencode($categorie) ?>"
onclick="showLoader();"
>
<?= $label ?>
</a>
</div>
<?php endforeach; ?>
</div>
<div class="row d-flex justify-content-between align-items-center mb-10">
<?php
$lescategories = [
'a_voir' => $trad['A voir'] ?? 'A voir',
'restaurant' => $trad['Restaurant'] ?? 'Restaurant',
'ludique' => $trad['Ludique'] ?? 'Ludique',
'soiree' => $trad['En soirée'] ?? 'En soirée'
];
foreach ($lescategories as $key => $label): ?>
<div class="col-3">
<a class="btn btn-secondary btn-block text-dark<?= isActive($categorie, $key) ?>"
href="lieux_visite.php?token=<?= urlencode($token) ?>&query=<?= urlencode($query) ?>&categorie=<?= $key ?>"
onclick="showLoader();"
>
<?= $label ?>
</a>
</div>
<?php endforeach; ?>
</div>
<div class="row">
<?
foreach ($tableau_liste as $lieu) {
if (!$lieu['desactive']) {$is_active="oui";}
$button_class = $is_active ? "btn-danger" : "btn-success";
$button_text = $is_active ? "Désactiver" : "Activer";
$border_color = $is_active ? "#6B757D" : "#dc3545"; // Vert si actif, rouge sinon
$photo_token = $lieu['token'];
$photo_id = $lieu['id']; // identifiant unique pour distinguer les composants
$prefix = substr($photo_token, 0, 2);
$prefix=strtoupper($prefix);
$photo_url = "/upload/visite/$prefix/$photo_token.jpg";
$photo_full_path = DOSSIER_RACINE.$photo_url;
?>
<div class="col-xl-4 mt-4">
<div class="card card-custom" id="card-<?= $lieu['id'] ?>" style="border: 2px solid <?= $border_color ?>;">
<div class="card-header">
<h3 class="card-title"><?= $lieu['name'] ?></h3>
<div class="card-toolbar">
<button id="btn-<?= $lieu['id'] ?>" class="btn <?= $button_class ?>" onclick="toggleActivation(<?= $lieu['id'] ?>, '<?= $lieu['categorie'] ?>')">
<?= $button_text ?>
</button>
</div>
</div>
<div class="card-body">
<h5 class="card-title"><?echo $trad['Distance'] ?? '⚠️';?> : <?= $lieu['distance'] ?> km</h5>
<?php if (file_exists($photo_full_path)): ?>
<img id="photoActuelle_<?= $photo_id ?>" class="img-fluid" style="max-height: 300px;"
src="../../../<?= $photo_url ?>?v=<?= uniqid() ?>">
<?php else: ?>
<p id="photoActuelleMessage_<?= $photo_id ?>">Aucune photo</p>
<?php endif; ?>
<div class="custom-file mt-2">
<input type="file" class="custom-file-input" id="photoInput_<?= $photo_id ?>">
<label class="custom-file-label" for="photoInput_<?= $photo_id ?>">Choisir une photo...</label>
</div>
<input type="hidden" id="token_<?= $photo_id ?>" value="<?= $photo_token ?>">
<button type="button" class="btn btn-sm btn-primary mt-2 uploadPhotoBtn" data-id="<?= $photo_id ?>">
<i class="fa fa-upload"></i> Uploader
</button>
<div id="uploadResult_<?= $photo_id ?>" class="text-success small mt-1"></div>
</div>
</div>
</div>
<?php
}
?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!--end::Content-->
</div>
<!--begin::Footer-->
<?include("includes/footer.php");?>
<!--end::Footer-->
</div>
<!--end::Wrapper-->
</div>
<!--end::Page-->
</div>
<!--end::Main-->
<?include("includes/extrav2.php");?>
<script type="text/javascript" class="init">
function toggleActivation(id) {
showLoader();
$.post("toggle_activation.php", { visite_id: id, token: '<?echo $token;?>', categorie:'<?echo $categorie;?>',query:'<?echo $query;?>' }, function(response) {
let data = JSON.parse(response);
if (data.success) {
console.log(data.requete_update);
let btn = $("#btn-" + id);
let card = btn.closest(".card");
if (data.new_status) {
btn.removeClass("btn-danger").addClass("btn-success").text("<?echo $trad['Activer'] ?? '⚠️';?>");
card.css("border", "2px solid #dc3545"); // Bordure rouge
} else {
btn.removeClass("btn-success").addClass("btn-danger").html("<?echo $trad['Désactiver'] ?? '⚠️';?>");
card.css("border", "2px solid #28a745"); // Bordure verte
}
}
hideLoader();
});
}
$(document).ready(function() {
$('.uploadPhotoBtn').on('click', function () {
const id = $(this).data('id');
const fileInput = $('#photoInput_' + id)[0];
const token = $('#token_' + id).val();
if (!fileInput.files.length) {
alert('Veuillez sélectionner une photo.');
return;
}
const formData = new FormData();
formData.append('photo', fileInput.files[0]);
formData.append('token', token);
formData.append('table', 'vis');
showLoader();
$.ajax({
url: '../upload_photo_visite.php',
type: 'POST',
data: formData,
processData: false,
contentType: false,
dataType: 'json',
success: function (response) {
$('#uploadResult_' + id).html(response.message);
const imageUrl = response.photo_url + '?v=' + Math.random();
if ($('#photoActuelle_' + id).length) {
$('#photoActuelle_' + id).attr('src', imageUrl);
} else {
$('#photoActuelleMessage_' + id).remove();
$('#photoInput_' + id).closest('.card-body').prepend('<img id="photoActuelle_' + id + '" class="img-fluid" style="max-height: 300px;" src="' + imageUrl + '">');
}
},
error: function () {
$('#uploadResult_' + id).html('Erreur AJAX.');
},
complete: function () {
hideLoader();
}
});
});
// mise à jour dynamique du label
$('.custom-file-input').on('change', function () {
const fileName = $(this).val().split('\\').pop();
$(this).next('.custom-file-label').html(fileName);
});
////////////////////////////
//MISE A JOUR NOTIFICATION//
////////////////////////////
<?if ($miseajour==1) {$title=$label_success;$message=$label_operation;$type="success";}?>
<?if ($miseajour==2) {$title=$label_erreur1;$message=$label_existe;$type="danger";}?>
<?if ($miseajour==3) {$title=$label_erreur1;$message=$label_plus_de;$type="danger";}?>
<?if ($miseajour) {?>
$.notify({title: '<?echo $title;?>',message: '<?echo $message;?>',},{element: 'body',position: null,type: "<?echo $type;?>",allow_dismiss: true,newest_on_top: true,spacing: 10,delay : 1000,placement: {from: "top",align: "center"},offset: {x: 30,y: 30},z_index: 10000,animate: {enter: 'animate__animated animate__bounce',exit: 'animate__animated animate__bounce'}});
<?}?>
});
</script>
<?include("includes/end.php");?>
</body>
</html>