创建待预约页面并更新导航栏
This commit is contained in:
@@ -278,6 +278,7 @@ try {
|
||||
<nav class="nav">
|
||||
<a href="index.php" class="nav-link">预约洗车</a>
|
||||
<a href="bookings.php" class="nav-link">预约管理</a>
|
||||
<a href="pending_bookings.php" class="nav-link">待预约处理</a>
|
||||
<a href="packages.php" class="nav-link">套餐管理</a>
|
||||
<a href="vip.php" class="nav-link">VIP管理</a>
|
||||
<a href="announcement.php" class="nav-link active">今日待办</a>
|
||||
|
||||
@@ -88,6 +88,7 @@ try {
|
||||
<nav class="nav">
|
||||
<a href="index.php" class="nav-link">预约洗车</a>
|
||||
<a href="bookings.php" class="nav-link active">预约管理</a>
|
||||
<a href="pending_bookings.php" class="nav-link">待预约处理</a>
|
||||
<a href="packages.php" class="nav-link">套餐管理</a>
|
||||
<a href="vip.php" class="nav-link">VIP管理</a>
|
||||
<a href="announcement.php" class="nav-link">今日待办</a>
|
||||
|
||||
@@ -68,6 +68,7 @@ $packages = $stmt->fetchAll();
|
||||
<nav class="nav">
|
||||
<a href="index.php" class="nav-link">预约洗车</a>
|
||||
<a href="bookings.php" class="nav-link">预约管理</a>
|
||||
<a href="pending_bookings.php" class="nav-link">待预约处理</a>
|
||||
<a href="packages.php" class="nav-link active">套餐管理</a>
|
||||
<a href="vip.php" class="nav-link">VIP管理</a>
|
||||
<a href="announcement.php" class="nav-link">今日待办</a>
|
||||
|
||||
@@ -0,0 +1,430 @@
|
||||
<?php
|
||||
// pending_bookings.php - 待预约页面,处理WPS表单数据
|
||||
require_once 'db_connect.php';
|
||||
|
||||
// 处理表单提交
|
||||
$success_message = '';
|
||||
$error_message = '';
|
||||
|
||||
// 如果有预约转换请求
|
||||
if (isset($_POST['action']) && $_POST['action'] == 'convert_to_booking' && isset($_POST['submission_id'])) {
|
||||
$submission_id = $_POST['submission_id'];
|
||||
$selected_date = $_POST['selected_date'];
|
||||
$selected_time = $_POST['selected_time'];
|
||||
$selected_package = $_POST['selected_package'];
|
||||
$custom_notes = $_POST['custom_notes'];
|
||||
|
||||
try {
|
||||
// 获取WPS表单提交数据
|
||||
$stmt = $pdo->prepare("SELECT * FROM wps_form_submissions WHERE id = ?");
|
||||
$stmt->execute([$submission_id]);
|
||||
$submission = $stmt->fetch();
|
||||
|
||||
if (!$submission) {
|
||||
throw new Exception("表单提交数据不存在");
|
||||
}
|
||||
|
||||
// 获取套餐信息
|
||||
$stmt = $pdo->prepare("SELECT * FROM packages WHERE id = ?");
|
||||
$stmt->execute([$selected_package]);
|
||||
$package = $stmt->fetch();
|
||||
|
||||
if (!$package) {
|
||||
throw new Exception("选择的套餐不存在");
|
||||
}
|
||||
|
||||
// 计算开始和结束时间
|
||||
$start_time = $selected_date . ' ' . $selected_time;
|
||||
$end_time = date('Y-m-d H:i:s', strtotime($start_time) + $package['base_duration'] * 60);
|
||||
|
||||
// 将数据插入到正式预约表
|
||||
$stmt = $pdo->prepare("INSERT INTO bookings (
|
||||
customer_name, phone, car_model, car_number, package_id, custom_services,
|
||||
start_time, end_time, duration, total_price, notes, status,
|
||||
member_type, source
|
||||
) VALUES (
|
||||
?, ?, ?, ?, ?, ?,
|
||||
?, ?, ?, ?, ?, ?,
|
||||
?, ?
|
||||
)");
|
||||
|
||||
$stmt->execute([
|
||||
$submission['name'],
|
||||
$submission['mobile'],
|
||||
$submission['car_type'],
|
||||
$submission['license_plate'],
|
||||
$selected_package,
|
||||
$custom_notes,
|
||||
$start_time,
|
||||
$end_time,
|
||||
$package['base_duration'],
|
||||
$package['price'],
|
||||
$submission['remarks'],
|
||||
'已确认', // 默认设置为已确认
|
||||
'普通客户', // 默认普通客户,可根据需要调整
|
||||
'其他' // 默认来源,可根据需要调整
|
||||
]);
|
||||
|
||||
$booking_id = $pdo->lastInsertId();
|
||||
|
||||
// 更新WPS表单提交状态为已处理
|
||||
$stmt = $pdo->prepare("UPDATE wps_form_submissions SET status = 'processed' WHERE id = ?");
|
||||
$stmt->execute([$submission_id]);
|
||||
|
||||
// 生成预约成功信息
|
||||
$booking_success_msg = "预约成功!\n\n客户:{$submission['name']}\n手机号:{$submission['mobile']}\n车牌号:{$submission['license_plate']}\n车型:{$submission['car_type']}\n\n预约时间:{$start_time}\n服务项目:{$package['package_name']}\n服务时长:{$package['base_duration']}分钟\n总价:{$package['price']}元\n\n感谢您的预约!";
|
||||
|
||||
$success_message = "预约转换成功!预约ID:{$booking_id}";
|
||||
|
||||
// 存储预约成功信息到会话,以便在页面上显示
|
||||
session_start();
|
||||
$_SESSION['booking_success_msg'] = $booking_success_msg;
|
||||
|
||||
} catch (Exception $e) {
|
||||
$error_message = '预约转换失败:' . $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
// 获取待处理的WPS表单提交
|
||||
try {
|
||||
$stmt = $pdo->prepare("SELECT * FROM wps_form_submissions WHERE status = 'pending' ORDER BY create_time DESC");
|
||||
$stmt->execute();
|
||||
$pending_submissions = $stmt->fetchAll();
|
||||
} catch (Exception $e) {
|
||||
$error_message = '获取待处理表单失败:' . $e->getMessage();
|
||||
$pending_submissions = [];
|
||||
}
|
||||
|
||||
// 获取所有套餐
|
||||
try {
|
||||
$stmt = $pdo->prepare("SELECT * FROM packages WHERE is_active = true");
|
||||
$stmt->execute();
|
||||
$packages = $stmt->fetchAll();
|
||||
} catch (Exception $e) {
|
||||
$error_message = '获取套餐信息失败:' . $e->getMessage();
|
||||
$packages = [];
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>待预约处理 - 洗车预约系统</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<style>
|
||||
/* 待预约页面特定样式 */
|
||||
.pending-bookings-container {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.pending-card {
|
||||
background: #fff;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
||||
margin-bottom: 20px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.pending-header {
|
||||
background: #f5f5f5;
|
||||
padding: 15px 20px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.pending-details {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.detail-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
||||
gap: 15px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.detail-item {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.detail-label {
|
||||
font-weight: bold;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.convert-form {
|
||||
background: #f9f9f9;
|
||||
padding: 20px;
|
||||
border-top: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.form-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 15px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
flex: 1;
|
||||
min-width: 200px;
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
display: block;
|
||||
margin-bottom: 5px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.form-group input, .form-group select, .form-group textarea {
|
||||
width: 100%;
|
||||
padding: 8px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 10px 20px;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: #007bff;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background: #0056b3;
|
||||
}
|
||||
|
||||
.booking-success {
|
||||
background: #d4edda;
|
||||
border: 1px solid #c3e6cb;
|
||||
color: #155724;
|
||||
padding: 15px;
|
||||
border-radius: 4px;
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.copy-message {
|
||||
background: #fff;
|
||||
border: 1px solid #ddd;
|
||||
padding: 10px;
|
||||
border-radius: 4px;
|
||||
margin-top: 10px;
|
||||
font-family: monospace;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.copy-btn {
|
||||
background: #28a745;
|
||||
color: white;
|
||||
padding: 5px 10px;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.status-badge {
|
||||
padding: 5px 10px;
|
||||
border-radius: 12px;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.status-pending {
|
||||
background: #ffc107;
|
||||
color: #212529;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="pending-bookings-container">
|
||||
<header class="header">
|
||||
<h1>🚗 洗车预约系统 - 待预约处理</h1>
|
||||
<nav class="nav">
|
||||
<a href="index.php" class="nav-link">预约洗车</a>
|
||||
<a href="bookings.php" class="nav-link">预约管理</a>
|
||||
<a href="pending_bookings.php" class="nav-link active">待预约处理</a>
|
||||
<a href="packages.php" class="nav-link">套餐管理</a>
|
||||
<a href="vip.php" class="nav-link">VIP管理</a>
|
||||
<a href="announcement.php" class="nav-link">今日待办</a>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<?php if (isset($success_message)): ?>
|
||||
<div class="success-message"><?php echo $success_message; ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (isset($error_message)): ?>
|
||||
<div class="error-message">
|
||||
<?php echo $error_message; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- 预约成功信息显示 -->
|
||||
<?php if (session_status() === PHP_SESSION_NONE) session_start(); ?>
|
||||
<?php if (isset($_SESSION['booking_success_msg'])): ?>
|
||||
<div class="booking-success">
|
||||
<h3>预约成功信息已生成</h3>
|
||||
<div class="copy-message" id="successMessage">
|
||||
<?php echo htmlspecialchars($_SESSION['booking_success_msg']); ?>
|
||||
</div>
|
||||
<button class="copy-btn" onclick="copyMessage()">复制信息</button>
|
||||
</div>
|
||||
<?php unset($_SESSION['booking_success_msg']); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="card">
|
||||
<h2>待处理预约 (共 <?php echo count($pending_submissions); ?> 条)</h2>
|
||||
|
||||
<?php if (empty($pending_submissions)): ?>
|
||||
<div class="empty-message">暂无待处理的预约请求</div>
|
||||
<?php else: ?>
|
||||
<?php foreach ($pending_submissions as $submission): ?>
|
||||
<div class="pending-card">
|
||||
<div class="pending-header">
|
||||
<h3><?php echo htmlspecialchars($submission['name']); ?> 的预约请求</h3>
|
||||
<span class="status-badge status-pending">待处理</span>
|
||||
</div>
|
||||
|
||||
<div class="pending-details">
|
||||
<div class="detail-grid">
|
||||
<div class="detail-item">
|
||||
<span class="detail-label">联系方式:</span>
|
||||
<span class="detail-value"><?php echo htmlspecialchars($submission['mobile']); ?></span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<span class="detail-label">车牌号:</span>
|
||||
<span class="detail-value"><?php echo htmlspecialchars($submission['license_plate']); ?></span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<span class="detail-label">车型:</span>
|
||||
<span class="detail-value"><?php echo htmlspecialchars($submission['car_type']); ?></span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<span class="detail-label">是否有车衣:</span>
|
||||
<span class="detail-value"><?php echo htmlspecialchars($submission['has_car_coat']); ?></span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<span class="detail-label">洗车习惯:</span>
|
||||
<span class="detail-value"><?php echo htmlspecialchars($submission['car_wash_habit']); ?></span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<span class="detail-label">撸车经验:</span>
|
||||
<span class="detail-value"><?php echo htmlspecialchars($submission['car_wash_experience']); ?></span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<span class="detail-label">洗车频率:</span>
|
||||
<span class="detail-value"><?php echo htmlspecialchars($submission['wash_frequency']); ?></span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<span class="detail-label">年龄段:</span>
|
||||
<span class="detail-value"><?php echo htmlspecialchars($submission['age_group']); ?></span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<span class="detail-label">自动编号:</span>
|
||||
<span class="detail-value"><?php echo htmlspecialchars($submission['auto_number']); ?></span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<span class="detail-label">提交时间:</span>
|
||||
<span class="detail-value"><?php echo htmlspecialchars($submission['create_time']); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($submission['remarks'])): ?>
|
||||
<div class="detail-item">
|
||||
<span class="detail-label">备注:</span>
|
||||
<span class="detail-value"><?php echo htmlspecialchars($submission['remarks']); ?></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="convert-form">
|
||||
<h4>转换为正式预约</h4>
|
||||
<form method="POST" action="pending_bookings.php">
|
||||
<input type="hidden" name="action" value="convert_to_booking">
|
||||
<input type="hidden" name="submission_id" value="<?php echo $submission['id']; ?>">
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label for="selected_date_<?php echo $submission['id']; ?>">选择日期:</label>
|
||||
<input type="date" id="selected_date_<?php echo $submission['id']; ?>" name="selected_date"
|
||||
value="<?php echo date('Y-m-d'); ?>" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="selected_time_<?php echo $submission['id']; ?>">选择时间:</label>
|
||||
<select id="selected_time_<?php echo $submission['id']; ?>" name="selected_time" required>
|
||||
<?php
|
||||
// 生成可选时间(9:00-18:00,每30分钟一个时间段)
|
||||
$start_hour = 9;
|
||||
$end_hour = 18;
|
||||
for ($hour = $start_hour; $hour < $end_hour; $hour++) {
|
||||
for ($minute = 0; $minute < 60; $minute += 30) {
|
||||
$time = sprintf('%02d:%02d', $hour, $minute);
|
||||
echo "<option value='$time'>$time</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="selected_package_<?php echo $submission['id']; ?>">选择套餐:</label>
|
||||
<select id="selected_package_<?php echo $submission['id']; ?>" name="selected_package" required>
|
||||
<?php foreach ($packages as $package): ?>
|
||||
<option value="<?php echo $package['id']; ?>">
|
||||
<?php echo htmlspecialchars($package['package_name']); ?> - <?php echo $package['price']; ?>元 (<?php echo $package['base_duration']; ?>分钟)
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="custom_notes_<?php echo $submission['id']; ?>">自定义备注:</label>
|
||||
<textarea id="custom_notes_<?php echo $submission['id']; ?>" name="custom_notes" rows="3"></textarea>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary">确认预约</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// 复制预约成功信息到剪贴板
|
||||
function copyMessage() {
|
||||
const message = document.getElementById('successMessage');
|
||||
const textArea = document.createElement('textarea');
|
||||
textArea.value = message.textContent;
|
||||
document.body.appendChild(textArea);
|
||||
textArea.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(textArea);
|
||||
|
||||
// 显示复制成功提示
|
||||
alert('预约信息已复制到剪贴板!');
|
||||
}
|
||||
|
||||
// 设置最小日期为今天
|
||||
document.querySelectorAll('input[type="date"]').forEach(input => {
|
||||
input.min = new Date().toISOString().split('T')[0];
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -151,6 +151,7 @@ try {
|
||||
<nav class="nav">
|
||||
<a href="index.php" class="nav-link">预约洗车</a>
|
||||
<a href="bookings.php" class="nav-link">预约管理</a>
|
||||
<a href="pending_bookings.php" class="nav-link">待预约处理</a>
|
||||
<a href="packages.php" class="nav-link">套餐管理</a>
|
||||
<a href="vip.php" class="nav-link active">VIP管理</a>
|
||||
<a href="announcement.php" class="nav-link">今日待办</a>
|
||||
|
||||
Reference in New Issue
Block a user