<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="description" content="Ogani Template">
<meta name="keywords" content="Ogani, unica, creative, html">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="{{asset('uploads/brochures/logo2_1.jpg')}}" rel="icon">
<title>
{{ title|raw }}
</title>
<!-- Google Font -->
<link
href="https://fonts.googleapis.com/css2?family=Cairo:wght@200;300;400;600;900&display=swap" rel="stylesheet">
<!-- Css Styles -->
<link rel="stylesheet" href="{{asset('ogani_master/css/bootstrap.min.css')}}" type="text/css">
<link rel="stylesheet" href="{{asset('ogani_master/css/font-awesome.min.css')}}" type="text/css">
<link rel="stylesheet" href="{{asset('ogani_master/css/elegant-icons.css')}}" type="text/css">
<link rel="stylesheet" href="{{asset('ogani_master/css/nice-select.css')}}" type="text/css">
<link rel="stylesheet" href="{{asset('ogani_master/css/jquery-ui.min.css')}}" type="text/css">
<link rel="stylesheet" href="{{asset('ogani_master/css/owl.carousel.min.css')}}" type="text/css">
<link rel="stylesheet" href="{{asset('ogani_master/css/slicknav.min.css')}}" type="text/css">
<link
rel="stylesheet" href="{{asset('ogani_master/css/style.css')}}" type="text/css">
<!-- Template Main CSS File -->
<link href="{{asset('Nice-Admin-master/assets/libs/datatables.net-bs4/css/dataTables.bootstrap4.css')}}" rel="stylesheet">
<link href="{{asset('NiceAdmin/assets/vendor/bootstrap-icons/bootstrap-icons.css')}}" rel="stylesheet">
</head>
<body>
<!-- ======= Header ======= -->
{{ include('Header.html.twig') }}
<!-- ======= Body ======= -->
{{ include('Body-panier.html.twig') }}
<!-- ======= Footer ======= -->
{{ include('Footer.html.twig') }}
{% block body %}{% endblock %}
<!-- Js Plugins -->
<script src="{{asset('ogani_master/js/jquery-3.3.1.min.js')}}"></script>
<script src="{{asset('ogani_master/js/bootstrap.min.js')}}"></script>
<script src="{{asset('ogani_master/js/jquery.nice-select.min.js')}}"></script>
<script src="{{asset('ogani_master/js/jquery-ui.min.js')}}"></script>
<script src="{{asset('ogani_master/js/jquery.slicknav.js')}}"></script>
<script src="{{asset('ogani_master/js/mixitup.min.js')}}"></script>
<script src="{{asset('ogani_master/js/owl.carousel.min.js')}}"></script>
<script src="{{asset('ogani_master/js/main.js')}}"></script>
<script src="{{asset('NiceAdmin/assets/vendor/simple-datatables/simple-datatables.js')}}"></script>
<script src="{{asset('Nice-Admin-master/assets/extra-libs/DataTables/datatables.min.js')}}"></script>
{% if not app.user %}
<script>
(function () {
const PHOTON_BASE_URL = 'https://photon.komoot.io/api/';
const NOMINATIM_BASE_URL = 'https://nominatim.openstreetmap.org/search';
const DEFAULT_SEARCH_LIMIT = 8;
const POI_SEARCH_LIMIT = 12;
const DEBOUNCE_DELAY = 300;
const REQUEST_TIMEOUT_MS = 6000;
const IVORY_COAST_LABEL = "Côte d'Ivoire";
const IVORY_COAST_CODE = 'CI';
const POI_KEYWORDS = ['mairie', 'hotel de ville', 'hôtel de ville', 'eglise', 'église', 'mosquee', 'mosquée', 'marche', 'marché', 'pharmacie', 'hopital', 'hôpital', 'gare', 'station', 'universite', 'université', 'banque'];
let activeRequestId = 0;
let debounceTimer = null;
function debounce(fn, wait) {
return function () {
var args = arguments;
var context = this;
clearTimeout(debounceTimer);
debounceTimer = setTimeout(function () {
fn.apply(context, args);
}, wait);
};
}
function buildUrl(baseUrl, params) {
return baseUrl + '?' + new URLSearchParams(params).toString();
}
function fetchWithTimeout(url, options, timeoutMs) {
var controller = new AbortController();
var timeoutId = setTimeout(function () {
controller.abort();
}, timeoutMs);
var fetchOptions = Object.assign({}, options || {}, { signal: controller.signal });
return fetch(url, fetchOptions).finally(function () {
clearTimeout(timeoutId);
});
}
function setFeedback(feedbackEl, message, level) {
if (!feedbackEl) return;
feedbackEl.textContent = message || '';
feedbackEl.classList.remove('d-none', 'text-muted', 'text-danger', 'text-success');
feedbackEl.classList.add(level || 'text-muted');
if (!message) feedbackEl.classList.add('d-none');
}
function normalize(value) {
return (value || '')
.toString()
.normalize('NFD')
.replace(/[\u0300-\u036f]/g, '')
.replace(/[^a-zA-Z0-9]+/g, ' ')
.replace(/\s+/g, ' ')
.trim()
.toLowerCase();
}
function isIvoryCoast(countryCode, countryName) {
var normalizedCode = normalize(countryCode);
var normalizedName = normalize(countryName);
return normalizedCode === 'ci' || normalizedName === 'cote d ivoire' || normalizedName === 'ivory coast';
}
function clearHiddenFields(latEl, lngEl, stateEl, countryEl, countryCodeEl) {
if (latEl) latEl.value = '';
if (lngEl) lngEl.value = '';
if (stateEl) stateEl.value = '';
if (countryEl) countryEl.value = '';
if (countryCodeEl) countryCodeEl.value = '';
}
function isPoiQuery(q) {
var raw = (q || '').toString().toLowerCase();
return POI_KEYWORDS.some(function (keyword) {
return raw.indexOf(keyword) !== -1;
});
}
function buildLabelPoi(properties) {
var name = (properties && properties.name ? properties.name : '').trim();
var street = (properties && properties.street ? properties.street : '').trim();
var houseNumber = (properties && properties.housenumber ? properties.housenumber : '').trim();
var city = (properties && (properties.city || properties.county) ? (properties.city || properties.county) : '').trim();
var main = name;
if (!main) {
main = [houseNumber, street].filter(Boolean).join(' ').trim() || street || city;
}
if (!main) return '';
if (city && normalize(main) !== normalize(city)) {
return main + ', ' + city + ', ' + IVORY_COAST_LABEL;
}
return main + ', ' + IVORY_COAST_LABEL;
}
function buildLabelAdmin(properties) {
var place = (
(properties && properties.district) ||
(properties && properties.suburb) ||
(properties && properties.neighbourhood) ||
(properties && properties.locality) ||
(properties && properties.city) ||
(properties && properties.name) ||
''
).trim();
var city = (
(properties && properties.city) ||
(properties && properties.county) ||
''
).trim();
if (!place) return '';
if (normalize(place) !== normalize(city)) {
return place + (city ? ', ' + city : '') + ', ' + IVORY_COAST_LABEL;
}
return place + ', ' + IVORY_COAST_LABEL;
}
function buildLabelFromPlace(place, city) {
var safePlace = (place || '').trim();
var safeCity = (city || '').trim();
if (!safePlace) return '';
if (normalize(safePlace) !== normalize(safeCity)) {
return safePlace + (safeCity ? ', ' + safeCity : '') + ', ' + IVORY_COAST_LABEL;
}
return safePlace + ', ' + IVORY_COAST_LABEL;
}
function buildLabel(item) {
if (!item) return '';
return item.label || buildLabelFromPlace(item.place, item.city);
}
function extractSignificantQuery(query) {
var words = normalize(query).split(' ').filter(Boolean);
var poiWords = POI_KEYWORDS.map(function (k) { return normalize(k); });
var stopwords = ['de', 'du', 'des', 'la', 'le', 'les', 'd'];
var filtered = words.filter(function (word) {
return poiWords.indexOf(word) === -1 && stopwords.indexOf(word) === -1;
});
return filtered.join(' ').trim();
}
function isPoiFeature(properties) {
var osmKey = normalize(properties && properties.osm_key);
var osmValue = normalize(properties && properties.osm_value);
var poiKeys = ['amenity', 'office', 'building', 'shop', 'tourism', 'leisure', 'healthcare', 'public transport', 'railway'];
var poiValues = ['townhall', 'pharmacy', 'hospital', 'clinic', 'place of worship', 'church', 'mosque', 'marketplace', 'university', 'bank', 'station'];
var keyMatch = poiKeys.indexOf(osmKey) !== -1;
var valueMatch = poiValues.some(function (value) { return osmValue.indexOf(value) !== -1; });
return keyMatch || valueMatch;
}
function rankPoi(item, query) {
var normalizedQuery = normalize(query);
var significant = extractSignificantQuery(query);
var normalizedName = normalize(item && item.name ? item.name : '');
var normalizedLabel = normalize(item && item.label ? item.label : '');
var score = 0;
if (normalizedName.indexOf('mairie') !== -1) score += 200;
if (normalizedName.indexOf('cocody') !== -1 || (significant && normalizedName.indexOf(significant) !== -1)) score += 150;
if (normalizedQuery && normalizedName.indexOf(normalizedQuery) !== -1) score += 100;
if (normalizedLabel.indexOf('vieux') !== -1) score -= 80;
return score;
}
function rankAdmin(item, query) {
var normalizedQuery = normalize(query);
var normalizedLabel = normalize(item && item.label ? item.label : '');
var score = 0;
if (normalizedQuery && normalizedLabel.indexOf(normalizedQuery) !== -1) score += 100;
if (item && item.place && item.city && normalize(item.place) !== normalize(item.city)) score += 20;
if (normalize(item && item.place) === 'abidjan' && normalizedQuery && normalizedQuery !== 'abidjan') score -= 40;
return score;
}
function dedupe(items) {
var seenLabels = new Set();
var deduped = [];
(items || []).forEach(function (item) {
var label = buildLabel(item);
if (!label) return;
var normalizedLabel = normalize(label);
if (seenLabels.has(normalizedLabel)) return;
seenLabels.add(normalizedLabel);
item.label = label;
deduped.push(item);
});
return deduped;
}
function mapPhotonFeatures(features, query) {
var poiMode = isPoiQuery(query);
return (features || []).map(function (feature) {
var properties = feature && feature.properties ? feature.properties : {};
if (!isIvoryCoast(properties.countrycode, properties.country)) return null;
var coords = feature && feature.geometry && feature.geometry.coordinates ? feature.geometry.coordinates : [];
var hasName = !!(properties.name || '').trim();
var place = properties.district || properties.suburb || properties.neighbourhood || properties.locality || properties.city || properties.name || '';
var city = properties.city || properties.county || '';
var label = poiMode ? buildLabelPoi(properties) : buildLabelAdmin(properties);
if (!label) return null;
if (poiMode) {
if (!hasName) return null;
if (!isPoiFeature(properties) && POI_KEYWORDS.every(function (word) { return normalize(properties.name).indexOf(normalize(word)) === -1; })) return null;
} else {
if (isPoiFeature(properties)) return null;
}
return {
name: properties.name || '',
place: place,
city: city,
label: label,
score: poiMode ? rankPoi({ name: properties.name || '', label: label }, query) : rankAdmin({ place: place, city: city, label: label }, query),
state: properties.state || properties.county || '',
country: IVORY_COAST_LABEL,
countrycode: IVORY_COAST_CODE,
lng: typeof coords[0] === 'number' ? coords[0] : null,
lat: typeof coords[1] === 'number' ? coords[1] : null
};
}).filter(Boolean).sort(function (a, b) {
if (b.score !== a.score) return b.score - a.score;
return normalize(a.label).localeCompare(normalize(b.label), 'fr');
});
}
function mapNominatimItems(items, query) {
var poiMode = isPoiQuery(query);
return (items || []).map(function (item) {
var address = item && item.address ? item.address : {};
if (!isIvoryCoast(address.country_code, address.country)) return null;
var pseudoProperties = {
name: address.amenity || address.building || address.shop || '',
street: address.road || '',
housenumber: address.house_number || '',
city: address.city || address.town || address.village || '',
county: address.county || '',
district: address.city_district || '',
suburb: address.suburb || '',
neighbourhood: address.neighbourhood || '',
locality: address.quarter || ''
};
var place = pseudoProperties.district || pseudoProperties.suburb || pseudoProperties.neighbourhood || pseudoProperties.locality || pseudoProperties.city || pseudoProperties.name || '';
var city = pseudoProperties.city || pseudoProperties.county || '';
var label = poiMode ? buildLabelPoi(pseudoProperties) : buildLabelAdmin(pseudoProperties);
if (!label) return null;
if (poiMode && !pseudoProperties.name) return null;
if (!poiMode && pseudoProperties.name) return null;
var lat = parseFloat(item.lat);
var lng = parseFloat(item.lon);
return {
name: pseudoProperties.name,
place: place,
city: city,
label: label,
score: poiMode ? rankPoi({ name: pseudoProperties.name, label: label }, query) : rankAdmin({ place: place, city: city, label: label }, query),
state: address.state || address.county || '',
country: IVORY_COAST_LABEL,
countrycode: IVORY_COAST_CODE,
lat: Number.isFinite(lat) ? lat : null,
lng: Number.isFinite(lng) ? lng : null
};
}).filter(Boolean).sort(function (a, b) {
if (b.score !== a.score) return b.score - a.score;
return normalize(a.label).localeCompare(normalize(b.label), 'fr');
});
}
function renderSuggestions(suggestionsEl, inputEl, results, onSelect) {
suggestionsEl.innerHTML = '';
if (!results.length) {
suggestionsEl.classList.add('d-none');
inputEl.setAttribute('aria-expanded', 'false');
return;
}
results.forEach(function (item, index) {
var option = document.createElement('button');
option.type = 'button';
option.className = 'commune-suggestion-item';
option.setAttribute('role', 'option');
option.setAttribute('data-index', String(index));
option.textContent = buildLabel(item);
option.addEventListener('click', function () { onSelect(item); });
suggestionsEl.appendChild(option);
});
suggestionsEl.classList.remove('d-none');
inputEl.setAttribute('aria-expanded', 'true');
}
function fetchPhotonSuggestions(query) {
var limit = isPoiQuery(query) ? POI_SEARCH_LIMIT : DEFAULT_SEARCH_LIMIT;
var url = buildUrl(PHOTON_BASE_URL, { q: query, limit: String(limit), lang: 'fr', countrycode: 'ci' });
return fetchWithTimeout(url, {}, REQUEST_TIMEOUT_MS)
.then(function (response) {
if (!response.ok) {
var httpErr = new Error('Photon HTTP error');
httpErr.status = response.status;
httpErr.statusText = response.statusText;
httpErr.url = url;
throw httpErr;
}
return response.json();
})
.then(function (data) {
return dedupe(mapPhotonFeatures(data && data.features ? data.features : [], query));
})
.catch(function (err) {
console.error('[CommuneAutocomplete] Photon error', {
status: err && err.status ? err.status : null,
statusText: err && err.statusText ? err.statusText : null,
url: err && err.url ? err.url : url,
err: err
});
throw err;
});
}
function fetchNominatimSuggestions(query) {
var limit = isPoiQuery(query) ? POI_SEARCH_LIMIT : DEFAULT_SEARCH_LIMIT;
var url = buildUrl(NOMINATIM_BASE_URL, { format: 'json', q: query, addressdetails: '1', limit: String(limit), countrycodes: 'ci', 'accept-language': 'fr' });
return fetchWithTimeout(url, {}, REQUEST_TIMEOUT_MS)
.then(function (response) {
if (!response.ok) {
var httpErr = new Error('Nominatim HTTP error');
httpErr.status = response.status;
httpErr.statusText = response.statusText;
httpErr.url = url;
throw httpErr;
}
return response.json();
})
.then(function (items) {
return dedupe(mapNominatimItems(items, query));
})
.catch(function (err) {
console.error('[CommuneAutocomplete] Nominatim error', {
status: err && err.status ? err.status : null,
statusText: err && err.statusText ? err.statusText : null,
url: err && err.url ? err.url : url,
err: err
});
throw err;
});
}
document.addEventListener('DOMContentLoaded', function () {
var btn = document.getElementById('btn-commander-invite');
var section = document.getElementById('section-checkout-invite');
if (!btn || !section) return;
var inputEl = document.getElementById('commune');
var suggestionsEl = document.getElementById('commune-suggestions');
var feedbackEl = document.getElementById('commune-feedback');
var alertEl = document.getElementById('places-alert');
var latEl = document.getElementById('commune_lat');
var lngEl = document.getElementById('commune_lng');
var stateEl = document.getElementById('commune_state');
var countryEl = document.getElementById('commune_country');
var countryCodeEl = document.getElementById('commune_countrycode');
var form = document.querySelector('form[data-guest-checkout="1"]');
if (!inputEl || !suggestionsEl || !form) return;
function closeSuggestions() {
suggestionsEl.classList.add('d-none');
inputEl.setAttribute('aria-expanded', 'false');
}
function selectSuggestion(item) {
inputEl.value = buildLabel(item);
if (latEl) latEl.value = item.lat !== null ? String(item.lat) : '';
if (lngEl) lngEl.value = item.lng !== null ? String(item.lng) : '';
if (stateEl) stateEl.value = item.state || '';
if (countryEl) countryEl.value = IVORY_COAST_LABEL;
if (countryCodeEl) countryCodeEl.value = IVORY_COAST_CODE;
setFeedback(feedbackEl, 'Commune sélectionnée.', 'text-success');
if (alertEl) alertEl.classList.add('d-none');
closeSuggestions();
}
var fetchSuggestions = debounce(function (query) {
if (query.length < 2) {
closeSuggestions();
setFeedback(feedbackEl, '', 'text-muted');
return;
}
var requestId = ++activeRequestId;
setFeedback(feedbackEl, 'Recherche...', 'text-muted');
if (alertEl) alertEl.classList.add('d-none');
fetchPhotonSuggestions(query)
.catch(function () { return fetchNominatimSuggestions(query); })
.then(function (results) {
if (requestId !== activeRequestId) return;
renderSuggestions(suggestionsEl, inputEl, results, selectSuggestion);
if (results.length) {
setFeedback(feedbackEl, '', 'text-muted');
} else {
setFeedback(feedbackEl, "Aucun résultat en Côte d'Ivoire.", 'text-muted');
}
})
.catch(function () {
if (requestId !== activeRequestId) return;
closeSuggestions();
setFeedback(feedbackEl, 'Erreur réseau. Veuillez réessayer.', 'text-danger');
if (alertEl) {
alertEl.textContent = "Le service de suggestions est indisponible. Vous pouvez saisir la commune manuellement.";
alertEl.classList.remove('d-none');
}
});
}, DEBOUNCE_DELAY);
inputEl.addEventListener('input', function (event) {
clearHiddenFields(latEl, lngEl, stateEl, countryEl, countryCodeEl);
setFeedback(feedbackEl, '', 'text-muted');
fetchSuggestions((event.target.value || '').trim());
});
document.addEventListener('click', function (event) {
if (!event.target.closest('.commune-autocomplete')) {
closeSuggestions();
}
});
btn.addEventListener('click', function () {
section.classList.toggle('d-none');
if (!section.classList.contains('d-none')) {
inputEl.focus();
}
});
form.addEventListener('submit', function (e) {
var value = (inputEl.value || '').trim();
if (value.length < 2) {
e.preventDefault();
setFeedback(feedbackEl, 'La commune est obligatoire.', 'text-danger');
inputEl.focus();
}
});
});
})();
</script>
{% endif %}
<style>
.cart-page {
background: #f8fafb;
}
.cart-card {
border-radius: 1rem;
}
.cart-table thead tr {
background: #f9fafb;
border-bottom: 1px solid #e9ecef;
}
.cart-table th,
.cart-table td {
vertical-align: middle;
}
.cart-table tbody tr:hover {
background-color: #f5f7fb;
}
.empty-cart-icon i {
opacity: 0.6;
}
.commune-autocomplete {
position: relative;
}
.commune-suggestions {
position: absolute;
top: calc(100% + 4px);
left: 0;
right: 0;
max-height: 240px;
overflow-y: auto;
background: #fff;
border: 1px solid #dee2e6;
border-radius: .375rem;
box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
z-index: 20;
}
.commune-suggestion-item {
display: block;
width: 100%;
padding: .5rem .75rem;
border: 0;
background: transparent;
text-align: left;
font-size: .95rem;
cursor: pointer;
}
.commune-suggestion-item:hover,
.commune-suggestion-item:focus {
background: #f3f7ff;
}
</style>
</body>
</html>