| 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/index.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 = "index";
$page = "index";
$ariane = "index";
$ariane1 = "index";
$titre = "index";
///////////////////////
//RECUPERATION ET TRAITEMENT
///////////////////////
$token = $db->escape($_REQUEST['token']);
$miseajour = $db->escape($_REQUEST['miseajour']);
$action = $db->escape($_REQUEST['action']);
if ($action==1)
{
// Champs principaux
$type = $_POST['type_hebergement'] ?? '';
$tarif = floatval($_POST['tarif_nuit'] ?? 0);
$parking = $_POST['parking'] ?? '';
$nom_commercial = $_POST['nom_commercial'] ?? '';
$email_reservation = $_POST['email_reservation'] ?? '';
$site_reservation = $_POST['site_reservation'] ?? '';
$facebook = $_POST['facebook'] ?? '';
$instagram = $_POST['instagram'] ?? '';
$location_link = $_POST['location_link'] ?? '';
// Données spécifiques selon le type
$donnees_specifiques = [];
if ($type === 'hotel') {
$donnees_specifiques = [
'nb_chambres' => intval($_POST['nb_chambres_hotel'] ?? 0),
'etoiles' => intval($_POST['etoiles_hotel'] ?? 0),
];
} elseif ($type === 'location') {
$donnees_specifiques = [
'capacite' => intval($_POST['capacite_location'] ?? 0),
'nb_chambres' => intval($_POST['nb_chambres_location'] ?? 0),
'nb_sdb' => intval($_POST['nb_sdb_location'] ?? 0),
];
} elseif ($type === 'camping') {
$donnees_specifiques = [
'nb_emplacements' => intval($_POST['nb_emplacements'] ?? 0),
'nb_mobilhome' => intval($_POST['nb_mobilhome'] ?? 0),
'etoiles' => intval($_POST['etoiles_camping'] ?? 0),
];
}
// Encodage JSON
$equipements_json = json_encode($_POST['equipements'] ?? [], JSON_UNESCAPED_UNICODE);
$activites_json = json_encode($_POST['activites'] ?? [], JSON_UNESCAPED_UNICODE);
$donnees_json = json_encode($donnees_specifiques ?? [], JSON_UNESCAPED_UNICODE);
// Mise à jour SQL
$requete_update="
UPDATE heb SET
type_hebergement = '" . $db->escape($type) . "',
tarif_nuit = '" . $tarif . "',
donnees_specifiques = '" . $db->escape($donnees_json) . "',
equipements_json = '" . $db->escape($equipements_json) . "',
activites_json = '" . $db->escape($activites_json) . "',
parking = '" . $db->escape($parking) . "',
nom_commercial = '" . $db->escape($nom_commercial) . "',
email_reservation = '" . $db->escape($email_reservation) . "',
site_reservation = '" . $db->escape($site_reservation) . "',
facebook = '" . $db->escape($facebook) . "',
instagram = '" . $db->escape($instagram) . "',
location_link = '" . $db->escape($location_link) . "'
WHERE token = '" . $db->escape($token) . "'
";
$db->query($requete_update);
header("Refresh:0; url=index.php?token=".$token."&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" 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-primary 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['Ajouter un lieu'] ?? '⚠️';?></a>
</div>
<div class="btn-group ml-2">
<a class="btn btn-secondary btn-sm" href="lieux_visite.php?token=<?echo $token;?>"><?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);
initialiserHebergementSiNecessaire($token);
///////
$myquery = "select * from heb where token = '$token'";
$fiche = $db->get_row($myquery);
// Décodage JSON
$donnees_specifiques = json_decode($fiche->donnees_specifiques, true);
$equipements = json_decode($fiche->equipements_json, true);
$activites = json_decode($fiche->activites_json, true);
$photos_local = json_decode($fiche->photos_local_json ?? '[]', true);
$photos_local = is_array($photos_local) ? $photos_local : [];
?>
<div class="d-flex flex-column-fluid">
<div class="<?echo $container_type;?>">
<form id="formulaire" action="index.php" method="post" >
<input type="hidden" name="action" value="1">
<input type="hidden" name="token" value="<?echo $token;?>">
<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['Mon compte'] ?? '⚠️';?></h3>
<div class="card-toolbar">
<button type="submit" form="formulaire" id="form_bouton" class="form_bouton btn btn-sm btn-primary "><?echo $trad['Enregistrer'] ?? '⚠️';?></button>
</div>
</div>
<div class="card-body">
<div class="row">
<div class="col-xl-6" >
<div class="h3"><?echo $trad['Nouveau'] ?? '⚠️';?><span style="color: #EBE7E3; font-size: 32px;">❤</span></div>
<div class="alert-text mb-10">
<?echo $trad['De plus en plus de touristes cherchent des hébergements'] ?? '⚠️';?>
</div>
<div class="h3 mb-5"><?echo $trad['Vous êtes'] ?? '⚠️';?></div>
<div class="form-group row">
<div class="col-12 col-md-8 mb-4">
<label><?echo $trad["Type d hébergement"] ?? '⚠️';?></label>
<div class="input-group">
<select class="form-control" name="type_hebergement" id="type_hebergement">
<option value="">-- <?echo $trad["Sélectionner"] ?? '⚠️';?> --</option>
<?php foreach ($types_hebergement as $key => $label): ?>
<option value="<?= $key ?>" <?= ($fiche->type_hebergement ?? '') === $key ? 'selected' : '' ?>>
<?echo $trad[$key] ?? '⚠️';?>
</option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="col-12 col-md-4 mb-4">
<label><?echo $trad["Tarif pour une nuit"] ?? '⚠️';?> (€)</label>
<div class="input-group">
<input type="number" step="0.01" class="form-control" name="tarif_nuit" value="<?= htmlspecialchars($fiche->tarif_nuit) ?>" placeholder="Ex: 120">
</div>
</div>
</div>
<!-- Champs spécifiques à l'hôtel -->
<div id="hotel_fields" style="display:none;">
<div class="form-group">
<label><?echo $trad["Nombre total de chambres"] ?? '⚠️';?></label>
<input type="number" class="form-control" name="nb_chambres_hotel" value="<?= $donnees_specifiques['nb_chambres'] ?? '' ?>">
</div>
<div class="form-group">
<label><?echo $trad["Nombre d étoiles"] ?? '⚠️';?></label>
<input type="number" class="form-control" name="etoiles_hotel" min="0" max="5" value="<?= $donnees_specifiques['etoiles'] ?? '' ?>">
</div>
</div>
<!-- Champs spécifiques à la location -->
<div id="location_fields" style="display:none;">
<div class="form-group">
<label><?echo $trad["Capacité totale"] ?? '⚠️';?></label>
<input type="number" class="form-control" name="capacite_location" value="<?= $donnees_specifiques['capacite'] ?? '' ?>">
</div>
<div class="form-group">
<label><?echo $trad["Nombre de chambres"] ?? '⚠️';?></label>
<input type="number" class="form-control" name="nb_chambres_location" value="<?= $donnees_specifiques['nb_chambres'] ?? '' ?>">
</div>
<div class="form-group">
<label><?echo $trad["Nombre de SDB"] ?? '⚠️';?></label>
<input type="number" class="form-control" name="nb_sdb_location" value="<?= $donnees_specifiques['nb_sdb'] ?? '' ?>">
</div>
</div>
<!-- Champs spécifiques au camping -->
<div id="camping_fields" style="display:none;">
<div class="form-group">
<label><?echo $trad["Nombre d emplacements"] ?? '⚠️';?></label>
<input type="number" class="form-control" name="nb_emplacements" value="<?= $donnees_specifiques['nb_emplacements'] ?? '' ?>">
</div>
<div class="form-group">
<label><?echo $trad["Nombre de mobil-homes"] ?? '⚠️';?></label>
<input type="number" class="form-control" name="nb_mobilhome" value="<?= $donnees_specifiques['nb_mobilhome'] ?? '' ?>" >
</div>
<div class="form-group">
<label><?echo $trad["Nombre d étoiles"] ?? '⚠️';?></label>
<input type="number" class="form-control" name="etoiles_camping" min="0" max="5" value="<?= $donnees_specifiques['etoiles'] ?? '' ?>">
</div>
</div>
<div class="mb-5">
<?php
$prefix = strtoupper(substr($token, 0, 2));
$photo_path = "/upload/hebergement/$prefix/{$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="form-group row align-items-center">
<div class="col-lg-3">
<div class="custom-file">
<input type="file" class="custom-file-input" id="photoInput">
<label class="custom-file-label" for="photoInput">Choisir</label>
</div>
<input type="hidden" id="token" value="<?= $fiche->token ?>">
</div>
<div class="col-lg-3">
<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 class="col-xl-6" >
<div class="form-group">
<label><?echo $trad["Nom commercial"] ?? '⚠️';?></label>
<input type="text" class="form-control" name="nom_commercial" value="<?= htmlspecialchars($fiche->nom_commercial ?? '') ?>">
</div>
<div class="form-group">
<label><?echo $trad["Email pour les réservations"] ?? '⚠️';?></label>
<input type="email" class="form-control" name="email_reservation" value="<?= htmlspecialchars($fiche->email_reservation ?? '') ?>">
</div>
<div class="form-group">
<label><?echo $trad["Site web pour les réservations"] ?? '⚠️';?></label>
<input type="url" class="form-control" name="site_reservation" value="<?= htmlspecialchars($fiche->site_reservation ?? '') ?>">
</div>
<div class="form-group">
<label>Facebook</label>
<input type="url" class="form-control" name="facebook" value="<?= htmlspecialchars($fiche->facebook ?? '') ?>">
</div>
<div class="form-group">
<label>Instagram</label>
<input type="url" class="form-control" name="instagram" value="<?= htmlspecialchars($fiche->instagram ?? '') ?>">
</div>
<div class="form-group">
<label><?echo $trad["Fiche etablissement google"] ?? '⚠️';?></label>
<input type="url" class="form-control" name="location_link" value="<?= htmlspecialchars($fiche->location_link ?? '') ?>">
</div>
<div class="form-group">
<label><?echo $trad["Équipements disponibles"] ?? '⚠️';?></label>
<div class="checkbox-list">
<?php foreach ($liste_equipements as $eq): ?>
<label class="checkbox">
<input type="checkbox" name="equipements[]" value="<?= $eq ?>" <?= in_array($eq, $equipements ?? []) ? 'checked' : '' ?>><span></span><?echo $trad[$eq] ?? '⚠️';?>
</label>
<?php endforeach; ?>
</div>
</div>
<div class="form-group">
<label><?echo $trad["Activités sur place"] ?? '⚠️';?></label><br>
<div class="checkbox-list">
<?php foreach ($liste_activites as $act): ?>
<label class="checkbox">
<input type="checkbox" name="activites[]" value="<?= $act ?>" <?= in_array($act, $activites ?? []) ? 'checked' : '' ?>> <span></span><?echo $trad[$act] ?? '⚠️';?>
</label>
<?php endforeach; ?>
</div>
</div>
<div class="form-group">
<label><?echo $trad["Type de parking"] ?? '⚠️';?></label>
<select class="form-control" name="parking">
<option value="">-- <?echo $trad["Sélectionner"] ?? '⚠️';?> --</option>
<?php foreach ($options_parking as $value => $label): ?>
<option value="<?= $value ?>" <?= ($fiche->parking ?? '') === $value ? 'selected' : '' ?>>
<?echo $trad[$label] ?? '⚠️';?>
</option>
<?php endforeach; ?>
</select>
</div>
</div>
</div>
<div class="row mt-10">
<div class="col-6" >
<div class="mb-10">
<h4 class="mb-4">Photos supplémentaires</h4>
<?php if (!empty($photos_local)) { ?>
<div id="galeriePhotosLocal" class="d-flex flex-wrap">
<?php foreach ($photos_local as $photo) { ?>
<div class="photo-item" style="margin-right:10px; margin-bottom:10px; position:relative;" data-photo="<?php echo htmlspecialchars($photo); ?>">
<img
src="../../../upload/hebergement_multiple/<?php echo htmlspecialchars($photo); ?>?v=<?php echo uniqid(); ?>"
alt="Photo supplémentaire"
style="width:160px; height:120px; object-fit:cover; border-radius:6px; border:1px solid #ddd; display:block;"
>
<button
type="button"
class="btn btn-danger btn-sm supprimerPhotoBtn"
data-photo="<?php echo htmlspecialchars($photo); ?>"
style="position:absolute; top:5px; right:5px; padding:2px 8px; line-height:1;"
>
×
</button>
</div>
<?php } ?>
</div>
<?php } else { ?>
<p id="photosLocalMessage">Aucune photo supplémentaire pour le moment.</p>
<?php } ?>
</div>
<div class="form-group row align-items-center">
<div class="col-lg-4">
<div class="custom-file">
<input type="file" class="custom-file-input" id="photosMultipleInput" multiple accept=".jpg,.jpeg,image/jpeg">
<label class="custom-file-label" for="photosMultipleInput">Choisir une ou plusieurs photos</label>
</div>
</div>
<div class="col-lg-3">
<button type="button" class="btn btn-primary" id="uploadMultipleBtn">
<i class="fa fa-upload"></i> Uploader les photos
</button>
</div>
</div>
<div class="form-group">
<div id="uploadMultipleResult" class="text-success small mb-2"></div>
</div>
</div>
</div>
</div>
<div class="card-footer text-right ">
</div>
</div>
</div>
</div>
</form>
</div>
</div>
<!--end::Content-->
</div>
<!--begin::Footer-->
<!-- Charge l'API correctement -->
<script
src="https://maps.googleapis.com/maps/api/js?key=<?= htmlspecialchars($GOOGLE_FRONT_KEY) ?>&libraries=places&v=weekly&loading=async&callback=initMap"
async defer></script>
<?include("includes/footer.php");?>
<!--end::Footer-->
</div>
<!--end::Wrapper-->
</div>
<!--end::Page-->
</div>
<!--end::Main-->
<?include("includes/extrav2.php");?>
<script>
document.getElementById('type_hebergement').addEventListener('change', function () {
const type = this.value;
document.getElementById('hotel_fields').style.display = (type === 'hotel') ? 'block' : 'none';
document.getElementById('location_fields').style.display = (type === 'location') ? 'block' : 'none';
document.getElementById('camping_fields').style.display = (type === 'camping') ? 'block' : 'none';
});
window.addEventListener('DOMContentLoaded', function () {
document.getElementById('type_hebergement').dispatchEvent(new Event('change'));
});
</script>
<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
}
});
});
$('#photosMultipleInput').on('change', function () {
const files = this.files;
let label = 'Choisir une ou plusieurs photos';
if (files.length === 1) {
label = files[0].name;
} else if (files.length > 1) {
label = files.length + ' fichiers sélectionnés';
}
$(this).next('.custom-file-label').html(label);
});
$('#uploadMultipleBtn').on('click', function () {
const files = $('#photosMultipleInput')[0].files;
const token = $('#token').val();
if (!files.length || !token) {
alert('Merci de choisir au moins une photo avant l\'upload.');
return;
}
const formData = new FormData();
formData.append('token', token);
for (let i = 0; i < files.length; i++) {
formData.append('photos[]', files[i]);
}
showLoader();
$.ajax({
url: '../upload_photo_hebergement_multiple.php',
type: 'POST',
data: formData,
processData: false,
contentType: false,
dataType: 'json',
success: function (response) {
$('#uploadMultipleResult').html(response.message);
location.reload();
},
error: function () {
$('#uploadMultipleResult').html('Erreur lors de l\'upload des photos.');
},
complete: function () {
hideLoader();
}
});
});
$(document).on('click', '.supprimerPhotoBtn', function () {
const photo = $(this).data('photo');
const token = $('#token').val();
if (!photo || !token) {
alert('Paramètres manquants.');
return;
}
if (!confirm('Supprimer cette photo ?')) {
return;
}
showLoader();
$.ajax({
url: '../supprimer_photo_hebergement_multiple.php',
type: 'POST',
dataType: 'json',
data: {
token: token,
photo: photo
},
success: function (response) {
$('#uploadMultipleResult').html(response.message);
if (response.success) {
$('.photo-item[data-photo="' + photo.replace(/"/g, '\\"') + '"]').remove();
if ($('#galeriePhotosLocal .photo-item').length === 0) {
$('#galeriePhotosLocal').after('<p id="photosLocalMessage">Aucune photo supplémentaire pour le moment.</p>');
$('#galeriePhotosLocal').remove();
}
}
},
error: function () {
$('#uploadMultipleResult').html('Erreur lors de la suppression.');
},
complete: function () {
hideLoader();
}
});
});
<?if ($miseajour==1) {
$title=$trad["Mise à jour demandée"] ?? '⚠️';
$message=$trad["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><?echo $trad["Type de parking"] ?? '⚠️';?>