notes voyage
This commit is contained in:
@@ -280,7 +280,7 @@ function openCheckpointModal(mode, data = null) {
|
||||
searchBlock.style.display = "block";
|
||||
formBlock.style.display = "none";
|
||||
btnDel.style.display = "none";
|
||||
document.getElementById("cp_old_sort_order").value = ""; // Important : vide pour ajout
|
||||
document.getElementById("cp_old_sort_order").value = "";
|
||||
document.getElementById("cp_name").value = "";
|
||||
addCpExpenseLine();
|
||||
} else if (mode === "edit" && data) {
|
||||
@@ -291,14 +291,21 @@ function openCheckpointModal(mode, data = null) {
|
||||
|
||||
document.getElementById("cp_lat").value = data.lat;
|
||||
document.getElementById("cp_lng").value = data.lng;
|
||||
document.getElementById("cp_old_sort_order").value = data.sort_order; // On stocke l'index unique
|
||||
document.getElementById("cp_old_sort_order").value = data.sort_order;
|
||||
document.getElementById("cp_name").value = data.location_name;
|
||||
|
||||
if (data.items && data.items.length > 0) {
|
||||
let visibleCount = 0;
|
||||
data.items.forEach((it) => {
|
||||
if (it.name !== "PF_TECHNICAL_POINT") {
|
||||
addCpExpenseLine(it.category, it.name, it.amount, it.is_paid);
|
||||
// On passe it.notes à la fonction !
|
||||
addCpExpenseLine(
|
||||
it.category,
|
||||
it.name,
|
||||
it.amount,
|
||||
it.is_paid,
|
||||
it.notes || "",
|
||||
);
|
||||
visibleCount++;
|
||||
}
|
||||
});
|
||||
@@ -364,29 +371,39 @@ function addCpExpenseLine(
|
||||
name = "",
|
||||
amount = "",
|
||||
isPaid = 0,
|
||||
notes = "",
|
||||
) {
|
||||
const container = document.getElementById("cpExpensesContainer");
|
||||
const div = document.createElement("div");
|
||||
div.style.display = "flex";
|
||||
div.style.gap = "8px";
|
||||
div.style.alignItems = "center";
|
||||
div.style.flexDirection = "column";
|
||||
div.style.gap = "6px";
|
||||
div.style.padding = "10px";
|
||||
div.style.background = "#f8fafc";
|
||||
div.style.borderRadius = "8px";
|
||||
div.style.border = "1px solid #e2e8f0";
|
||||
|
||||
const isChecked = isPaid == 1 ? "checked" : "";
|
||||
|
||||
div.innerHTML = `
|
||||
<select name="items[cat][]" class="pf-input" style="width:50px; padding:8px 4px; font-size:1.2rem; cursor:pointer;" title="Catégorie">
|
||||
<option value="accommodation" ${category === "accommodation" ? "selected" : ""}>🏨</option>
|
||||
<option value="transport" ${category === "transport" ? "selected" : ""}>🚗</option>
|
||||
<option value="activity" ${category === "activity" ? "selected" : ""}>🎫</option>
|
||||
</select>
|
||||
<input type="text" name="items[name][]" class="pf-input" placeholder="Libellé (Optionnel)" value="${name}" style="flex:2; padding:8px; font-size:0.9rem;">
|
||||
<input type="number" step="0.01" name="items[amount][]" class="pf-input" placeholder="0.00" value="${amount}" style="width:80px; text-align:right; padding:8px; font-size:0.9rem;">
|
||||
<label title="Payé ?" style="display:flex; align-items:center; cursor:pointer;">
|
||||
<input type="checkbox" ${isChecked} onchange="this.nextElementSibling.value = this.checked ? 1 : 0" style="margin:0;">
|
||||
<input type="hidden" name="items[paid][]" value="${isPaid}">
|
||||
<span style="font-size:0.75rem; margin-left:2px; font-weight:bold; color:#64748b;">Payé</span>
|
||||
</label>
|
||||
<button type="button" onclick="this.parentElement.remove()" style="width:28px; height:28px; border:none; background:#fee2e2; color:#ef4444; border-radius:6px; cursor:pointer; font-weight:bold; display:flex; justify-content:center; align-items:center;">×</button>
|
||||
<div style="display:flex; gap:8px; align-items:center; width:100%;">
|
||||
<select name="items[cat][]" class="pf-input" style="width:50px; padding:8px 4px; font-size:1.2rem; cursor:pointer;" title="Catégorie">
|
||||
<option value="accommodation" ${category === "accommodation" ? "selected" : ""}>🏨</option>
|
||||
<option value="transport" ${category === "transport" ? "selected" : ""}>🚗</option>
|
||||
<option value="activity" ${category === "activity" ? "selected" : ""}>🎫</option>
|
||||
</select>
|
||||
<input type="text" name="items[name][]" class="pf-input" placeholder="Libellé (Optionnel)" value="${name}" style="flex:2; padding:8px; font-size:0.9rem;">
|
||||
<input type="number" step="0.01" name="items[amount][]" class="pf-input" placeholder="0.00" value="${amount}" style="width:80px; text-align:right; padding:8px; font-size:0.9rem;">
|
||||
|
||||
<label title="Payé ?" style="display:flex; align-items:center; cursor:pointer; width:55px;">
|
||||
<input type="checkbox" ${isChecked} onchange="this.nextElementSibling.value = this.checked ? 1 : 0" style="margin:0;">
|
||||
<input type="hidden" name="items[paid][]" value="${isPaid}">
|
||||
<span style="font-size:0.75rem; margin-left:4px; font-weight:bold; color:#64748b;">Payé</span>
|
||||
</label>
|
||||
|
||||
<button type="button" onclick="this.parentElement.parentElement.remove()" style="width:28px; height:28px; border:none; background:#fee2e2; color:#ef4444; border-radius:6px; cursor:pointer; font-weight:bold; display:flex; justify-content:center; align-items:center;">×</button>
|
||||
</div>
|
||||
<input type="text" name="items[notes][]" class="pf-input" placeholder="🔗 Lien de réservation ou adresse exacte..." value="${notes}" style="font-size:0.8rem; padding:6px 8px; border-style:dashed; color:#475569; width:calc(100% - 58px); margin-left:58px;">
|
||||
`;
|
||||
container.appendChild(div);
|
||||
}
|
||||
|
||||
@@ -35,8 +35,7 @@ if ($holiday_id > 0 && !empty($location_name)) {
|
||||
}
|
||||
|
||||
// 3. INSERTION DES LIGNES
|
||||
$stmt = $pdo->prepare("INSERT INTO pf_holidays_items (holiday_id, category, name, amount, is_paid, location_name, lat, lng, sort_order) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
$validItemsCount = 0;
|
||||
$stmt = $pdo->prepare("INSERT INTO pf_holidays_items (holiday_id, category, name, amount, is_paid, location_name, lat, lng, sort_order, notes) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); $validItemsCount = 0;
|
||||
|
||||
if (isset($_POST['items']['name'])) {
|
||||
foreach ($_POST['items']['name'] as $i => $raw_name) {
|
||||
@@ -45,15 +44,15 @@ if ($holiday_id > 0 && !empty($location_name)) {
|
||||
if ($name !== '' || $amount_raw !== '') {
|
||||
$cat = $_POST['items']['cat'][$i] ?? 'activity';
|
||||
$amount = (float)$amount_raw;
|
||||
$paid = isset($_POST['items']['paid'][$i]) ? 1 : 0;
|
||||
$stmt->execute([$holiday_id, $cat, $name ?: 'Dépense', $amount, $paid, $location_name, $lat, $lng, $target_order]);
|
||||
$validItemsCount++;
|
||||
$paid = (isset($_POST['items']['paid'][$i]) && (int)$_POST['items']['paid'][$i] === 1) ? 1 : 0;
|
||||
$note = trim($_POST['items']['notes'][$i] ?? '');
|
||||
$stmt->execute([$holiday_id, $cat, $name ?: 'Dépense', $amount, $paid, $location_name, $lat, $lng, $target_order, $note]); $validItemsCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($validItemsCount === 0) {
|
||||
$stmt->execute([$holiday_id, 'activity', 'PF_TECHNICAL_POINT', 0, 1, $location_name, $lat, $lng, $target_order]);
|
||||
$stmt->execute([$holiday_id, 'activity', 'PF_TECHNICAL_POINT', 0, 1, $location_name, $lat, $lng, $target_order, '']);
|
||||
}
|
||||
|
||||
// 4. GESTION DES FAVORIS
|
||||
|
||||
@@ -8,7 +8,10 @@ if ($id === 0) { echo "<div class='pf-section'><p>Erreur.</p></div>"; exit; }
|
||||
$stmt = $pdo->prepare("
|
||||
SELECT h.*,
|
||||
(COALESCE(h.budget_food, 0) + COALESCE(h.budget_extra, 0) + COALESCE((SELECT SUM(amount) FROM pf_holidays_items WHERE holiday_id = h.id), 0)) as total_cost,
|
||||
(SELECT COALESCE(SUM(ABS(amount)), 0) FROM pf_expenses WHERE holiday_id = h.id) as total_paid,
|
||||
(
|
||||
(SELECT COALESCE(SUM(ABS(amount)), 0) FROM pf_expenses WHERE holiday_id = h.id) +
|
||||
(SELECT COALESCE(SUM(amount), 0) FROM pf_holidays_items WHERE holiday_id = h.id AND is_paid = 1)
|
||||
) as total_paid,
|
||||
(SELECT COALESCE(SUM(amount), 0) FROM pf_savings WHERE holiday_id = h.id) as total_saved
|
||||
FROM pf_holidays h WHERE h.id = ?
|
||||
");
|
||||
@@ -151,12 +154,23 @@ $pctSaved = $cost > 0 ? min(100 - $pctPaid, ($saved / $cost) * 100) : 0;
|
||||
$visibleItemsCount++;
|
||||
$icon = match($it['category']) { 'transport' => '🚗', 'accommodation' => '🏨', 'activity' => '🎫', default => '🏷️' };
|
||||
?>
|
||||
<div class="hol-expense-line">
|
||||
<span style="color:#475569;"><?= $icon ?> <?= htmlspecialchars($it['name']) ?></span>
|
||||
<span>
|
||||
<strong style="color:var(--text-main);"><?= number_format($it['amount'], 2, ',', ' ') ?> €</strong>
|
||||
<span style="margin-left:5px; color:<?= $it['is_paid'] ? '#10b981' : '#f59e0b' ?>;"><?= $it['is_paid'] ? '✓' : '⏳' ?></span>
|
||||
</span>
|
||||
<div class="hol-expense-line" style="display:flex; flex-direction:column; align-items:flex-start; gap:4px;">
|
||||
<div style="display:flex; justify-content:space-between; width:100%;">
|
||||
<span style="color:#475569; font-weight:500;"><?= $icon ?> <?= htmlspecialchars($it['name']) ?></span>
|
||||
<span>
|
||||
<strong style="color:var(--text-main);"><?= number_format($it['amount'], 2, ',', ' ') ?> €</strong>
|
||||
<span style="margin-left:5px; color:<?= $it['is_paid'] ? '#10b981' : '#f59e0b' ?>;"><?= $it['is_paid'] ? '✓' : '⏳' ?></span>
|
||||
</span>
|
||||
</div>
|
||||
<?php if (!empty($it['notes'])): ?>
|
||||
<div style="font-size:0.75rem; color:#94a3b8; padding-left: 24px; word-break: break-all;">
|
||||
<?php if (filter_var($it['notes'], FILTER_VALIDATE_URL)): ?>
|
||||
🔗 <a href="<?= htmlspecialchars($it['notes']) ?>" target="_blank" style="color:#3b82f6; text-decoration:none;">Voir le lien</a>
|
||||
<?php else: ?>
|
||||
📝 <?= htmlspecialchars($it['notes']) ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
@@ -224,7 +238,7 @@ $pctSaved = $cost > 0 ? min(100 - $pctPaid, ($saved / $cost) * 100) : 0;
|
||||
<button type="button" class="pf-btn btn-secondary" onclick="addCpExpenseLine()" style="padding:4px 8px; font-size:0.8rem; height:auto; width:auto; margin:0;">+ Ajouter une dépense</button>
|
||||
</div>
|
||||
|
||||
<div id="cpExpensesContainer" style="margin-bottom:15px; display:flex; flex-direction:column; gap:10px; max-height:300px; overflow-y:auto;">
|
||||
<div id="cpExpensesContainer" style="margin-bottom:15px; display:flex; flex-direction:column; gap:10px; max-height:350px; overflow-y:auto; overflow-x:hidden;">
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 20px; padding-left: 5px;">
|
||||
|
||||
@@ -29,7 +29,10 @@ $sql = "
|
||||
COALESCE(h.budget_extra, 0) +
|
||||
COALESCE((SELECT SUM(amount) FROM pf_holidays_items WHERE holiday_id = h.id), 0)
|
||||
) as total_cost,
|
||||
(SELECT COALESCE(SUM(ABS(amount)), 0) FROM pf_expenses WHERE holiday_id = h.id) as total_paid,
|
||||
(
|
||||
(SELECT COALESCE(SUM(ABS(amount)), 0) FROM pf_expenses WHERE holiday_id = h.id) +
|
||||
(SELECT COALESCE(SUM(amount), 0) FROM pf_holidays_items WHERE holiday_id = h.id AND is_paid = 1)
|
||||
) as total_paid,
|
||||
(SELECT COALESCE(SUM(amount), 0) FROM pf_savings WHERE holiday_id = h.id) as total_saved
|
||||
FROM pf_holidays h
|
||||
$whereSQL
|
||||
|
||||
Reference in New Issue
Block a user