188 lines
10 KiB
PHP
188 lines
10 KiB
PHP
<?php
|
|
$pageTitle = "Pilot Signup - Kotkakey";
|
|
$pageDescription = "Join the Kotkakey pilot program to help solve medicine shortages in Finland.";
|
|
|
|
$errors = [];
|
|
$inputs = [];
|
|
|
|
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|
// Sanitize and validate inputs
|
|
$organization = filter_input(INPUT_POST, 'organization', FILTER_SANITIZE_STRING);
|
|
$role = filter_input(INPUT_POST, 'role', FILTER_SANITIZE_STRING);
|
|
$contact_person = filter_input(INPUT_POST, 'contact_person', FILTER_SANITIZE_STRING);
|
|
$email = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
|
|
$phone = filter_input(INPUT_POST, 'phone', FILTER_SANITIZE_STRING);
|
|
$address = filter_input(INPUT_POST, 'address', FILTER_SANITIZE_STRING);
|
|
$patients_served = filter_input(INPUT_POST, 'patients_served', FILTER_SANITIZE_NUMBER_INT);
|
|
$challenges = filter_input(INPUT_POST, 'challenges', FILTER_SANITIZE_STRING);
|
|
$consent = filter_input(INPUT_POST, 'consent', FILTER_VALIDATE_BOOLEAN);
|
|
|
|
$inputs = compact('organization', 'role', 'contact_person', 'email', 'phone', 'address', 'patients_served', 'challenges', 'consent');
|
|
|
|
// Basic validation
|
|
if (empty($organization)) {
|
|
$errors['organization'] = 'Organization name is required.';
|
|
}
|
|
if (empty($role)) {
|
|
$errors['role'] = 'Please select a role.';
|
|
}
|
|
if (empty($contact_person)) {
|
|
$errors['contact_person'] = 'Contact person is required.';
|
|
}
|
|
if (!$email) {
|
|
$errors['email'] = 'A valid email is required.';
|
|
}
|
|
if (empty($phone)) {
|
|
$errors['phone'] = 'Phone number is required.';
|
|
}
|
|
if (!$consent) {
|
|
$errors['consent'] = 'You must agree to the terms.';
|
|
}
|
|
|
|
if (empty($errors)) {
|
|
require_once __DIR__ . '/mail/MailService.php';
|
|
|
|
$to = 'info@kotkakey.com';
|
|
$subject = 'New Pilot Signup: ' . htmlspecialchars($organization);
|
|
|
|
$html_content = "<h2>New Pilot Program Signup</h2>";
|
|
$html_content .= "<ul>";
|
|
$html_content .= "<li><strong>Organization:</strong> " . htmlspecialchars($organization) . "</li>";
|
|
$html_content .= "<li><strong>Role:</strong> " . htmlspecialchars($role) . "</li>";
|
|
$html_content .= "<li><strong>Contact Person:</strong> " . htmlspecialchars($contact_person) . "</li>";
|
|
$html_content .= "<li><strong>Email:</strong> " . htmlspecialchars($email) . "</li>";
|
|
$html_content .= "<li><strong>Phone:</strong> " . htmlspecialchars($phone) . "</li>";
|
|
$html_content .= "<li><strong>Address / Region:</strong> " . htmlspecialchars($address) . "</li>";
|
|
$html_content .= "<li><strong>Patients Served:</strong> " . htmlspecialchars($patients_served) . "</li>";
|
|
$html_content .= "<li><strong>Main Challenges:</strong><br>" . nl2br(htmlspecialchars($challenges)) . "</li>";
|
|
$html_content .= "</ul>";
|
|
|
|
$text_content = "New Pilot Program Signup
|
|
|
|
";
|
|
$text_content .= "Organization: " . $organization . "
|
|
";
|
|
$text_content .= "Role: " . $role . "
|
|
";
|
|
$text_content .= "Contact Person: " . $contact_person . "
|
|
";
|
|
$text_content .= "Email: " . $email . "
|
|
";
|
|
$text_content .= "Phone: " . $phone . "
|
|
";
|
|
$text_content .= "Address / Region: " . $address . "
|
|
";
|
|
$text_content .= "Patients Served: " . $patients_served . "
|
|
";
|
|
$text_content .= "Main Challenges:
|
|
" . $challenges . "
|
|
";
|
|
|
|
// Use the generic sendMail function
|
|
$result = MailService::sendMail($to, $subject, $html_content, $text_content, ['reply_to' => $email]);
|
|
|
|
if (!empty($result['success'])) {
|
|
header('Location: signup-thank-you.php');
|
|
exit;
|
|
} else {
|
|
// Log error, maybe set a generic error message for the user
|
|
error_log('MailService Error: ' . ($result['error'] ?? 'Unknown error'));
|
|
$errors['submit'] = 'Sorry, there was a problem sending your application. Please try again later.';
|
|
}
|
|
}
|
|
}
|
|
|
|
// Include header
|
|
include __DIR__ . '/index.php';
|
|
?>
|
|
|
|
<main class="container mt-5 pt-5">
|
|
<div class="row justify-content-center">
|
|
<div class="col-lg-8">
|
|
<div class="card shadow-sm" style="border-radius: 0.5rem; border: 0;">
|
|
<div class="card-body p-5">
|
|
<h1 class="display-5 text-center mb-4">Join the Pilot Program</h1>
|
|
<p class="text-center text-muted mb-5">Become a part of the solution to medicine shortages. Fill out the form below to apply for the Kotkakey pilot program.</p>
|
|
|
|
<?php if (!empty($errors['submit'])): ?>
|
|
<div class="alert alert-danger"><?php echo htmlspecialchars($errors['submit']); ?></div>
|
|
<?php endif; ?>
|
|
|
|
<form action="signup.php" method="POST" novalidate>
|
|
<div class="mb-3">
|
|
<label for="organization" class="form-label">Organization / Pharmacy Name</label>
|
|
<input type="text" class="form-control <?php echo isset($errors['organization']) ? 'is-invalid' : ''; ?>" id="organization" name="organization" value="<?php echo htmlspecialchars($inputs['organization'] ?? ''); ?>" required>
|
|
<div class="invalid-feedback"><?php echo htmlspecialchars($errors['organization'] ?? ''); ?></div>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label for="role" class="form-label">Role</label>
|
|
<select class="form-select <?php echo isset($errors['role']) ? 'is-invalid' : ''; ?>" id="role" name="role" required>
|
|
<option value="">Select your role...</option>
|
|
<option value="Farmaseutti" <?php echo ($inputs['role'] ?? '') === 'Farmaseutti' ? 'selected' : ''; ?>>Farmaseutti</option>
|
|
<option value="Proviisori" <?php echo ($inputs['role'] ?? '') === 'Proviisori' ? 'selected' : ''; ?>>Proviisori</option>
|
|
<option value="Pharmacy Owner" <?php echo ($inputs['role'] ?? '') === 'Pharmacy Owner' ? 'selected' : ''; ?>>Pharmacy Owner</option>
|
|
<option value="Chain Lead" <?php echo ($inputs['role'] ?? '') === 'Chain Lead' ? 'selected' : ''; ?>>Chain Lead</option>
|
|
<option value="Other" <?php echo ($inputs['role'] ?? '') === 'Other' ? 'selected' : ''; ?>>Other</option>
|
|
</select>
|
|
<div class="invalid-feedback"><?php echo htmlspecialchars($errors['role'] ?? ''); ?></div>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label for="contact_person" class="form-label">Contact Person</label>
|
|
<input type="text" class="form-control <?php echo isset($errors['contact_person']) ? 'is-invalid' : ''; ?>" id="contact_person" name="contact_person" value="<?php echo htmlspecialchars($inputs['contact_person'] ?? ''); ?>" required>
|
|
<div class="invalid-feedback"><?php echo htmlspecialchars($errors['contact_person'] ?? ''); ?></div>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label for="email" class="form-label">Email</label>
|
|
<input type="email" class="form-control <?php echo isset($errors['email']) ? 'is-invalid' : ''; ?>" id="email" name="email" value="<?php echo htmlspecialchars($inputs['email'] ?? ''); ?>" required>
|
|
<div class="invalid-feedback"><?php echo htmlspecialchars($errors['email'] ?? ''); ?></div>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label for="phone" class="form-label">Phone</label>
|
|
<input type="tel" class="form-control <?php echo isset($errors['phone']) ? 'is-invalid' : ''; ?>" id="phone" name="phone" value="<?php echo htmlspecialchars($inputs['phone'] ?? ''); ?>" required>
|
|
<div class="invalid-feedback"><?php echo htmlspecialchars($errors['phone'] ?? ''); ?></div>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label for="address" class="form-label">Address / Region</label>
|
|
<input type="text" class="form-control" id="address" name="address" value="<?php echo htmlspecialchars($inputs['address'] ?? ''); ?>">
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label for="patients_served" class="form-label">Number of Patients Served / Pharmacy Size</label>
|
|
<input type="number" class="form-control" id="patients_served" name="patients_served" value="<?php echo htmlspecialchars($inputs['patients_served'] ?? ''); ?>">
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label for="challenges" class="form-label">Main Shortage Challenges (Optional)</label>
|
|
<textarea class="form-control" id="challenges" name="challenges" rows="4"><?php echo htmlspecialchars($inputs['challenges'] ?? ''); ?></textarea>
|
|
</div>
|
|
|
|
<div class="form-check mb-4">
|
|
<input class="form-check-input <?php echo isset($errors['consent']) ? 'is-invalid' : ''; ?>" type="checkbox" value="1" id="consent" name="consent" required>
|
|
<label class="form-check-label" for="consent">
|
|
I agree to the processing of my data as described in the Privacy Policy and consent to be contacted about the pilot program.
|
|
</label>
|
|
<div class="invalid-feedback"><?php echo htmlspecialchars($errors['consent'] ?? ''); ?></div>
|
|
</div>
|
|
|
|
<div class="d-grid">
|
|
<button type="submit" class="btn btn-primary btn-lg" style="background-color: #0057FF; border: none;">Submit Application</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<?php
|
|
// Include footer
|
|
// We are including index.php which contains the full page layout.
|
|
// To prevent re-rendering the whole page, we can't include a separate footer.
|
|
// This is a temporary workaround. A better solution would be to have separate header/footer files.
|
|
?>
|