- Set up PHP application with Composer and JWT library - Implemented SSO authentication with local dev mode - Created Box API service for folder validation - Built two-column form interface (form + preview) - Added real-time Box ID validation with AJAX - Integrated webhook submission with status response - Auto-populate Master Campaign Number from Box folder hierarchy - Responsive design with Montserrat font and black/yellow theme 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
224 lines
7 KiB
HTML
224 lines
7 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Date Form</title>
|
|
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;700&display=swap" rel="stylesheet">
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: 'Montserrat', sans-serif;
|
|
background-color: #000000;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
min-height: 100vh;
|
|
padding: 20px;
|
|
}
|
|
|
|
.container {
|
|
background-color: #ffffff;
|
|
padding: 40px;
|
|
border-radius: 10px;
|
|
box-shadow: 0 4px 6px rgba(255, 196, 7, 0.3);
|
|
max-width: 500px;
|
|
width: 100%;
|
|
}
|
|
|
|
h1 {
|
|
color: #000000;
|
|
text-align: center;
|
|
margin-bottom: 30px;
|
|
font-weight: 700;
|
|
}
|
|
|
|
.form-group {
|
|
margin-bottom: 25px;
|
|
}
|
|
|
|
label {
|
|
display: block;
|
|
color: #000000;
|
|
font-weight: 600;
|
|
margin-bottom: 8px;
|
|
font-size: 14px;
|
|
}
|
|
|
|
input[type="date"],
|
|
input[type="text"] {
|
|
width: 100%;
|
|
padding: 12px;
|
|
border: 2px solid #FFC407;
|
|
border-radius: 5px;
|
|
font-family: 'Montserrat', sans-serif;
|
|
font-size: 14px;
|
|
color: #000000;
|
|
background-color: #ffffff;
|
|
transition: border-color 0.3s ease;
|
|
}
|
|
|
|
input[type="date"]:focus,
|
|
input[type="text"]:focus {
|
|
outline: none;
|
|
border-color: #000000;
|
|
}
|
|
|
|
.submit-btn {
|
|
width: 100%;
|
|
padding: 14px;
|
|
background-color: #FFC407;
|
|
color: #000000;
|
|
border: none;
|
|
border-radius: 5px;
|
|
font-family: 'Montserrat', sans-serif;
|
|
font-size: 16px;
|
|
font-weight: 700;
|
|
cursor: pointer;
|
|
transition: all 0.3s ease;
|
|
margin-top: 10px;
|
|
}
|
|
|
|
.submit-btn:hover {
|
|
background-color: #000000;
|
|
color: #FFC407;
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 4px 8px rgba(255, 196, 7, 0.4);
|
|
}
|
|
|
|
.submit-btn:active {
|
|
transform: translateY(0);
|
|
}
|
|
|
|
.message {
|
|
margin-top: 20px;
|
|
padding: 12px;
|
|
border-radius: 5px;
|
|
text-align: center;
|
|
font-weight: 600;
|
|
display: none;
|
|
}
|
|
|
|
.message.success {
|
|
background-color: #FFC407;
|
|
color: #000000;
|
|
}
|
|
|
|
.message.error {
|
|
background-color: #ff4444;
|
|
color: #ffffff;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<h1>Date Submission Form</h1>
|
|
<form id="dateForm">
|
|
<div class="form-group">
|
|
<label for="masterCampaignNumber">Master Campaign Number</label>
|
|
<input type="text" id="masterCampaignNumber" name="masterCampaignNumber" required>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="boxId">Box ID</label>
|
|
<input type="text" id="boxId" name="boxId" required>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="supplyDate">Supply Date</label>
|
|
<input type="date" id="supplyDate" name="supplyDate" required>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="liveDate">Live Date</label>
|
|
<input type="date" id="liveDate" name="liveDate" required>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="endDate">End Date</label>
|
|
<input type="date" id="endDate" name="endDate" required>
|
|
</div>
|
|
|
|
<button type="submit" class="submit-btn">Submit</button>
|
|
</form>
|
|
<div id="message" class="message"></div>
|
|
</div>
|
|
|
|
<script>
|
|
// Webhook URL - Replace this with your actual webhook URL
|
|
const WEBHOOK_URL = 'YOUR_WEBHOOK_URL_HERE';
|
|
|
|
document.getElementById('dateForm').addEventListener('submit', async function(e) {
|
|
e.preventDefault();
|
|
|
|
const messageDiv = document.getElementById('message');
|
|
const submitBtn = document.querySelector('.submit-btn');
|
|
|
|
// Get form values
|
|
const masterCampaignNumber = document.getElementById('masterCampaignNumber').value;
|
|
const boxId = document.getElementById('boxId').value;
|
|
const supplyDate = document.getElementById('supplyDate').value;
|
|
const liveDate = document.getElementById('liveDate').value;
|
|
const endDate = document.getElementById('endDate').value;
|
|
|
|
// Format dates to match the CSV format (DD/MM/YYYY 00:00)
|
|
function formatDate(dateString) {
|
|
const date = new Date(dateString);
|
|
const day = String(date.getDate()).padStart(2, '0');
|
|
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
const year = date.getFullYear();
|
|
return `${day}/${month}/${year} 00:00`;
|
|
}
|
|
|
|
// Prepare data
|
|
const formData = {
|
|
masterCampaignNumber: masterCampaignNumber,
|
|
boxId: boxId,
|
|
supplyDate: formatDate(supplyDate),
|
|
liveDate: formatDate(liveDate),
|
|
endDate: formatDate(endDate)
|
|
};
|
|
|
|
// Disable button during submission
|
|
submitBtn.disabled = true;
|
|
submitBtn.textContent = 'Submitting...';
|
|
|
|
try {
|
|
const response = await fetch(WEBHOOK_URL, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify(formData)
|
|
});
|
|
|
|
if (response.ok) {
|
|
messageDiv.textContent = 'Form submitted successfully!';
|
|
messageDiv.className = 'message success';
|
|
messageDiv.style.display = 'block';
|
|
document.getElementById('dateForm').reset();
|
|
} else {
|
|
throw new Error('Submission failed');
|
|
}
|
|
} catch (error) {
|
|
messageDiv.textContent = 'Error submitting form. Please try again.';
|
|
messageDiv.className = 'message error';
|
|
messageDiv.style.display = 'block';
|
|
} finally {
|
|
submitBtn.disabled = false;
|
|
submitBtn.textContent = 'Submit';
|
|
|
|
// Hide message after 5 seconds
|
|
setTimeout(() => {
|
|
messageDiv.style.display = 'none';
|
|
}, 5000);
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|