|
@@ -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);
|