Parcourir la source

fleat: save order update

igb il y a 13 heures
Parent
commit
96e6e2cff7
4 fichiers modifiés avec 43 ajouts et 11 suppressions
  1. 4 1
      order.php
  2. 10 0
      order_save.php
  3. 16 0
      panel.php
  4. 13 10
      rebate_summary.php

+ 4 - 1
order.php

@@ -38,7 +38,8 @@ $ordStr = !empty($ord) ? "$ord," : "";
 // 构建查询SQL
 $employee_id = $_SESSION['employee_id'];
 $isAdmin = checkIfAdmin();
-$sqlStr = "SELECT o.*, c.cs_company, c.cs_code
+$sqlStr = "SELECT o.*, c.cs_company, c.cs_code,
+           DATEDIFF(NOW(), o.created_at) as days_diff
            FROM orders o
            LEFT JOIN customer c ON o.customer_id = c.id
            WHERE 1=1";
@@ -286,7 +287,9 @@ $sqlStr .= " $fliterStr ORDER BY {$ordStr}o.created_at DESC";
                     <div class="col7"><?= date('Y-m-d', strtotime($row['order_date'])) ?></div>
                     <div class="col9"><?= number_format($row['total_amount'], 2) ?></div>
                     <div class="col10">
+                        <?php if ($isAdmin || $row['days_diff'] <= 30): ?>
                         <a href="order_edit.php?id=<?= $row['id'] ?>&keys=<?= $keys ?>&page=<?= $page ?>" class="ico_edit ico">修改</a>
+                        <?php endif; ?>
                         <a href="order_details.php?id=<?= $row['id'] ?>" class="ico_view ico">查看详情</a>
                         <?php if ($isAdmin): ?>
                         <a href="javascript:void(0)" onclick="confirmDelete(<?= $row['id'] ?>, '<?= htmlspecialcharsFix($row['order_code']) ?>')" class="ico_del ico">删除</a>

+ 10 - 0
order_save.php

@@ -18,6 +18,16 @@ if (!empty($id) && is_numeric($id)) {
             echo "<script>alert('您没有权限编辑此订单!');history.back();</script>";
             exit;
         }
+        
+        // 检查订单创建时间,非管理员不能编辑超过30天的订单
+        $orderDateQuery = "SELECT DATEDIFF(NOW(), created_at) as days_diff FROM orders WHERE id = $id";
+        $orderDateResult = mysqli_query($conn, $orderDateQuery);
+        $orderDateData = mysqli_fetch_assoc($orderDateResult);
+        
+        if ($orderDateData['days_diff'] > 30) {
+            echo "<script>alert('超过30天的订单只有管理员可以编辑!');history.back();</script>";
+            exit;
+        }
     }
 }
 

+ 16 - 0
panel.php

@@ -103,6 +103,22 @@ $stmt->close();
                     </div>
                 </dt>
             <?php endif; ?>
+            <dt>
+                <?php
+                // 获取未读消息数量
+                $unread_sql = "SELECT COUNT(*) as count FROM messages m 
+                            LEFT JOIN message_recipients mr ON m.id = mr.message_id AND mr.employee_id = {$_SESSION['employee_id']}
+                            WHERE (m.target_type = 2 AND (mr.id IS NULL OR (mr.is_read = 0 AND mr.is_deleted = 0)))
+                                OR (mr.employee_id = {$_SESSION['employee_id']} AND mr.is_read = 0 AND mr.is_deleted = 0)";
+                $unread_result = mysqli_query($conn, $unread_sql);
+                $unread_count = mysqli_fetch_assoc($unread_result)['count'];
+                ?>
+                <a href="../message_list.php" target="contentFrame">消息列表
+                    <?php if($unread_count > 0): ?>
+                    <span class="badge badge-danger" style="background-color: #d9534f; color: white; padding: 2px 5px; border-radius: 50%; font-size: 12px; margin-left: 5px;"><?= $unread_count ?></span>
+                    <?php endif; ?>
+                </a>
+            </dt>            
             <dt><a href="../pwdEdit.php" target="contentFrame">修改密码</a></dt>
             <dt><a href="../index.php?act=logout" onclick="return confirm('确认要退出吗?');">退出登录</a></dt>
 

+ 13 - 10
rebate_summary.php

@@ -132,9 +132,11 @@ $customerDetailSql = "
 SELECT 
     c.id AS customer_id,
     c.cs_company AS customer_name,
-    c.cs_code
+    c.cs_code,
+    c.cs_belong,
+    o.em_user AS employee_name
 FROM 
-    customer c
+    customer c left join employee  o ON c.cs_belong = o.id
 WHERE 
     c.id IN ($paginatedIdsStr)";
 
@@ -318,8 +320,8 @@ if (!empty($customers)) {
         }
         
         .col2 { width: 5%; text-align: center; }
-        .col3 { width: 15%; }
-        .col4 { width: 25%; }
+        .col3 { width: 25%; }
+        .col4 { width: 15%; }
         .col5 { width: 10%; text-align: center; }
         .col6 { width: 15%; text-align: right; }
         .col7 { width: 10%; text-align: center; }
@@ -327,8 +329,8 @@ if (!empty($customers)) {
 
         /* 表格布局修复,因为 "css/common.css 覆盖了 */
         .table2 .col2 { width: 5%; text-align: center; }
-        .table2 .col3 { width: 15%; }
-        .table2 .col4 { width: 25%; }
+        .table2 .col3 { width: 25%; }
+        .table2 .col4 { width: 15%; }
         .table2 .col5 { width: 10%; text-align: center; }
         .table2 .col6 { width: 15%; text-align: right; }
         .table2 .col7 { width: 10%; text-align: center; }
@@ -418,7 +420,7 @@ if (!empty($customers)) {
             <div class="col4">客户名称</div>
             <div class="col5">返点产品数</div>
             <div class="col6">返点金额合计</div>
-            <div class="col7">查看详情</div>
+            <div class="col7">处理人</div>
             <div class="col8">操作</div>
         </div>
 
@@ -426,6 +428,7 @@ if (!empty($customers)) {
         if (!empty($customers)) {
             $tempNum = ($page - 1) * $pageSize;
             foreach ($customers as $customer) {
+
                 $tempNum++;
                 ?>
                 <div class="tline">
@@ -435,7 +438,7 @@ if (!empty($customers)) {
                     <div class="col5"><?= $customer['qualifying_products'] ?></div>
                     <div class="col6"><?= number_format($customer['total_rebate_amount'], 2) ?> 元</div>
                     <div class="col7">
-                        <a href="javascript:void(0)" class="toggleDetail" data-id="<?= $customer['customer_id'] ?>">展开详情</a>
+                        <a href="javascript:void(0)" class="toggleDetail" data-id="<?= $customer['customer_id'] ?>"><?php echo $customer['employee_name'];?></a>
                     </div>
                     <div class="col8">
                         <a href="rebate_redeem.php?customer_id=<?= $customer['customer_id'] ?>" class="ico_edit ico">处理兑换</a>
@@ -563,10 +566,10 @@ if (!empty($customers)) {
             
             if (detailPanel.is(':visible')) {
                 detailPanel.slideUp();
-                $(this).text('展开详情');
+                //$(this).text('展开详情');
             } else {
                 detailPanel.slideDown();
-                $(this).text('收起详情');
+                //$(this).text('收起详情');
             }
         });