prepare("SELECT attachment FROM work_orders WHERE id = ? AND creator_id = ? AND product_id = ? AND status = '未处理'"); $stmt->execute([$id, getCurrentUserId(), $pid]); $order = $stmt->fetch(); if ($order) { if ($order['attachment'] && file_exists(__DIR__ . '/' . $order['attachment'])) { unlink(__DIR__ . '/' . $order['attachment']); } $pdo->prepare('DELETE FROM work_orders WHERE id = ? AND product_id = ?')->execute([$id, $pid]); $_SESSION['flash_msg'] = '工单已撤销'; $_SESSION['flash_type'] = 'success'; } else { $_SESSION['flash_msg'] = '无法撤销:工单不存在、非本人发起或状态已变更'; $_SESSION['flash_type'] = 'danger'; } header('Location: work_order_records.php'); exit; } $pageTitle = '工单记录'; require __DIR__ . '/includes/header.php'; // 分页 $page = max(1, (int)($_GET['p'] ?? 1)); $perPage = 20; $offset = ($page - 1) * $perPage; $pid = getCurrentProductId(); $stmt = $pdo->prepare('SELECT COUNT(*) FROM work_orders WHERE creator_id = ? AND product_id = ?'); $stmt->execute([getCurrentUserId(), $pid]); $total = (int)$stmt->fetchColumn(); $totalPages = max(1, ceil($total / $perPage)); $stmt = $pdo->prepare('SELECT * FROM work_orders WHERE creator_id = ? AND product_id = ? ORDER BY created_at DESC LIMIT ? OFFSET ?'); $stmt->execute([getCurrentUserId(), $pid, $perPage, $offset]); $orders = $stmt->fetchAll(); ?>
+ 发起工单

我的工单

ID 内容 兑换码 附件 发起时间 状态 操作
100 ? '...' : '' ?> - 查看 - 撤销 已驳回 -
暂无工单