Browse Source

fleat: update change

igb 6 days ago
parent
commit
dee24212a9
2 changed files with 17 additions and 6 deletions
  1. 4 1
      claimCustomer.php
  2. 13 5
      customers.php

+ 4 - 1
claimCustomer.php

@@ -35,6 +35,7 @@ if ($reachedLimit) {
     if ($row = $result->fetch_assoc()) {
         $oldCode = $row['cs_code'];
         $originalEmp = $row['em_user'];
+        $originalId= $row['cs_belong'];
         $newCode = str_replace("-", "/0" . substr($em_code, 1) . "-", $oldCode);
         
         // Update chain and check circulation
@@ -56,11 +57,13 @@ if ($reachedLimit) {
         $conn->query($updateSql);
         
         // Insert claim record
-        $insertSql = "INSERT INTO claimrecord (oldCode, originalEmp, newEmp, cs_id, claimTime, isread) 
+        $insertSql = "INSERT INTO claimrecord (oldCode, originalEmp,original_employee_id, newEmp,new_employee_id, cs_id, claimTime, isread) 
                      VALUES (
                          '" . $conn->real_escape_string($oldCode) . "',
                          '" . $conn->real_escape_string($originalEmp) . "',
+                         '" . $conn->real_escape_string($originalId) . "',
                          '" . $conn->real_escape_string($_SESSION['employee_name']) . "',
+                         '" . $conn->real_escape_string($_SESSION['employee_id']) . "',
                          " . $cid . ",
                          NOW(),
                          0

+ 13 - 5
customers.php

@@ -407,24 +407,27 @@ if ($act == "postchk") {
     if (isset($_POST['chkbox']) && isset($_POST['chkact'])) {
         $chkact = $_POST['chkact'];
         $ids = implode(',', array_map('intval', $_POST['chkbox']));
+        $count = count($_POST['chkbox']);
         
-        // Check if this is an employee transfer action
+        // 检查是否为员工转让操作
         if (substr($chkact, 0, 1) === 't') {
-            // Extract employee ID from the chkact value
+            // 从chkact值中提取员工ID
             $employeeId = (int)substr($chkact, 1);
             
-            // Get the employee code for the transfer
-            $stmt = $conn->prepare("SELECT em_code FROM employee WHERE id = ?");
+            // 获取员工代码和名称
+            $stmt = $conn->prepare("SELECT em_code, em_user FROM employee WHERE id = ?");
             $stmt->bind_param("i", $employeeId);
             $stmt->execute();
             $result = $stmt->get_result();
             $employeeCode = '';
+            $employeeName = '未知业务员';
             if ($row = $result->fetch_assoc()) {
                 $employeeCode = $row['em_code'];
+                $employeeName = $row['em_user'];
             }
             $stmt->close();
             
-            // Update customer records
+            // 更新客户记录
             $sql = "UPDATE customer SET 
                    cs_updatetime = NOW(),
                    cs_code = REPLACE(cs_code, '-', '/{$employeeCode}-'),
@@ -432,6 +435,11 @@ if ($act == "postchk") {
                    cs_chain = CONCAT(cs_chain, ',{$employeeId}')
                    WHERE id IN ({$ids})";
             mysqli_query($conn, $sql);
+            
+            // 记录操作日志
+            $action = "{$_SESSION['employee_name']} 批量转移{$count}个客户({$ids})给业务员【{$employeeName}】";
+            logAction($action);
+         
         } else {
             switch($chkact) {
                 case "0":