Quellcode durchsuchen

feat: update examine_status

igb vor 1 Tag
Ursprung
Commit
90ad65ef6c
3 geänderte Dateien mit 241 neuen und 29 gelöschten Zeilen
  1. 10 2
      get_rebate_details.php
  2. 230 27
      rebate_history.php
  3. 1 0
      system/employee.php

+ 10 - 2
get_rebate_details.php

@@ -16,6 +16,14 @@ if ($redemptionId <= 0) {
 $employee_id = $_SESSION['employee_id'];
 $isAdmin = checkIfAdmin();
 
+// 检查是否为财务角色或管理员
+$isFinance = false;
+$checkRoleSql = "SELECT em_permission_role_id FROM employee WHERE id = $employee_id";
+$roleResult = mysqli_query($conn, $checkRoleSql);
+if ($roleResult && $row = mysqli_fetch_assoc($roleResult)) {
+    $isFinance = ($row['em_permission_role_id'] == 6 || $row['em_permission_role_id'] == 1);
+}
+
 // 获取返点兑换详情
 $sql = "SELECT 
             rri.id,
@@ -44,8 +52,8 @@ $sql = "SELECT
         WHERE 
             rri.redemption_id = ?";
 
-// 非管理员只能查看自己客户的数据
-if (!$isAdmin) {
+// 非管理员和非财务只能查看自己客户的数据
+if (!$isAdmin && !$isFinance) {
     $sql .= " AND c.cs_belong = $employee_id";
 }
 

+ 230 - 27
rebate_history.php

@@ -29,6 +29,13 @@ $page = isset($_GET['Page']) ? intval($_GET['Page']) : 1;
 // 构建基本条件SQL
 $employee_id = $_SESSION['employee_id'];
 $isAdmin = checkIfAdmin();
+// 检查是否为财务角色或管理员
+$isFinance = false;
+$checkRoleSql = "SELECT em_permission_role_id FROM employee WHERE id = $employee_id";
+$roleResult = mysqli_query($conn, $checkRoleSql);
+if ($roleResult && $row = mysqli_fetch_assoc($roleResult)) {
+    $isFinance = ($row['em_permission_role_id'] == 6 || $row['em_permission_role_id'] == 1);
+}
 
 // 基础查询,计算总记录数
 $countSql = "SELECT COUNT(*) AS total 
@@ -36,11 +43,13 @@ $countSql = "SELECT COUNT(*) AS total
              JOIN customer c ON rr.customer_id = c.id
              WHERE 1=1";
 
-// 非管理员只能查看自己客户的返点历史
-if (!$isAdmin) {
+// 非管理员和非财务只能查看自己客户的返点历史
+if (!$isAdmin && !$isFinance) {
     $countSql .= " AND c.cs_belong = $employee_id";
 }
 
+
+
 // 添加搜索条件
 if (!empty($keyscode)) {
     $countSql .= " AND (c.cs_company LIKE '%$keyscode%' OR c.cs_code LIKE '%$keyscode%')";
@@ -81,7 +90,10 @@ $sql = "SELECT
             rr.total_rebate_amount,
             rr.notes,
             rr.status,
+            rr.examine_status,
+            rr.examine_date,
             e.em_user AS employee_name,
+            e2.em_user AS examine_by_name,
             (SELECT COUNT(DISTINCT product_id) FROM rebate_redemption_items WHERE redemption_id = rr.id) AS product_count
         FROM 
             rebate_redemptions rr
@@ -89,11 +101,13 @@ $sql = "SELECT
             customer c ON rr.customer_id = c.id
         LEFT JOIN
             employee e ON rr.created_by = e.id
+        LEFT JOIN
+            employee e2 ON rr.examine_by = e2.id
         WHERE 
             1=1";
 
-// 非管理员只能查看自己客户的返点历史
-if (!$isAdmin) {
+// 非管理员和非财务只能查看自己客户的返点历史
+if (!$isAdmin && !$isFinance) {
     $sql .= " AND c.cs_belong = $employee_id";
 }
 
@@ -118,6 +132,28 @@ $redemptions = [];
 while ($row = mysqli_fetch_assoc($result)) {
     $redemptions[] = $row;
 }
+
+// 处理审核操作
+if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'examine' && $isFinance) {
+    $redemptionId = isset($_POST['redemption_id']) ? intval($_POST['redemption_id']) : 0;
+    $examineStatus = isset($_POST['examine_status']) ? intval($_POST['examine_status']) : 0;
+    
+    if ($redemptionId > 0 && in_array($examineStatus, [1, 2])) {
+        $updateSql = "UPDATE rebate_redemptions 
+                      SET examine_status = $examineStatus,
+                          examine_date = NOW(),
+                          examine_by = $employee_id
+                      WHERE id = $redemptionId";
+        
+        if (mysqli_query($conn, $updateSql)) {
+            // 刷新页面以显示更新后的状态
+            echo "<script>window.location.href = window.location.href;</script>";
+            exit;
+        } else {
+            echo "<script>alert('审核操作失败: " . mysqli_error($conn) . "');</script>";
+        }
+    }
+}
 ?>
 <!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">
@@ -167,22 +203,22 @@ while ($row = mysqli_fetch_assoc($result)) {
         
         .col2 { width: 5%; text-align: center; }
         .col3 { width: 15%; }
-        .col4 { width: 20%; }
-        .col5 { width: 12%; text-align: center; }
-        .col6 { width: 10%; text-align: center; }
-        .col7 { width: 15%; text-align: right; }
-        .col8 { width: 10%; text-align: center; }
-        .col9 { width: 13%; text-align: center; }
+        .col4 { width: 12%; text-align: center; }
+        .col5 { width: 8%; text-align: center; }
+        .col6 { width: 15%; text-align: right; }
+        .col7 { width: 10%; text-align: center; }
+        .col8 { width: 15%; text-align: center; }
+        .col9 { width: 15%; text-align: center; }
 
         /* 表格布局修复 */
         .table2 .col2 { width: 5%; text-align: center; }
         .table2 .col3 { width: 15%; }
-        .table2 .col4 { width: 20%; }
-        .table2 .col5 { width: 12%; text-align: center; }
-        .table2 .col6 { width: 10%; text-align: center; }
-        .table2 .col7 { width: 15%; text-align: right; }
-        .table2 .col8 { width: 10%; text-align: center; }
-        .table2 .col9 { width: 13%; text-align: center; }
+        .table2 .col4 { width: 12%; text-align: center; }
+        .table2 .col5 { width: 8%; text-align: center; }
+        .table2 .col6 { width: 15%; text-align: right; }
+        .table2 .col7 { width: 10%; text-align: center; }
+        .table2 .col8 { width: 15%; text-align: center; }
+        .table2 .col9 { width: 15%; text-align: center; }
 
         .theader > div, .tline > div {
             padding: 0 5px;
@@ -194,7 +230,7 @@ while ($row = mysqli_fetch_assoc($result)) {
             justify-content: center;
         }
         
-        .col3, .col4 {
+        .col3 {
             justify-content: flex-start !important;
         }
         
@@ -249,6 +285,22 @@ while ($row = mysqli_fetch_assoc($result)) {
             text-decoration: line-through;
         }
         
+        /* 审核状态样式 */
+        .examine-pending {
+            color: #f39c12;
+            font-weight: bold;
+        }
+        
+        .examine-approved {
+            color: #27ae60;
+            font-weight: bold;
+        }
+        
+        .examine-rejected {
+            color: #e74c3c;
+            font-weight: bold;
+        }
+        
         /* 备注文本溢出控制 */
         .notes-text {
             max-width: 200px;
@@ -257,6 +309,90 @@ while ($row = mysqli_fetch_assoc($result)) {
             text-overflow: ellipsis;
             display: inline-block;
         }
+        
+        /* 审核操作按钮 */
+        .examine-btn {
+            display: inline-block;
+            padding: 3px 8px;
+            margin: 0 2px;
+            border-radius: 3px;
+            cursor: pointer;
+            text-decoration: none;
+            font-size: 12px;
+            color: white;
+            box-sizing: border-box;
+            height: 24px;
+            line-height: 18px;
+            vertical-align: middle;
+        }
+        
+
+        
+
+
+        .approve-btn {
+            background-color: #0f9d58; /* 绿色 */
+        }
+        
+        .reject-btn {
+            background-color: #db4437; /* 红色 */
+        }
+        
+        .examine-btn:hover {
+            opacity: 0.9;
+        }
+        
+        /* 模态窗口样式 */
+        .modal {
+            display: none;
+            position: fixed;
+            z-index: 1000;
+            left: 0;
+            top: 0;
+            width: 100%;
+            height: 100%;
+            background-color: rgba(0,0,0,0.5);
+        }
+        
+        .modal-content {
+            background-color: #fefefe;
+            margin: 15% auto;
+            padding: 20px;
+            border: 1px solid #888;
+            width: 300px;
+            border-radius: 5px;
+            text-align: center;
+        }
+        
+        .modal-buttons {
+            margin-top: 20px;
+            display: flex;
+            justify-content: center;
+        }
+        
+        .modal-btn {
+            padding: 5px 15px;
+            margin: 0 5px;
+            border-radius: 3px;
+            cursor: pointer;
+            display: inline-block;
+            min-width: 60px;
+            height: 30px;
+            line-height: 20px;
+            text-align: center;
+            font-size: 14px;
+            border: none;
+        }
+        
+        .confirm-btn {
+            background-color: #3498db;
+            color: white;
+        }
+        
+        .cancel-btn {
+            background-color: #95a5a6;
+            color: white;
+        }
     </style>
 </head>
 <body>
@@ -285,11 +421,11 @@ while ($row = mysqli_fetch_assoc($result)) {
         <div class="theader">
             <div class="col2">序号</div>
             <div class="col3">客户编码</div>
-<!--            <div class="col4">客户名称</div>-->
-            <div class="col5">兑换日期</div>
-            <div class="col6">产品数</div>
-            <div class="col7">返点金额</div>
-            <div class="col8">处理人</div>
+            <div class="col4">兑换日期</div>
+            <div class="col5">产品数</div>
+            <div class="col6">返点金额</div>
+            <div class="col7">处理人</div>
+            <div class="col8">审核状态</div>
             <div class="col9">操作</div>
         </div>
 
@@ -299,17 +435,44 @@ while ($row = mysqli_fetch_assoc($result)) {
             foreach ($redemptions as $redemption) {
                 $tempNum++;
                 $statusClass = $redemption['status'] == 1 ? 'status-active' : 'status-cancelled';
+                
+                // 审核状态
+                $examineStatusText = '未审核';
+                $examineStatusClass = 'examine-pending';
+                if ($redemption['examine_status'] == 1) {
+                    $examineStatusText = '已通过';
+                    $examineStatusClass = 'examine-approved';
+                } elseif ($redemption['examine_status'] == 2) {
+                    $examineStatusText = '已拒绝';
+                    $examineStatusClass = 'examine-rejected';
+                }
                 ?>
                 <div class="tline">
                     <div class="col2"><?= $tempNum ?></div>
                     <div class="col3 rb-slidepanel" data-id="<?= $redemption['redemption_id'] ?>"><?= htmlspecialcharsFix($redemption['cs_code']) ?></div>
-<!--                    <div class="col4 rb-slidepanel" data-id="--><?php //= $redemption['redemption_id'] ?><!--">--><?php //= htmlspecialcharsFix($redemption['customer_name']) ?><!--</div>-->
-                    <div class="col5"><?= date('Y-m-d', strtotime($redemption['redemption_date'])) ?></div>
-                    <div class="col6"><?= $redemption['product_count'] ?></div>
-                    <div class="col7 <?= $statusClass ?>"><?= number_format($redemption['total_rebate_amount'], 2) ?> 元</div>
-                    <div class="col8"><?= htmlspecialcharsFix($redemption['employee_name']) ?></div>
+                    <div class="col4"><?= date('Y-m-d', strtotime($redemption['redemption_date'])) ?></div>
+                    <div class="col5"><?= $redemption['product_count'] ?></div>
+                    <div class="col6 <?= $statusClass ?>"><?= number_format($redemption['total_rebate_amount'], 2) ?> 元</div>
+                    <div class="col7"><?= htmlspecialcharsFix($redemption['employee_name']) ?></div>
+                    <div class="col8 <?= $examineStatusClass ?>">
+                        <?= $examineStatusText ?>
+                        <?php if ($redemption['examine_status'] > 0 && !empty($redemption['examine_by_name'])): ?>
+                        <!-- <div style="font-size: 12px; color: #666; margin-top: 2px;">
+                            <?= htmlspecialcharsFix($redemption['examine_by_name']) ?>
+                            <br><?= date('m-d H:i', strtotime($redemption['examine_date'])) ?>
+                        </div> -->
+                        <?php endif; ?>
+                    </div>
                     <div class="col9">
                         <a href="javascript:void(0)" class="rb-toggleDetail" data-id="<?= $redemption['redemption_id'] ?>">查看详情</a>
+                        <?php if ($isFinance && $redemption['examine_status'] == 0 && $redemption['status'] == 1): ?>
+                        <span style="margin-left: 5px; display: inline-block;">
+                            <a href="javascript:void(0)" class="examine-btn approve-btn" 
+                               data-id="<?= $redemption['redemption_id'] ?>" data-status="1">通过</a>
+                            <a href="javascript:void(0)" class="examine-btn reject-btn" 
+                               data-id="<?= $redemption['redemption_id'] ?>" data-status="2">拒绝</a>
+                        </span>
+                        <?php endif; ?>
                     </div>
                 </div>
                 <div class="notepanel clear" id="detail-<?= $redemption['redemption_id'] ?>">
@@ -385,6 +548,22 @@ while ($row = mysqli_fetch_assoc($result)) {
         </div>
     </div>
 
+    <!-- 审核确认模态窗口 -->
+    <div id="examineModal" class="modal">
+        <div class="modal-content">
+            <p id="examineMessage">确认要执行此操作吗?</p>
+            <div class="modal-buttons">
+                <form id="examineForm" method="post">
+                    <input type="hidden" name="action" value="examine">
+                    <input type="hidden" name="redemption_id" id="modalRedemptionId" value="">
+                    <input type="hidden" name="examine_status" id="modalExamineStatus" value="">
+                    <button type="submit" class="modal-btn confirm-btn">确认</button>
+                    <button type="button" class="modal-btn cancel-btn" id="cancelExamine">取消</button>
+                </form>
+            </div>
+        </div>
+    </div>
+
     <script>
     $(document).ready(function() {
         // 添加日期验证逻辑
@@ -481,6 +660,30 @@ while ($row = mysqli_fetch_assoc($result)) {
             }
         });
         
+        // 审核按钮点击事件
+        $('.examine-btn').on('click', function() {
+            var redemptionId = $(this).data('id');
+            var examineStatus = $(this).data('status');
+            var actionText = examineStatus == 1 ? '通过' : '拒绝';
+            
+            $('#modalRedemptionId').val(redemptionId);
+            $('#modalExamineStatus').val(examineStatus);
+            $('#examineMessage').text('确认要' + actionText + '这条返点记录吗?');
+            $('#examineModal').show();
+        });
+        
+        // 取消审核按钮
+        $('#cancelExamine').on('click', function() {
+            $('#examineModal').hide();
+        });
+        
+        // 点击模态窗口外部关闭模态窗口
+        $(window).on('click', function(e) {
+            if ($(e.target).is('#examineModal')) {
+                $('#examineModal').hide();
+            }
+        });
+        
         // 加载返点详情
         function loadRedemptionDetails(redemptionId) {
             var $detailsContainer = $('#rebate-details-' + redemptionId);

+ 1 - 0
system/employee.php

@@ -165,6 +165,7 @@ if($act == "add" || $act == "edit") {
                         <option value="2" <?php echo (isset($em_permission_role_id) && $em_permission_role_id == 2) ? 'selected' : ''; ?>>2 * 组长</option>
                         <option value="3" <?php echo (isset($em_permission_role_id) && $em_permission_role_id == 3) ? 'selected' : ''; ?>>3 * 组员</option>
                         <option value="4" <?php echo (isset($em_permission_role_id) && $em_permission_role_id == 4) ? 'selected' : ''; ?>>4 * 分公司</option>
+                        <option value="6" <?php echo (isset($em_permission_role_id) && $em_permission_role_id == 6) ? 'selected' : ''; ?>>6 * 财务</option>
                         <option value="1" <?php echo (isset($em_permission_role_id) && $em_permission_role_id == 1) ? 'selected' : ''; ?>>1 * 管理员</option>
                     </select>
                 </td>