export function createItinerary() { if (!document.getElementById('case-filter').value) { return; } let date = document.getElementById('date'); date.value = new Date().toLocaleDateString(); let btn = document.getElementById('create-itinerary'); btn.setAttribute('data-bs-toggle', 'modal'); btn.setAttribute('data-bs-target', '#exampleModalMessage'); btn.click(); } export function addLocationToItinerary() { let date = document.getElementById('date').value; let origin = document.getElementById('origin').value; let destination = document.getElementById('destination').value; let departure = document.getElementById('departure').value; let arrival = document.getElementById('arrival').value; let caseMileage = document.getElementById('case-mileage').checked; let caseId = document.getElementById('case-filter').value; fetch('/index.php/api/add-location-to-itinerary', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ date: date, origin: origin, destination: destination, departure: departure, arrival: arrival, caseMileage: caseMileage, caseId: caseId }) }) .then(response => response.json()) .then(data => { if (data.success === true) { $('#close-modal').click(); } }); } export function openMap() { if (!document.getElementById('case-filter').value || !document.getElementById('date-filter').value) { return false; } document.getElementById('caseId').value = document.getElementById('case-filter').value; document.getElementById('caseDate').value = document.getElementById('date-filter').value; document.getElementById('map-form').submit(); }