|
@@ -150,11 +150,58 @@ if ($act == "save") {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
// If we have output from processing, we'll show it instead of the normal page
|
|
|
if (!empty($output)) {
|
|
|
echo $output;
|
|
|
exit;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+// 批量操作
|
|
|
+if ($act == "postchk") {
|
|
|
+ $keys = urlencode($_GET['Keys'] ?? '');
|
|
|
+ $page = $_GET['Page'] ?? '';
|
|
|
+ $chkact = $_POST['chkact'] ?? '';
|
|
|
+
|
|
|
+ if (isset($_POST['chkbox']) && is_array($_POST['chkbox'])) {
|
|
|
+ $ids = array_map('intval', $_POST['chkbox']);
|
|
|
+ $idList = implode(',', $ids);
|
|
|
+
|
|
|
+ if (!empty($idList)) {
|
|
|
+ switch($chkact) {
|
|
|
+ case "0":
|
|
|
+ case "1":
|
|
|
+ $sql = "UPDATE customer SET cs_state=$chkact WHERE id IN ($idList)";
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ // In delete case, let's use transactions to ensure both tables are updated
|
|
|
+ $conn->begin_transaction();
|
|
|
+ try {
|
|
|
+ // Delete from customer_contact first (due to foreign key constraint)
|
|
|
+ $sql = "DELETE FROM customer_contact WHERE customer_id IN ($idList)";
|
|
|
+ $conn->query($sql);
|
|
|
+
|
|
|
+ // Then delete from customer table
|
|
|
+ $sql = "DELETE FROM customer WHERE id IN ($idList)";
|
|
|
+ $conn->query($sql);
|
|
|
+
|
|
|
+ $conn->commit();
|
|
|
+ } catch (Exception $e) {
|
|
|
+ $conn->rollback();
|
|
|
+ echo "<script>alert('删除失败: " . $e->getMessage() . "');</script>";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($chkact == "0" || $chkact == "1") {
|
|
|
+ $conn->query($sql);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ header("Location: ?Keys=$keys&Page=$page");
|
|
|
+ exit;
|
|
|
+}
|
|
|
+
|
|
|
?>
|
|
|
<!DOCTYPE html>
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
@@ -725,49 +772,7 @@ if ($act == "edit" || $act == "add") {
|
|
|
exit;
|
|
|
}
|
|
|
|
|
|
-// 批量操作
|
|
|
-if ($act == "postchk") {
|
|
|
- $keys = urlencode($_GET['Keys'] ?? '');
|
|
|
- $page = $_GET['Page'] ?? '';
|
|
|
- $chkact = $_POST['chkact'] ?? '';
|
|
|
-
|
|
|
- if (isset($_POST['chkbox']) && is_array($_POST['chkbox'])) {
|
|
|
- $ids = array_map('intval', $_POST['chkbox']);
|
|
|
- $idList = implode(',', $ids);
|
|
|
-
|
|
|
- if (!empty($idList)) {
|
|
|
- switch($chkact) {
|
|
|
- case "0":
|
|
|
- case "1":
|
|
|
- $sql = "UPDATE customer SET cs_state=$chkact WHERE id IN ($idList)";
|
|
|
- break;
|
|
|
- default:
|
|
|
- // In delete case, let's use transactions to ensure both tables are updated
|
|
|
- $conn->begin_transaction();
|
|
|
- try {
|
|
|
- // Delete from customer_contact first (due to foreign key constraint)
|
|
|
- $sql = "DELETE FROM customer_contact WHERE customer_id IN ($idList)";
|
|
|
- $conn->query($sql);
|
|
|
-
|
|
|
- // Then delete from customer table
|
|
|
- $sql = "DELETE FROM customer WHERE id IN ($idList)";
|
|
|
- $conn->query($sql);
|
|
|
-
|
|
|
- $conn->commit();
|
|
|
- } catch (Exception $e) {
|
|
|
- $conn->rollback();
|
|
|
- echo "<script>alert('删除失败: " . $e->getMessage() . "');</script>";
|
|
|
- }
|
|
|
- }
|
|
|
- if ($chkact == "0" || $chkact == "1") {
|
|
|
- $conn->query($sql);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- header("Location: ?Keys=$keys&Page=$page");
|
|
|
- exit;
|
|
|
-}
|
|
|
+
|
|
|
|
|
|
// 主列表页面
|
|
|
$fliterQudao = $_GET['fliterQudao'] ?? '';
|
|
@@ -845,6 +850,7 @@ $sql = "SELECT c.id, c.cs_code, c.cs_company, c.cs_country, c.cs_address,
|
|
|
OR cc.email_1 LIKE '%".$conn->real_escape_string($keyscode)."%'
|
|
|
OR cc.email_2 LIKE '%".$conn->real_escape_string($keyscode)."%'
|
|
|
OR cc.email_3 LIKE '%".$conn->real_escape_string($keyscode)."%')
|
|
|
+ AND c.cs_state=1
|
|
|
$filterStr
|
|
|
ORDER BY c.cs_updatetime DESC";
|
|
|
|
|
@@ -980,7 +986,7 @@ $tempNum = $pageSize * ($page - 1);
|
|
|
$tempNum++;
|
|
|
?>
|
|
|
<tr onMouseOver="this.style.background='#F7FCFF'" onMouseOut="this.style.background='#FFFFFF'">
|
|
|
- <td align="center"><input type="checkbox" name="chkbox" value="<?php echo $row['id'] ?? ''; ?>" /></td>
|
|
|
+ <td align="center"><input type="checkbox" name="chkbox[]" value="<?php echo $row['id'] ?? ''; ?>" /></td>
|
|
|
<td align="center"><?php echo $tempNum; ?></td>
|
|
|
<td align="center" class="code" data-id="<?php echo $row['id'] ?? ''; ?>">
|
|
|
<?php
|
|
@@ -1171,7 +1177,7 @@ $tempNum = $pageSize * ($page - 1);
|
|
|
<option value="0">隐藏</option>
|
|
|
<option value="-1">删除</option>
|
|
|
</select>
|
|
|
- <input type="button" value="执行" onClick="postchk(1)" class="btn1" />
|
|
|
+ <input type="button" value="执行" onClick="postchk_new(1)" class="btn1" />
|
|
|
<input type="button" value="新增" onClick="location.href='?act=add'" class="btn1" />
|
|
|
</div>
|
|
|
</td>
|