123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- <?php
- require_once 'conn.php';
- checkLogin();
- $id = $_GET['id'] ?? '';
- // 验证并获取订单数据
- if (!empty($id) && is_numeric($id)) {
- // 获取订单基本信息
- $employee_id = $_SESSION['employee_id'];
- $sql = "SELECT o.*, c.cs_company, c.cs_code, cc.contact_name, e.em_user as employee_name
- FROM orders o
- LEFT JOIN customer c ON o.customer_id = c.id
- LEFT JOIN customer_contact cc ON o.contact_id = cc.id
- LEFT JOIN employee e ON o.employee_id = e.id
- WHERE o.id = $id AND o.employee_id = $employee_id";
- $result = mysqli_query($conn, $sql);
- if ($row = mysqli_fetch_assoc($result)) {
- $order = $row;
- } else {
- echo "<script>alert('订单不存在或您没有权限查看');history.back();</script>";
- exit;
- }
- // 获取订单项信息
- $sql = "SELECT oi.*, p.ProductName
- FROM order_items oi
- LEFT JOIN products p ON oi.product_id = p.id
- WHERE oi.order_id = $id";
- $itemsResult = mysqli_query($conn, $sql);
- $orderItems = [];
- while ($itemRow = mysqli_fetch_assoc($itemsResult)) {
- $orderItems[] = $itemRow;
- }
- } else {
- echo "<script>alert('订单不存在!');history.back();</script>";
- exit;
- }
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>订单详情</title>
- <link rel="stylesheet" href="css/common.css" type="text/css" />
- <link rel="stylesheet" href="css/alert.css" type="text/css" />
- <script src="js/jquery-1.7.2.min.js"></script>
- <script src="js/js.js"></script>
- <style>
- body {
- margin: 0;
- padding: 20px;
- background: #fff;
- }
- #man_zone {
- margin-left: 0;
- }
- .order-info {
- border: 1px solid #ddd;
- padding: 15px;
- margin-bottom: 20px;
- background-color: #f9f9f9;
- }
- .order-info h2 {
- margin-top: 0;
- border-bottom: 1px solid #ddd;
- padding-bottom: 10px;
- }
- .order-info .info-row {
- margin-bottom: 10px;
- }
- .order-info .info-label {
- font-weight: bold;
- display: inline-block;
- width: 120px;
- }
- .products-table {
- width: 100%;
- border-collapse: collapse;
- margin-bottom: 20px;
- }
- .products-table th, .products-table td {
- border: 1px solid #ddd;
- padding: 8px;
- text-align: left;
- }
- .products-table th {
- background-color: #f2f2f2;
- }
- /* 移除徽章式样,使用普通文本显示 */
- .order-status {
- font-weight: bold;
- }
- .payment-status {
- font-weight: bold;
- }
- .notes-section {
- border: 1px solid #ddd;
- padding: 15px;
- margin-bottom: 20px;
- }
- .total-section {
- text-align: right;
- font-size: 1.1em;
- margin-top: 10px;
- border-top: 1px solid #ddd;
- padding-top: 10px;
- }
- </style>
- </head>
- <body>
- <div id="man_zone">
- <div align="right" style="margin-bottom: 10px;">
- <input type="button" value="返回订单列表" class="btn1" onClick="location.href='order.php'" />
- <input type="button" value="编辑此订单" class="btn1" onClick="location.href='order_edit.php?id=<?= $id ?>'" />
- </div>
- <div class="order-info">
- <h2>订单信息</h2>
- <div class="info-row">
- <span class="info-label">订单编号:</span> <?= htmlspecialcharsFix($order['order_code']) ?>
- </div>
- <div class="info-row">
- <span class="info-label">客户:</span>
- <?php if (!empty($order['cs_code'])): ?>
- <?= htmlspecialcharsFix($order['cs_code']) ?> -
- <?php endif; ?>
- <?= htmlspecialcharsFix($order['cs_company']) ?>
- </div>
- <div class="info-row">
- <span class="info-label">联系人:</span> <?= htmlspecialcharsFix($order['contact_name']) ?>
- </div>
- <div class="info-row">
- <span class="info-label">订单日期:</span> <?= date('Y-m-d', strtotime($order['order_date'])) ?>
- </div>
- <div class="info-row">
- <span class="info-label">创建时间:</span> <?= $order['created_at'] ?>
- </div>
- <div class="info-row">
- <span class="info-label">最后更新:</span> <?= $order['updated_at'] ?>
- </div>
- <div class="info-row">
- <span class="info-label">销售员:</span> <?= htmlspecialcharsFix($order['employee_name']) ?>
- </div>
- </div>
- <h2>订单产品</h2>
- <table class="products-table">
- <thead>
- <tr>
- <th>序号</th>
- <th>产品名称</th>
- <th>数量</th>
- <th>单位</th>
- <th>单价</th>
- <th>折扣</th>
- <th>总价</th>
- <th>备注</th>
- </tr>
- </thead>
- <tbody>
- <?php foreach ($orderItems as $index => $item): ?>
- <tr>
- <td><?= $index + 1 ?></td>
- <td><?= htmlspecialcharsFix($item['ProductName']) ?></td>
- <td><?= $item['quantity'] ?></td>
- <td><?= htmlspecialcharsFix($item['unit']) ?></td>
- <td><?= number_format($item['unit_price'], 2) ?></td>
- <td>
- <?php if ($item['discount_amount'] > 0): ?>
- <?= number_format($item['discount_amount'], 2) ?>
- (<?= number_format($item['discount_percent'], 2) ?>%)
- <?php else: ?>
- -
- <?php endif; ?>
- </td>
- <td><?= number_format($item['total_price'], 2) ?></td>
- <td><?= htmlspecialcharsFix($item['notes']) ?></td>
- </tr>
- <?php endforeach; ?>
- </tbody>
- </table>
- <div class="total-section">
- <!-- <div>-->
- <!-- <strong>订单小计:</strong> --><?php //= number_format($order['subtotal'], 2) ?>
- <!-- </div>-->
- <!-- --><?php //if(isset($order['discount_amount']) && $order['discount_amount'] > 0): ?>
- <!-- <div>-->
- <!-- <strong>订单折扣:</strong> --><?php //= number_format($order['discount_amount'], 2) ?>
- <!-- </div>-->
- <!-- --><?php //endif; ?>
- <div style="font-size: 1.2em; margin-top: 5px;">
- <strong>订单总额:</strong> <?= number_format($order['total_amount'], 2) ?>
- </div>
- </div>
- <?php if (!empty($order['notes'])): ?>
- <div class="notes-section">
- <h2>订单备注</h2>
- <div>
-
- <p><?= nl2br(htmlspecialcharsFix($order['notes'])) ?></p>
- </div>
- </div>
- <?php endif; ?>
- </div>
- </body>
- </html>
|