File Manager V1.5

[SYSTEM@ROOT]: /home/ketechno/dakotaoilug.com/
INJECT_FILE:
NEW_ENTRY:

FILE_CONTENT: appointment.php

<?php
include 'header.php';
require_once 'admin/functions.php';

$success_message = '';
$error_message = '';

function send_appointment_mail_fallback($data) {
    $recipients = [];
    $cfg = __DIR__ . '/admin/mailer_config.php';
    if (file_exists($cfg)) { require $cfg; }
    if (!empty($MAIL_TO_OVERRIDE)) {
        $recipients = [$MAIL_TO_OVERRIDE];
    }
    if (!$recipients && function_exists('getSupportUsersEmails')) {
        $recipients = getSupportUsersEmails();
    }
    if (!$recipients) { $recipients = ['oildakota8@gmail.com']; }

    $name = isset($data['name']) ? $data['name'] : '';
    $email = isset($data['email']) ? $data['email'] : '';
    $phone = isset($data['phone']) ? $data['phone'] : '';
    $service = isset($data['service']) ? $data['service'] : '';
    $quantity = (isset($data['quantity_liters']) && $data['quantity_liters'] !== '') ? $data['quantity_liters'] : '';
    $date = isset($data['preferred_date']) ? $data['preferred_date'] : '';
    $time = isset($data['preferred_time']) ? $data['preferred_time'] : '';
    $message = isset($data['message']) ? $data['message'] : '';
    $appointmentId = isset($data['appointment_id']) ? (int)$data['appointment_id'] : 0;

    $subject = 'New order Request - Dakota Oil';
    $html = '<html><body>';
    $html .= '<h2 style="margin:0 0 10px 0;">New Order Request</h2>';
    $html .= '<table cellpadding="0" cellspacing="0" border="0" style="width:100%; border-collapse:collapse; border:1px solid #e5e7eb;">';
    $html .= '<tr><td style="padding:8px;border:1px solid #e5e7eb;"><strong>Name:</strong></td><td style="padding:8px;border:1px solid #e5e7eb;">' . htmlspecialchars($name) . '</td></tr>';
    $html .= '<tr><td style="padding:8px;border:1px solid #e5e7eb;"><strong>Email:</strong></td><td style="padding:8px;border:1px solid #e5e7eb;">' . htmlspecialchars($email) . '</td></tr>';
    $html .= '<tr><td style="padding:8px;border:1px solid #e5e7eb;"><strong>Phone:</strong></td><td style="padding:8px;border:1px solid #e5e7eb;">' . htmlspecialchars($phone) . '</td></tr>';
    $html .= '<tr><td style="padding:8px;border:1px solid #e5e7eb;"><strong>Service:</strong></td><td style="padding:8px;border:1px solid #e5e7eb;">' . htmlspecialchars($service) . '</td></tr>';
    if ($quantity !== '') {
        $html .= '<tr><td style="padding:8px;border:1px solid #e5e7eb;"><strong>Quantity (Liters):</strong></td><td style="padding:8px;border:1px solid #e5e7eb;">' . htmlspecialchars($quantity) . '</td></tr>';
    }
    if ($appointmentId > 0) {
        $html .= '<tr><td style="padding:8px;border:1px solid #e5e7eb;"><strong>Request ID:</strong></td><td style="padding:8px;border:1px solid #e5e7eb;">#' . (int)$appointmentId . '</td></tr>';
    }
    $html .= '<tr><td style="padding:8px;border:1px solid #e5e7eb;"><strong>Submitted:</strong></td><td style="padding:8px;border:1px solid #e5e7eb;">' . htmlspecialchars(date('Y-m-d H:i:s')) . '</td></tr>';
    $html .= '<tr><td style="padding:8px;border:1px solid #e5e7eb;"><strong>Preferred Date:</strong></td><td style="padding:8px;border:1px solid #e5e7eb;">' . htmlspecialchars($date) . '</td></tr>';
    $html .= '<tr><td style="padding:8px;border:1px solid #e5e7eb;"><strong>Preferred Time:</strong></td><td style="padding:8px;border:1px solid #e5e7eb;">' . htmlspecialchars($time) . '</td></tr>';
    if ($message !== '') {
        $html .= '<tr><td valign="top" style="padding:8px;border:1px solid #e5e7eb;"><strong>Message:</strong></td><td style="padding:8px;border:1px solid #e5e7eb;">' . nl2br(htmlspecialchars($message)) . '</td></tr>';
    }
    $html .= '</table>';
    $html .= '</body></html>';
    $body = $html;

    $fromDomain = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost';
    $from = 'noreply@' . $fromDomain;

    $headers = '';
    $headers .= 'From: ' . $from . "\r\n";
    if (!empty($email)) { $headers .= 'Reply-To: ' . $email . "\r\n"; }
    $headers .= 'Return-Path: ' . $from . "\r\n";
    $headers .= 'X-Mailer: PHP/' . phpversion() . "\r\n";
    $headers .= 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-Type: text/html; charset=UTF-8' . "\r\n";
    $headers .= 'Content-Transfer-Encoding: 8bit' . "\r\n";

    $to = implode(',', $recipients);
    $params = '-f ' . $from;
    return mail($to, $subject, $body, $headers, $params);
}

// Handle form submission
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $result = addAppointment($_POST);
    
    if ($result) {
        $appointment_id = 0;
        if (isset($conn)) { $appointment_id = mysqli_insert_id($conn); }
        $payload = $_POST;
        $payload['appointment_id'] = (int)$appointment_id;
        $sent = false;
        // Notify support users about the new appointment
        try {
            $sent = sendSupportAppointmentAlert($payload);
        } catch (Exception $e) {}
        if (!$sent) {
            try { send_appointment_mail_fallback($payload); } catch (Exception $e) {}
        }
        $success_message = "Order request submitted successfully!";
    } else {
        $error_message = "Error: Unable to submit order. Please try again.";
    }
}
?>

<section class="accordian-section" style="margin-top:10%;color:#ffffff; ">
		
		<div class="auto-container">
		<h2>Order Fuel or book for other services here</h2>
		<hr>
			<div class="row clearfix">
				
				<!--Accordian Column-->
				<div class="accordian-column col-lg-6 col-md-12 col-sm-12">
					<div class="inner-column">
					<?php if ($success_message): ?>
                <div class="alert alert-success"><?php echo $success_message; ?></div>
            <?php endif; ?>
            <?php if ($error_message): ?>
                <div class="alert alert-danger"><?php echo $error_message; ?></div>
            <?php endif; ?>

            <form method="POST" action="" class="appointment-form" style=" border:2px solid #2ed0b0; padding:20px;">
                <div class="row">
                    <div class="col-md-6 mb-3">
                        <label for="name">Full Name *</label>
                        <input type="text" class="form-control" id="name" name="name" required>
                    </div>
                    <div class="col-md-6 mb-3">
                        <label for="email">Email Address *</label>
                        <input type="email" class="form-control" id="email" name="email" required>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-6 mb-3">
                        <label for="phone">Phone Number *</label>
                        <input type="tel" class="form-control" id="phone" name="phone" required>
                    </div>
                    <div class="col-md-6 mb-3">
                        <label for="service">Service Type *</label>
                        <select class="form-control" id="service" name="service" required>
                            <option value="">Select a service</option>
                            <option value="Aircraft Fuel">Aircraft Fuel</option>
                            <option value="Airport Meet and Assist">Airport Meet and Assist</option>
                            <option value="Mentorship">Mentorship</option>
                            <option value="Aircraft Insuranc">Aircraft Insurance</option>
                           
                        </select>
                    </div>
                </div>
                <div id="quantity_row" class="row" style="display:none;">
                    <div class="col-md-6 mb-3">
                        <label for="quantity_liters">Quantity (Liters)</label>
                        <input type="number" class="form-control" id="quantity_liters" name="quantity_liters" min="0" step="0.01" placeholder="e.g., 500">
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-6 mb-3">
                        <label for="preferred_date">Preferred Date *</label>
                        <input type="date" class="form-control" id="preferred_date" name="preferred_date" required>
                    </div>
                    <div class="col-md-6 mb-3">
                        <label for="preferred_time">Preferred Time *</label>
                        <input type="time" class="form-control" id="preferred_time" name="preferred_time" required>
                    </div>
                </div>
                <div class="mb-3">
                    <label for="message">Additional Message</label>
                    <textarea class="form-control" id="message" name="message" rows="4"></textarea>
                </div>
                <button type="submit" class="btn ">Submit Request</button>
            </form>
            <script>
            (function(){
              var serviceSelect = document.getElementById('service');
              var qtyRow = document.getElementById('quantity_row');
              var qtyInput = document.getElementById('quantity_liters');
              function updateQtyVisibility(){
                var val = (serviceSelect.value || '').toLowerCase();
                var show = val.indexOf('fuel') !== -1;
                qtyRow.style.display = show ? '' : 'none';
                if (show) {
                  qtyInput.setAttribute('required','required');
                } else {
                  qtyInput.removeAttribute('required');
                  qtyInput.value = '';
                }
              }
              if (serviceSelect) {
                serviceSelect.addEventListener('change', updateQtyVisibility);
                updateQtyVisibility();
              }
            })();
            </script>
						
						
					</div>
				</div>
				 <?php // Get about page content
try {
    $query = "SELECT * FROM about_content";
    $result = $conn->query($query);
    if (!$result) {
        throw new Exception("Database query failed: " . $conn->error);
    }
    $about_content = [];
    while ($row = $result->fetch_assoc()) {
        $about_content[$row['section_key']] = $row;
    }
} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
    $about_content = [];
}
?>
				<!--Content Column-->
				<div class="content-column col-lg-6 col-md-12 col-sm-12">
					<div class="inner-column">
						<h2>Find us</h2>
						
						 <div class="footer-column col-md-6 col-sm-6 col-xs-12">
                                <div class="footer-widget contact-widget">
									<ul class="social-icon-one">
										<li ><a href="#" class="fa fa-map-marker" style="color:#006dae;
;"></a></li>								
									</ul>
									<p style="color:#2ed0b0; font-size:20px;
;">                                          Plot 16 Namiiro Swamp access road</br>
P.O BOX 703253 Entebbe.</br>
Tel: +256 74074438/0742173144</br>
Email: oildakota8@gmail.com 
									</p>
								</div>
							</div>
							 <div class="footer-column col-md-6 col-sm-6 col-xs-12">
                                <div class="footer-widget contact-widget">
									<ul class="list-unstyled">
                        <!--<li>
                            <i class="fas fa-map-marker-alt icon"></i>
                            <h2><?php echo htmlspecialchars($about_content['location']['title'] ?? ''); ?></h2>
                            <a href="#" class="fa fa-map-marker" style="color:#006dae;"></a>								
                            <?php echo nl2br(htmlspecialchars($about_content['location']['content'] ?? '')); ?>
                        </li>
                            <a href="#" class="fa fa-phone" style="color:#006dae;"></a>								
                            <strong>Phone:</strong><br>
                            <?php echo nl2br(htmlspecialchars($about_content['contact']['content'] ?? '')); ?>
                        </li>-->
                        <li>
                    </ul>
								</div>
							</div>
						
					</div>
				</div>
				
			</div>
		</div>
	</section>
<?php include 'footer.php'; ?>
[ KEMBALI ]