diff --git a/admin/index.php b/admin/index.php index e57df7d..19d592c 100644 --- a/admin/index.php +++ b/admin/index.php @@ -1,5 +1,8 @@ 'Session expired. Please reload and log in again.']); + exit; +} +if ($isAjax) { header('Content-Type: application/json'); $action = $_POST['action'] ?? $_GET['action'] ?? ''; @@ -28,11 +37,10 @@ if ($isAjax && $authed) { if ($id && in_array($status, $allowed)) { db()->prepare("UPDATE bookings SET status=? WHERE id=?")->execute([$status, $id]); echo json_encode(['ok'=>true]); - } else { - echo json_encode(['error'=>'Invalid']); - } + } else { echo json_encode(['error'=>'Invalid']); } exit; } + if ($action === 'save_admin_notes') { $id = (int)($_POST['id'] ?? 0); $notes = substr(trim($_POST['notes'] ?? ''), 0, 1000); @@ -40,6 +48,103 @@ if ($isAjax && $authed) { echo json_encode(['ok'=>true]); exit; } + + if ($action === 'toggle_requirement') { + $id = (int)($_POST['id'] ?? 0); + $field = $_POST['field'] ?? ''; + $allowed_fields = ['insurance_verified','deposit_received','license_verified']; + if ($id && in_array($field, $allowed_fields)) { + $stmt = db()->prepare("SELECT `{$field}` FROM bookings WHERE id=?"); + $stmt->execute([$id]); + $current = (int)$stmt->fetchColumn(); + $new = $current ? 0 : 1; + db()->prepare("UPDATE bookings SET `{$field}`=? WHERE id=?")->execute([$new, $id]); + echo json_encode(['ok'=>true,'value'=>$new]); + } else { echo json_encode(['error'=>'Invalid']); } + exit; + } + + if ($action === 'send_reminder') { + $id = (int)($_POST['id'] ?? 0); + $keys = array_filter(explode(',', $_POST['items'] ?? '')); + $stmt = db()->prepare("SELECT * FROM bookings WHERE id=?"); + $stmt->execute([$id]); + $b = $stmt->fetch(); + if (!$b) { echo json_encode(['error'=>'Not found']); exit; } + + $pkg = PACKAGES[$b['package']] ?? ['label' => $b['package']]; + $dateLabel = date('F j, Y', strtotime($b['rental_date'])); + $ref = $b['booking_ref']; + + $itemDefs = [ + 'waiver' => [ + 'label' => 'Sign Your Rental Agreement', + 'detail' => 'Your digital rental agreement still needs to be signed before your pickup. It only takes a minute and can be done on any device — no printer required.', + 'cta' => "
", + ], + 'insurance' => [ + 'label' => 'Proof of Personal Auto Insurance', + 'detail' => 'You\'ll need to bring proof of valid personal auto insurance to pickup. A photo on your phone of your insurance card is fine. This is required before we can hand over the keys.', + 'cta' => '', + ], + 'deposit' => [ + 'label' => 'Security Deposit', + 'detail' => 'A refundable security deposit is required at the time of pickup. Please have it ready — cash or card accepted. It will be returned in full upon safe return of the vehicle.', + 'cta' => '', + ], + 'license' => [ + 'label' => "Valid Driver's License", + 'detail' => "Please bring your valid driver's license to pickup. We're required to verify it before you take the Slingshot out. Must match the name on the booking.", + 'cta' => '', + ], + ]; + + $rowsHtml = ''; + $n = 1; + foreach ($keys as $key) { + if (!isset($itemDefs[$key])) continue; + $d = $itemDefs[$key]; + $rowsHtml .= " +" . htmlspecialchars($d['detail']) . "
+ {$d['cta']} +Hey " . htmlspecialchars($b['name']) . ", your " . htmlspecialchars($pkg['label']) . " rental on {$dateLabel} is coming up! (Ref: {$ref})
+To make sure pickup goes smoothly, here's what still needs to be taken care of:
+Questions? Call or text (817) 555-0199 or reply to this email — we're happy to help.
+Ride on,
The Parker County Slingshot Team
© " . date('Y') . " Parker County Slingshot Rentals — Weatherford, TX
+| Ref | Customer | Package | Date | -Amount | Status | Waiver | Admin Notes | Received | ++ | Customer | +Rental Date | +Package | +Amount | +Status | +Progress | +Submitted |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| = htmlspecialchars($b['booking_ref']) ?> | -
- = htmlspecialchars($b['name']) ?> - = htmlspecialchars($b['email']) ?> - = htmlspecialchars($b['phone']) ?> + $b['package']]; + + // Determine each step's state + $stepConfirmed = in_array($b['status'], ['confirmed','completed']); + $stepWaiver = (bool)$b['waiver_signed']; + $stepInsurance = (bool)$b['insurance_verified']; + $stepDeposit = (bool)$b['deposit_received']; + $stepLicense = (bool)$b['license_verified']; + + // Dot colors: done=green, if cancelled skip all + $cancelled = $b['status'] === 'cancelled'; + $dotClass = function($done) use ($cancelled) { + if ($cancelled) return 'dot-skip'; + return $done ? 'dot-done' : 'dot-pending'; + }; + + $allDone = $stepConfirmed && $stepWaiver && $stepInsurance && $stepDeposit && $stepLicense; + $pendingCount = ($cancelled ? 0 : ( + (!$stepConfirmed?1:0)+(!$stepWaiver?1:0)+(!$stepInsurance?1:0)+(!$stepDeposit?1:0)+(!$stepLicense?1:0) + )); + ?> + | |||||||||||||||
| + |
- $b['package']]; ?>
- = htmlspecialchars($pkg['label']) ?>
+ = htmlspecialchars($b['name']) ?> + = htmlspecialchars($b['email']) ?> |
= date('M j, Y', strtotime($b['rental_date'])) ?>
- → = date('M j', strtotime($b['end_date'])) ?> + → = date('M j', strtotime($b['end_date'])) ?> |
- $= number_format($b['amount'],2) ?> | -- | ||||||||||||
|
+
+
+
+
+
+
+
+ Customer+= htmlspecialchars($b['booking_ref']) ?>
+ = htmlspecialchars($b['name']) ?>
+
+
+
+
+ Package
+ = htmlspecialchars($pkg['label']) ?>
+ $= number_format($b['amount'],2) ?>
+ Rental Date
+ = date('F j, Y', strtotime($b['rental_date'])) ?>
+
+ Customer Message
+ = nl2br(htmlspecialchars($b['notes'])) ?>
+
+
+
+
+ Admin Notes
+
+
+
+
+
+
+ Booking Flow+
+
+
+
+
+
+
+
+
+
+ Booking Submitted
+
+
+
+
+
+
+
+
+ Booking Confirmed
+
+
+
+
+
+
+
+
+ Rental Waiver Signed
+
+
+
+
+
+
+
+
+
+
+
+ Proof of Insurance Received
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Security Deposit Received
+
+
+
+
+
+
+
+
+
+
+
+
+ Driver's License Verified
+
+
+
+
+
+
+
+
+
+
+ Send Reminder Email+Select what the customer still needs to do, then send them a nudge email with clear instructions. + + +Not applicable for cancelled bookings. + +
+
+
+ Include in Reminder+
+
+
+
+
+
+
+
+
+ Waiver Link
+
+
+ https://parkerslingshotrentals.com/waiver.php?ref== htmlspecialchars($b['booking_ref']) ?>
+ |
- = date('M j g:ia', strtotime($b['created_at'])) ?> | |||||||||||||||