| Current Path : /home/h/a/p/happyrenas/myreco.online/administration/panel/ |
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/panel/hebergement_detail.php |
<?
set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ . '/../');
include("../../configuration.php");
include("../../includes/fonctions.php");
setlocale(LC_TIME, 'fr_FR.UTF-8');
include("auth.php");
ini_set('memory_limit', '512M'); // ou plus si nécessaire
///////////////////////
//PARAMETRES DE LA PAGE
///////////////////////
$totem = "hebergement";
$page = "hebergement";
$ariane1 = "Les hebergements";
$ariane2 = "Les hebergements";
$titre = "Les hebergements";
$datatable_nom = "hebergement_table";
$date_creation = date("Y-m-d");
$date_heure_creation = date("Y-m-d H:i");
$miseajour = $db->escape($_REQUEST['miseajour']);
$country_code_selected = $db->escape($_REQUEST['country_code_selected']);
$postal_code_selected = $db->escape($_REQUEST['postal_code_selected']);
$hebergement_id = $db->escape(trim($_REQUEST['hebergement_id']));
$generer_correspondance = $db->escape(trim($_REQUEST['generer_correspondance']));
$generer_qrcode = $db->escape(trim($_REQUEST['generer_qrcode']));
$hebergement_nom = $db->escape(trim($_REQUEST['hebergement_nom']));
if ($hebergement_nom){
$query = "UPDATE heb SET name = '".$hebergement_nom."' WHERE id = ".$hebergement_id;
$db->query($query);
header("Refresh:0; url=hebergement_detail.php?country_code_selected=$country_code_selected&postal_code_selected=$postal_code_selected&hebergement_id=$hebergement_id&miseajour=1");exit;
}
if ($generer_correspondance=="oui"){
$myquery = "SELECT token from heb where id=".$hebergement_id;
$fiche = $db->get_row($myquery);
genererCorrespondance($fiche->token);
header("Refresh:0; url=hebergement_detail.php?country_code_selected=$country_code_selected&postal_code_selected=$postal_code_selected&hebergement_id=$hebergement_id&miseajour=1");exit;
}
if ($generer_qrcode=="oui"){
$myquery = "SELECT token,country_code from heb where id=".$hebergement_id;
$fiche = $db->get_row($myquery);
$result=genererQRCodeHabilleSansEcraser($fiche->token, $fiche->country_code);
header("Refresh:0; url=hebergement_detail.php?country_code_selected=$country_code_selected&postal_code_selected=$postal_code_selected&hebergement_id=$hebergement_id&miseajour=1");exit;
}
?>
<!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">
<div id="halt_loader_overlay"></div>
<div id="halt_loader" class=""><i class="fa fa-spinner fa-spin"></i> Chargement des informations, merci de patienter...</div>
<div id="halt_initialisation" class=""><i class="fa fa-spinner fa-spin"></i> Première initialisation de votre hébergement, 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">
<?
if ($hebergement_id){
$myquery = "SELECT * from heb where id=".$hebergement_id;
$fiche = $db->get_row($myquery);
$init_result = initialiserHebergementSiNecessaire($fiche->token);
if (strpos($init_result, "Initialisation effectuée") !== false) {
echo "<script>
document.addEventListener('DOMContentLoaded', function () {
const waitAndReload = () => {
if (typeof showLoader === 'function') {
showLoaderInitialisation();
setTimeout(function () {
location.reload();
}, 500);
} else {
setTimeout(waitAndReload, 50); // réessaye jusqu'à ce que showLoader soit dispo
}
};
waitAndReload();
});
</script>";
}
}
?>
<!--begin::Subheader-->
<div class="subheader py-2 py-lg-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 flex-wrap mr-2">
<h5 class="text-dark font-weight-bold mt-2 mb-2 mr-5"><?echo $country_code_selected;?></h5>
<div class="subheader-separator subheader-separator-ver mt-2 mb-2 mr-5 bg-gray-200"></div>
<h5 class="text-dark font-weight-bold mt-2 mb-2 mr-5">Département <?echo $postal_code_selected;?></h5>
<div class="d-flex align-items-center" id="kt_subheader_search">
<span class="text-dark-50 font-weight-bold" id="kt_subheader_total"></span>
</div>
</div>
<div class="d-flex align-items-center">
<div class="btn-group ml-2">
<a href="hebergement_detail.php?country_code_selected=<?echo $country_code_selected;?>&postal_code_selected=<?echo $postal_code_selected;?>&hebergement_id=<?echo $hebergement_id;?>&generer_qrcode=oui"
class="btn btn-outline-danger font-weight-bold btn-sm px-3 font-size-base"
onclick="showLoader();">(Re)générer QR</a>
</div>
<div class="btn-group ml-2">
<a href="hebergement_detail.php?country_code_selected=<?php echo $country_code_selected; ?>&postal_code_selected=<?php echo $postal_code_selected; ?>&hebergement_id=<?php echo $hebergement_id; ?>&generer_correspondance=oui"
class="btn btn-outline-danger font-weight-bold btn-sm px-3 font-size-base"
onclick="showLoader();">
(Re)générer correspondances
</a>
</div>
<div class="btn-group ml-2">
<a target="_blank" href="https://www.myreco.online/administration/gestion/index.php?token=<?echo $fiche->token;?>" class="btn btn-outline-danger font-weight-bold btn-sm px-3 font-size-base">Compte proprio</a>
</div>
<div class="btn-group ml-2">
<a href="hebergement_liste.php?country_code_selected=<?echo $country_code_selected;?>&postal_code_selected=<?echo $postal_code_selected;?>" class="btn btn-outline-danger font-weight-bold btn-sm px-3 font-size-base" onclick="showLoader();">Retour</a>
</div>
</div>
</div>
</div>
<!--end::Subheader-->
<div class="d-flex flex-column-fluid">
<div class="container-fluid">
<div class="row">
<div class="col-xl-6" >
<div class="card card-custom" style="border: 1px solid <?echo $couleur_bordure;?>;">
<div class="card-header flex-wrap py-3">
<div class="card-title">
<h3 class="card-label"><?echo $fiche->name;?></h3>
</div>
<div class="card-toolbar" id="card-toolbar"></div>
</div>
<div class="card-body">
<!--begin::Tab Content-->
<div class="row">
<div class="col-12" >
<?
foreach ( $db->get_col_info("name") as $name )
{
$myquery = "SELECT COLUMN_NAME, COLUMN_COMMENT AS COLUMN_COMMENT FROM information_schema.COLUMNS a WHERE COLUMN_NAME='".$name."' AND TABLE_NAME = 'heb';";
$metadata = $db->get_row($myquery);
$fiche->$name=str_replace('"','"',$fiche->$name);
?>
<div class="form-group">
<label><?echo $name;?> <?if ($metadata->COLUMN_COMMENT){?><span class="text-primary"> [<?echo $metadata->COLUMN_COMMENT;?>]</span><?}?></label>
<div class="input-group">
<input type="text" style="background-color:#ddd;cursor:not-allowed;" class="form-control" disabled readonly value="<?echo $fiche->$name;?>" >
</div>
</div>
<?}?>
</div>
</div>
</div>
</div>
</div>
<div class="col-xl-6" >
<div class="row">
<div class="col-xl-12 mb-2" >
<div class="card card-custom" style="border: 1px solid <?echo $couleur_bordure;?>;">
<div class="card-header flex-wrap py-3">
<div class="card-title">
<h3 class="card-label">Lieux à proximité de cet hébergement</h3>
</div>
</div>
<div class="card-body">
<?php
$myquery = "SELECT * FROM heb WHERE id = " . $hebergement_id;
$fiche = $db->get_row($myquery);
// Analyse des 3 zones
$proche_info = analyserJsonCategorie($fiche->proche_json);
$median_info = analyserJsonCategorie($fiche->median_json);
$lointain_info = analyserJsonCategorie($fiche->lointain_json);
?>
<table border="1" cellpadding="8" cellspacing="0" style="width:100%;border-collapse: collapse;">
<thead>
<tr>
<th>Zone</th>
<th>Total</th>
<th>Détail</th>
</tr>
</thead>
<tbody>
<tr>
<td>🟢 Proche</td>
<td><?= $proche_info['total'] ?></td>
<td><?= implode(' / ', $proche_info['detail']) ?></td>
</tr>
<tr>
<td>🟠 Médian</td>
<td><?= $median_info['total'] ?></td>
<td><?= implode(' / ', $median_info['detail']) ?></td>
</tr>
<tr>
<td>🔵 Lointain</td>
<td><?= $lointain_info['total'] ?></td>
<td><?= implode(' / ', $lointain_info['detail']) ?></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="col-xl-12 mb-2" >
<div class="card card-custom" style="border: 1px solid <?echo $couleur_bordure;?>;">
<div class="card-body">
<div class="row">
<div class="col-xl-12 mb-2 d-flex align-items-start ">
<?php
$infos = recupererCheminsQRCode($fiche->token);
if ($infos['existe_brut']) {
echo "<a href='{$infos['qrcode']}' target='_blank'>
<img src='{$infos['qrcode']}' height='120' style='border:1px solid #ccc;'>
</a>";
}
if ($infos['existe_habille']) {
echo "<a href='{$infos['qrcode_habille']}' target='_blank'>
<img src='{$infos['qrcode_habille']}' height='120' style='border:1px solid #ccc;'>
</a>";
}
?>
<hr>
<?echo $infos['date_brut'] ;?>
</div>
</div>
</div>
</div>
</div>
<div class="col-xl-12 mb-2" >
<div class="card card-custom" style="border: 1px solid <?echo $couleur_bordure;?>;">
<div class="card-body">
<div class="row">
<div class="col-xl-12 mb-2 ">
<?
$prefix = strtoupper(substr($fiche->token, 0, 2));
$photo_path = "/upload/hebergement/$prefix/{$fiche->token}.jpg";
$photo_abs_path = DOSSIER_RACINE.$photo_path;
if (file_exists($photo_abs_path)) {
echo '<img id="photoActuelle" src="../../../' . $photo_path . '?v=' . uniqid() . '" alt="Photo hébergement" style="max-width:300px">';
} else {
echo '<p id="photoActuelleMessage">Aucune photo trouvée ou récupérée.</p>';
}
?>
</div>
<div class="col-xl-12 mb-2 ">
<div class="form-group row align-items-center">
<div class="col-lg-6">
<div class="custom-file">
<input type="file" class="custom-file-input" id="photoInput">
<label class="custom-file-label" for="photoInput">Choisir une photo...</label>
</div>
<input type="hidden" id="token" value="<?= $fiche->token ?>">
</div>
<div class="col-lg-6">
<button type="button" class="btn btn-primary" id="uploadPhotoBtn">
<i class="fa fa-upload"></i> Uploader
</button>
</div>
</div>
<div class="form-group">
<div id="uploadResult" class="text-success small mb-2"></div>
<div id="photoPreview"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-xl-12" >
<form id="formulaire_principal" action="hebergement_detail.php" method="post">
<input type="hidden" name="action" value="modifier">
<input type="hidden" name="hebergement_id" value="<?echo $hebergement_id;?>">
<input type="hidden" name="country_code_selected" value="<?echo $country_code_selected;?>">
<input type="hidden" name="postal_code_selected" value="<?echo $postal_code_selected;?>">
<div class="card card-custom" style="border: 1px solid <?echo $couleur_bordure;?>;">
<div class="card-header flex-wrap py-3">
<div class="card-title">
<h3 class="card-label">Données modifiables</h3>
</div>
<div class="card-toolbar" id="card-toolbar">
<div class="btn-group ml-2"><button type="submit" form="formulaire_principal" id="formulaire_principal" class="form_bouton btn btn-primary font-weight-bold btn-sm px-3 font-size-base" onclick="showLoader();">ENREGISTRER</button></div>
</div>
</div>
<div class="card-body">
<div class="row">
<div class="col-xl-12" >
<div class="form-group">
<label>Nom <span class="text-danger">*</span></label>
<div class="input-group">
<input type="text" name="hebergement_nom" class="form-control" placeholder="Nom" value="<?echo htmlspecialchars($fiche->name);?>" required>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</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">
$(document).ready(function() {
$('#photoInput').on('change', function () {
const fileName = $(this).val().split('\\').pop();
$(this).next('.custom-file-label').html(fileName);
});
$('#uploadPhotoBtn').on('click', function () {
const file = $('#photoInput')[0].files[0];
const token = $('#token').val();
if (!file || !token) {
alert('Merci de choisir une photo sur votre ordinateur avant de l\'uploader.');
return;
}
const formData = new FormData();
formData.append('photo', file);
formData.append('token', token);
showLoader(); // 🔄 Affiche le loader
$.ajax({
url: '../upload_photo_hebergement.php',
type: 'POST',
data: formData,
processData: false,
contentType: false,
success: function (response) {
console.log(response.message);
$('#uploadResult').html(response.message);
if (response.photo_url) {
const imageUrl = response.photo_url + '?v=' + Math.random();
if ($('#photoActuelle').length) {
// L'image existe déjà → on change son src
$('#photoActuelle').attr('src', imageUrl);
} else {
// Si pas d'image (juste un message), on l’ajoute
$('#photoActuelleMessage').remove(); // supprime le <p>
$('#photoPreview').html('<img id="photoActuelle" src="' + imageUrl + '" style="max-width:300px">');
}
}
},
error: function () {
$('#uploadResult').html('Erreur lors de l\'upload AJAX.');
},
complete: function () {
hideLoader(); // ✅ Cache le loader à la fin, qu'il y ait succès ou erreur
}
});
});
////////////////////////
//NOTIFICATION EN HAUT//
////////////////////////
<?if ($miseajour==1) {$title="Mise à jour demandée";$message="La mise à jour a été effectuée avec succès";$type="success";}?>
<?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>