소스 검색

fleat: update Customer

igb 1 주 전
부모
커밋
f212ff38a4
3개의 변경된 파일191개의 추가작업 그리고 55개의 파일을 삭제
  1. 24 0
      customers.php
  2. 80 28
      customersFollow.php
  3. 87 27
      customersNew.php

+ 24 - 0
customers.php

@@ -428,6 +428,22 @@ if ($act == "postchk") {
             }
             $stmt->close();
             
+            // 检查是否有客户已经属于目标业务员
+            $checkSql = "SELECT GROUP_CONCAT(id) as existing_ids FROM customer 
+                         WHERE cs_belong = $employeeId AND id IN ({$ids})";
+            $checkResult = $conn->query($checkSql);
+            $existingIds = "";
+            
+            if ($checkResult && $checkRow = $checkResult->fetch_assoc()) {
+                $existingIds = $checkRow['existing_ids'];
+            }
+            
+            if (!empty($existingIds)) {
+                // 有客户已经属于该业务员,显示错误信息
+                echo "<script>alert('无法转移,客户ID:{$existingIds} 已经属于业务员【{$employeeName}】!');history.back();</script>";
+                exit;
+            }
+            
             // 更新客户记录
             $sql = "UPDATE customer SET 
                    cs_updatetime = NOW(),
@@ -600,6 +616,14 @@ $sqlStr .= " $fliterStr ORDER BY {$ordStr}c.cs_updatetime DESC";
             margin-left: 0;
 
         }
+ 
+
+        /*解决操作换行变形问题*/
+        .table2 .col9 {
+            white-space: nowrap;
+            overflow: hidden;
+        }
+      
     </style>
 </head>
 <body>

+ 80 - 28
customersFollow.php

@@ -1,6 +1,86 @@
 <?php
 require_once 'conn.php';
 checkLogin();
+
+
+$act = $_GET['act'] ?? '';
+
+if ($act == "postchk") {
+    $keys = urlencode($_GET['Keys'] ?? '');
+    $page = $_GET['Page'] ?? '';
+    $chkact = $_POST['chkact'] ?? '';
+
+    if (!empty($_POST['chkbox'])) {
+        $sqlStr = "";
+        $count = count($_POST['chkbox']);
+        $ids = implode(',', array_map('intval', $_POST['chkbox']));
+
+        foreach ($_POST['chkbox'] as $id) {
+            $sqlStr .= ($sqlStr ? " OR id=" : " WHERE id=") . (int)$id;
+        }
+
+        switch ($chkact) {
+            case "0":
+            case "1":
+            case "2":
+            case "3":
+                $sqlStr = "UPDATE customer SET cs_deal=" . $chkact . $sqlStr;
+
+                // 记录操作日志
+                $dealStatus = "";
+                switch($chkact) {
+                    case "0": $dealStatus = "无响应"; break;
+                    case "1": $dealStatus = "背景调查"; break;
+                    case "2": $dealStatus = "明确需求"; break;
+                    case "3": $dealStatus = "已成交"; break;
+                }
+                $action = "{$_SESSION['employee_name']} 将{$count}个客户({$ids})状态修改为【{$dealStatus}】";
+                logAction($action);
+                break;
+            default:
+                // 员工转让操作
+                $employeeId = str_replace("t", "", $chkact);
+                
+                // 检查是否有客户已经属于目标业务员
+                $checkSql = "SELECT GROUP_CONCAT(id) as existing_ids FROM customer 
+                             WHERE cs_belong = $employeeId AND id IN ($ids)";
+                $checkResult = $conn->query($checkSql);
+                $existingIds = "";
+                
+                if ($checkResult && $checkRow = $checkResult->fetch_assoc()) {
+                    $existingIds = $checkRow['existing_ids'];
+                }
+                
+                if (!empty($existingIds)) {
+                    // 有客户已经属于该业务员,显示错误信息
+                    echo "<script>alert('无法转移,客户ID:{$existingIds} 已经属于该业务员!');history.back();</script>";
+                    exit;
+                }
+                
+                $sqlStr = "UPDATE customer SET cs_belong=" . $employeeId . $sqlStr;
+                
+                // 获取员工名称
+                $stmt = $conn->prepare("SELECT em_code, em_user FROM employee WHERE id = ?");
+                $stmt->bind_param("i", $employeeId);
+                $stmt->execute();
+                $result = $stmt->get_result();
+                $employeeName = '未知业务员';
+                if ($row = $result->fetch_assoc()) {
+                    $employeeName = $row['em_user'];
+                }
+                $stmt->close();
+                
+                // 记录操作日志
+                $action = "{$_SESSION['employee_name']} 批量转移{$count}个客户({$ids})给业务员【{$employeeName}】";
+                logAction($action);
+        }
+
+        $conn->query($sqlStr);
+        header("Location: ?Keys=" . $keys . "&Page=" . $page);
+        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">
@@ -26,35 +106,7 @@ checkLogin();
 <?php // require_once 'panel.php'; ?>
 <div id="man_zone">
 <?php
-$act = $_GET['act'] ?? '';
 
-if ($act == "postchk") {
-    $keys = urlencode($_GET['Keys'] ?? '');
-    $page = $_GET['Page'] ?? '';
-    $chkact = $_POST['chkact'] ?? '';
-    
-    if (!empty($_POST['chkbox'])) {
-        $sqlStr = "";
-        foreach ($_POST['chkbox'] as $id) {
-            $sqlStr .= ($sqlStr ? " OR id=" : " WHERE id=") . (int)$id;
-        }
-        
-        switch ($chkact) {
-            case "0":
-            case "1":
-            case "2":
-            case "3":
-                $sqlStr = "UPDATE customer SET cs_deal=" . $chkact . $sqlStr;
-                break;
-            default:
-                $sqlStr = "UPDATE customer SET cs_belong=" . str_replace("t", "", $chkact) . $sqlStr;
-        }
-        
-        $conn->query($sqlStr);
-        header("Location: ?Keys=" . $keys . "&Page=" . $page);
-        exit;
-    }
-}
 
 $keys = $_GET['Keys'] ?? '';
 $keyscode = textEncode($keys);

+ 87 - 27
customersNew.php

@@ -1,6 +1,93 @@
 <?php
 require_once 'conn.php';
 checkLogin();
+
+$act = $_GET['act'] ?? '';
+
+if ($act == "postchk") {
+    $keys = urlencode($_GET['Keys'] ?? '');
+    $page = $_GET['Page'] ?? '';
+    $chkact = $_POST['chkact'] ?? '';
+
+    if (!empty($_POST['chkbox'])) {
+        $sqlStr = "";
+        $count = count($_POST['chkbox']);
+        $ids = implode(',', array_map('intval', $_POST['chkbox']));
+
+        foreach ($_POST['chkbox'] as $id) {
+            $sqlStr .= ($sqlStr ? " OR id=" : " WHERE id=") . (int)$id;
+        }
+
+        switch ($chkact) {
+            case "0":
+            case "1":
+            case "2":
+                $sqlStr = "UPDATE customer SET cs_deal=" . $chkact . $sqlStr;
+
+                // 记录操作日志
+                $dealStatus = "";
+                switch($chkact) {
+                    case "0": $dealStatus = "无响应"; break;
+                    case "1": $dealStatus = "背景调查"; break;
+                    case "2": $dealStatus = "明确需求"; break;
+                }
+                $action = "{$_SESSION['employee_name']} 将{$count}个客户({$ids})状态修改为【{$dealStatus}】";
+                logAction($action);
+                break;
+            default:
+                // 员工转让操作
+                $employeeId = str_replace("t", "", $chkact);
+
+                // 检查是否有客户已经属于目标业务员
+                $checkSql = "SELECT GROUP_CONCAT(id) as existing_ids FROM customer 
+                             WHERE cs_belong = $employeeId AND id IN ($ids)";
+                $checkResult = $conn->query($checkSql);
+                $existingIds = "";
+
+                if ($checkResult && $checkRow = $checkResult->fetch_assoc()) {
+                    $existingIds = $checkRow['existing_ids'];
+                }
+
+                if (!empty($existingIds)) {
+                    // 有客户已经属于该业务员,显示错误信息
+                    $stmt = $conn->prepare("SELECT em_user FROM employee WHERE id = ?");
+                    $stmt->bind_param("i", $employeeId);
+                    $stmt->execute();
+                    $result = $stmt->get_result();
+                    $employeeName = '未知业务员';
+                    if ($row = $result->fetch_assoc()) {
+                        $employeeName = $row['em_user'];
+                    }
+                    $stmt->close();
+
+                    echo "<script>alert('无法转移,客户ID:{$existingIds} 已经属于业务员【{$employeeName}】!');history.back();</script>";
+                    exit;
+                }
+
+                $sqlStr = "UPDATE customer SET cs_belong=" . $employeeId . $sqlStr;
+
+                // 获取员工名称
+                $stmt = $conn->prepare("SELECT em_code, em_user FROM employee WHERE id = ?");
+                $stmt->bind_param("i", $employeeId);
+                $stmt->execute();
+                $result = $stmt->get_result();
+                $employeeName = '未知业务员';
+                if ($row = $result->fetch_assoc()) {
+                    $employeeName = $row['em_user'];
+                }
+                $stmt->close();
+
+                // 记录操作日志
+                $action = "{$_SESSION['employee_name']} 批量转移{$count}个客户({$ids})给业务员【{$employeeName}】";
+                logAction($action);
+        }
+
+        $conn->query($sqlStr);
+        header("Location: ?Keys=" . $keys . "&Page=" . $page);
+        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">
@@ -27,34 +114,7 @@ checkLogin();
 <?php // require_once 'panel.php'; ?>
 <div id="man_zone">
 <?php
-$act = $_GET['act'] ?? '';
 
-if ($act == "postchk") {
-    $keys = urlencode($_GET['Keys'] ?? '');
-    $page = $_GET['Page'] ?? '';
-    $chkact = $_POST['chkact'] ?? '';
-    
-    if (!empty($_POST['chkbox'])) {
-        $sqlStr = "";
-        foreach ($_POST['chkbox'] as $id) {
-            $sqlStr .= ($sqlStr ? " OR id=" : " WHERE id=") . (int)$id;
-        }
-        
-        switch ($chkact) {
-            case "0":
-            case "1":
-            case "2":
-                $sqlStr = "UPDATE customer SET cs_deal=" . $chkact . $sqlStr;
-                break;
-            default:
-                $sqlStr = "UPDATE customer SET cs_belong=" . str_replace("t", "", $chkact) . $sqlStr;
-        }
-        
-        $conn->query($sqlStr);
-        header("Location: ?Keys=" . $keys . "&Page=" . $page);
-        exit;
-    }
-}
 
 $keys = $_GET['Keys'] ?? '';
 $keyscode = textEncode($keys);