return
This commit is contained in:
@@ -331,25 +331,31 @@ function initDetailMap() {
|
|||||||
routePromises.push(promise);
|
routePromises.push(promise);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. On attend que TOUTES les routes soient calculées pour les dessiner dans le bon ordre
|
// 2. On attend que TOUTES les routes soient calculées
|
||||||
Promise.all(routePromises).then((results) => {
|
Promise.all(routePromises).then((results) => {
|
||||||
// On s'assure de dessiner l'Étape 1 d'abord, puis la 2, etc.
|
|
||||||
results.sort((a, b) => a.index - b.index);
|
results.sort((a, b) => a.index - b.index);
|
||||||
|
|
||||||
|
// NOUVEAU : On cherche quelle étape a été marquée "Retour"
|
||||||
|
let returnStartIndex = latlngs.length - 2; // Par défaut : le tout dernier segment
|
||||||
|
const customReturnStep = MAP_POINTS.findIndex((p) => p.is_return == 1);
|
||||||
|
if (customReturnStep > 0) {
|
||||||
|
// Si trouvé (et que ce n'est pas le point de départ)
|
||||||
|
returnStartIndex = customReturnStep;
|
||||||
|
}
|
||||||
|
|
||||||
results.forEach((res) => {
|
results.forEach((res) => {
|
||||||
const i = res.index;
|
const i = res.index;
|
||||||
|
|
||||||
// Styles par défaut (Aller / Étape 1)
|
let routeColor = "#3b82f6"; // Bleu (Aller)
|
||||||
let routeColor = "#3b82f6"; // Bleu
|
let routeWeight = 6;
|
||||||
let routeWeight = 6; // Épais
|
let routeDash = null;
|
||||||
let routeDash = null; // Ligne continue
|
|
||||||
|
|
||||||
// Modification des styles selon le segment
|
// Application de la bonne couleur
|
||||||
if (i === latlngs.length - 2) {
|
if (i >= returnStartIndex) {
|
||||||
// DERNIER SEGMENT (Retour)
|
// TOUS LES SEGMENTS DEPUIS L'ÉTAPE "RETOUR"
|
||||||
routeColor = "#f97316"; // Orange vif (Tranche parfaitement avec le bleu)
|
routeColor = "#f97316"; // Orange
|
||||||
routeWeight = 3; // Plus fin pour se superposer sans cacher
|
routeWeight = 3;
|
||||||
routeDash = "10, 10"; // En pointillés pour laisser voir le bleu en dessous
|
routeDash = "10, 10";
|
||||||
} else if (i > 0) {
|
} else if (i > 0) {
|
||||||
// SEGMENTS INTERMÉDIAIRES
|
// SEGMENTS INTERMÉDIAIRES
|
||||||
routeColor = "#8b5cf6"; // Violet
|
routeColor = "#8b5cf6"; // Violet
|
||||||
@@ -420,6 +426,7 @@ function openCheckpointModal(mode, data = null) {
|
|||||||
document.getElementById("cp_old_sort_order").value = "";
|
document.getElementById("cp_old_sort_order").value = "";
|
||||||
document.getElementById("cp_name").value = "";
|
document.getElementById("cp_name").value = "";
|
||||||
addCpExpenseLine();
|
addCpExpenseLine();
|
||||||
|
document.getElementById("cp_is_return").checked = false;
|
||||||
} else if (mode === "edit" && data) {
|
} else if (mode === "edit" && data) {
|
||||||
document.getElementById("cpModalTitle").innerText = "✏️ Modifier l'étape";
|
document.getElementById("cpModalTitle").innerText = "✏️ Modifier l'étape";
|
||||||
searchBlock.style.display = "none";
|
searchBlock.style.display = "none";
|
||||||
@@ -432,6 +439,7 @@ function openCheckpointModal(mode, data = null) {
|
|||||||
document.getElementById("cp_name").value = data.location_name;
|
document.getElementById("cp_name").value = data.location_name;
|
||||||
document.getElementById("cp_start_date").value = data.step_start_date || "";
|
document.getElementById("cp_start_date").value = data.step_start_date || "";
|
||||||
document.getElementById("cp_end_date").value = data.step_end_date || "";
|
document.getElementById("cp_end_date").value = data.step_end_date || "";
|
||||||
|
document.getElementById("cp_is_return").checked = data.is_return == 1;
|
||||||
|
|
||||||
if (data.items && data.items.length > 0) {
|
if (data.items && data.items.length > 0) {
|
||||||
let visibleCount = 0;
|
let visibleCount = 0;
|
||||||
|
|||||||
@@ -56,10 +56,10 @@ if ($holiday_id > 0 && !empty($location_name)) {
|
|||||||
// Récupération des dates de l'étape globale
|
// Récupération des dates de l'étape globale
|
||||||
$step_start = !empty($_POST['step_start_date']) ? $_POST['step_start_date'] : null;
|
$step_start = !empty($_POST['step_start_date']) ? $_POST['step_start_date'] : null;
|
||||||
$step_end = !empty($_POST['step_end_date']) ? $_POST['step_end_date'] : null;
|
$step_end = !empty($_POST['step_end_date']) ? $_POST['step_end_date'] : null;
|
||||||
|
$is_return = isset($_POST['is_return']) ? 1 : 0; // NOUVEAU
|
||||||
|
|
||||||
// 3. INSERTION DES LIGNES
|
// 3. INSERTION DES LIGNES (16 Colonnes)
|
||||||
// Il doit y avoir EXACTEMENT 15 colonnes et 15 points d'interrogation (?)
|
$stmt = $pdo->prepare("INSERT INTO pf_holidays_items (holiday_id, category, name, amount, is_paid, location_name, lat, lng, sort_order, notes, item_date, item_time, step_start_date, step_end_date, duration, is_return) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||||
$stmt = $pdo->prepare("INSERT INTO pf_holidays_items (holiday_id, category, name, amount, is_paid, location_name, lat, lng, sort_order, notes, item_date, item_time, step_start_date, step_end_date, duration) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
|
||||||
$validItemsCount = 0;
|
$validItemsCount = 0;
|
||||||
|
|
||||||
if (isset($_POST['items']['name'])) {
|
if (isset($_POST['items']['name'])) {
|
||||||
@@ -72,21 +72,19 @@ if ($holiday_id > 0 && !empty($location_name)) {
|
|||||||
$paid = (isset($_POST['items']['paid'][$i]) && (int)$_POST['items']['paid'][$i] === 1) ? 1 : 0;
|
$paid = (isset($_POST['items']['paid'][$i]) && (int)$_POST['items']['paid'][$i] === 1) ? 1 : 0;
|
||||||
$note = trim($_POST['items']['notes'][$i] ?? '');
|
$note = trim($_POST['items']['notes'][$i] ?? '');
|
||||||
|
|
||||||
// Récupération des données invisibles
|
|
||||||
$date = !empty($_POST['items']['date'][$i]) ? $_POST['items']['date'][$i] : null;
|
$date = !empty($_POST['items']['date'][$i]) ? $_POST['items']['date'][$i] : null;
|
||||||
$time = !empty($_POST['items']['time'][$i]) ? $_POST['items']['time'][$i] : null;
|
$time = !empty($_POST['items']['time'][$i]) ? $_POST['items']['time'][$i] : null;
|
||||||
$dur = !empty($_POST['items']['duration'][$i]) ? (int)$_POST['items']['duration'][$i] : 1;
|
$dur = !empty($_POST['items']['duration'][$i]) ? (int)$_POST['items']['duration'][$i] : 1;
|
||||||
|
|
||||||
// Les 15 variables passées au tableau doivent correspondre aux 15 points d'interrogation
|
// Ajout de $is_return à la fin
|
||||||
$stmt->execute([$holiday_id, $cat, $name ?: 'Dépense', $amount, $paid, $location_name, $lat, $lng, $target_order, $note, $date, $time, $step_start, $step_end, $dur]);
|
$stmt->execute([$holiday_id, $cat, $name ?: 'Dépense', $amount, $paid, $location_name, $lat, $lng, $target_order, $note, $date, $time, $step_start, $step_end, $dur, $is_return]);
|
||||||
$validItemsCount++;
|
$validItemsCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si l'étape est vide, on enregistre quand même ses dates
|
|
||||||
if ($validItemsCount === 0) {
|
if ($validItemsCount === 0) {
|
||||||
$stmt->execute([$holiday_id, 'activity', 'PF_TECHNICAL_POINT', 0, 1, $location_name, $lat, $lng, $target_order, '', null, null, $step_start, $step_end, 1]);
|
$stmt->execute([$holiday_id, 'activity', 'PF_TECHNICAL_POINT', 0, 1, $location_name, $lat, $lng, $target_order, '', null, null, $step_start, $step_end, 1, $is_return]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. GESTION DES FAVORIS
|
// 4. GESTION DES FAVORIS
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ foreach ($items as $it) {
|
|||||||
'sort_order' => $it['sort_order'],
|
'sort_order' => $it['sort_order'],
|
||||||
'step_start_date' => $it['step_start_date'],
|
'step_start_date' => $it['step_start_date'],
|
||||||
'step_end_date' => $it['step_end_date'],
|
'step_end_date' => $it['step_end_date'],
|
||||||
|
'is_return' => (int)$it['is_return'],
|
||||||
'total_amount' => 0,
|
'total_amount' => 0,
|
||||||
'items' => []
|
'items' => []
|
||||||
];
|
];
|
||||||
@@ -151,6 +152,9 @@ $pctSaved = $cost > 0 ? min(100 - $pctPaid, ($saved / $cost) * 100) : 0;
|
|||||||
<span style="color:#94a3b8; font-size:1.1rem; cursor:grab; user-select:none;">☰</span>
|
<span style="color:#94a3b8; font-size:1.1rem; cursor:grab; user-select:none;">☰</span>
|
||||||
<div class="hol-cp-title" onclick="panMapTo(<?= $step['lat'] ?>, <?= $step['lng'] ?>)" title="<?= htmlspecialchars($step['location_name']) ?>">
|
<div class="hol-cp-title" onclick="panMapTo(<?= $step['lat'] ?>, <?= $step['lng'] ?>)" title="<?= htmlspecialchars($step['location_name']) ?>">
|
||||||
📍 <?= htmlspecialchars($step['location_name']) ?>
|
📍 <?= htmlspecialchars($step['location_name']) ?>
|
||||||
|
<?php if (!empty($step['is_return'])): ?>
|
||||||
|
<span style="background: #fff7ed; color: #ea580c; padding: 2px 6px; border-radius: 4px; font-size: 0.7rem; font-weight: bold; margin-left: 5px; border: 1px solid #ffedd5; vertical-align: middle;">🏁 Retour</span>
|
||||||
|
<?php endif; ?>
|
||||||
<?php if (!empty($step['step_start_date']) && !empty($step['step_end_date'])): ?>
|
<?php if (!empty($step['step_start_date']) && !empty($step['step_end_date'])): ?>
|
||||||
<div style="font-size:0.75rem; color:#64748b; font-weight:normal; margin-top:2px;">
|
<div style="font-size:0.75rem; color:#64748b; font-weight:normal; margin-top:2px;">
|
||||||
Du <?= date('d/m', strtotime($step['step_start_date'])) ?> au <?= date('d/m', strtotime($step['step_end_date'])) ?>
|
Du <?= date('d/m', strtotime($step['step_start_date'])) ?> au <?= date('d/m', strtotime($step['step_end_date'])) ?>
|
||||||
@@ -252,6 +256,12 @@ $pctSaved = $cost > 0 ? min(100 - $pctPaid, ($saved / $cost) * 100) : 0;
|
|||||||
<label class="pf-label">Départ le (Optionnel)</label>
|
<label class="pf-label">Départ le (Optionnel)</label>
|
||||||
<input type="date" name="step_end_date" id="cp_end_date" class="pf-input">
|
<input type="date" name="step_end_date" id="cp_end_date" class="pf-input">
|
||||||
</div>
|
</div>
|
||||||
|
<div style="margin-bottom: 15px; padding-left: 5px;">
|
||||||
|
<label style="display:flex; align-items:center; cursor:pointer; font-size:0.9rem; color:#d97706; font-weight:600;">
|
||||||
|
<input type="checkbox" name="is_return" id="cp_is_return" value="1" style="margin-right:8px; width:16px; height:16px;">
|
||||||
|
🏁 Trajet retour
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:10px;">
|
<div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:10px;">
|
||||||
|
|||||||
Reference in New Issue
Block a user