= '" . mysqli_real_escape_string($conn, $fliterFromDate) . "'"; $urlStr .= "&fliterFromDate=" . urlencode($fliterFromDate); } if (!empty($fliterToDate)) { $fliterStr .= " AND o.order_date <= '" . mysqli_real_escape_string($conn, $fliterToDate) . " 23:59:59'"; $urlStr .= "&fliterToDate=" . urlencode($fliterToDate); } // 搜索和排序 $keys = $_GET['Keys'] ?? ''; $keyscode = mysqli_real_escape_string($conn, $keys); $page = $_GET['Page'] ?? 1; $ord = $_GET['Ord'] ?? ''; $ordStr = !empty($ord) ? "$ord," : ""; // 构建查询SQL $employee_id = $_SESSION['employee_id']; $isAdmin = checkIfAdmin(); $sqlStr = "SELECT o.*, c.cs_company, c.cs_code FROM orders o LEFT JOIN customer c ON o.customer_id = c.id WHERE 1=1"; // 非管理员只能查看自己的订单 if (!$isAdmin) { $sqlStr .= " AND o.employee_id = $employee_id"; } if (!empty($keyscode)) { $sqlStr .= " AND (o.order_code LIKE '%$keyscode%' OR c.cs_company LIKE '%$keyscode%' OR c.cs_code LIKE '%$keyscode%')"; } $sqlStr .= " $fliterStr ORDER BY {$ordStr}o.created_at DESC"; ?> 订单列表

筛选条件

序号
销售订单号
客户编码
客户
出货日期
订单金额
操作
$totalPages) $page = $totalPages; // 计算起始记录 $offset = ($page - 1) * $pageSize; // 添加分页条件 $sqlStr .= " LIMIT $offset, $pageSize"; $result = mysqli_query($conn, $sqlStr); if (mysqli_num_rows($result) > 0) { $tempNum = ($page - 1) * $pageSize; while ($row = mysqli_fetch_assoc($result)) { $tempNum++; ?>
订单详情
总金额:
备注
当前暂无订单记录
'; } else { echo '
没有找到匹配的订单记录,点击返回
'; } } ?>
1) { $pageName = "?Keys=$keys$urlStr&"; $pageLen = 3; if ($page > 1) { echo "首页"; echo "上一页"; } if ($pageLen * 2 + 1 >= $totalPages) { $startPage = 1; $endPage = $totalPages; } else { if ($page <= $pageLen + 1) { $startPage = 1; $endPage = $pageLen * 2 + 1; } else { $startPage = $page - $pageLen; $endPage = $page + $pageLen; } if ($page + $pageLen > $totalPages) { $startPage = $totalPages - $pageLen * 2; $endPage = $totalPages; } } for ($i = $startPage; $i <= $endPage; $i++) { if ($i == $page) { echo "$i"; } else { echo "$i"; } } if ($page < $totalPages) { if ($totalPages - $page > $pageLen) { echo "...$totalPages"; } echo "下一页"; echo "尾页"; } } ?>