123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333 |
- <?php
- require_once 'conn.php';
- checkLogin();
- ?>
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>管理区域</title>
- <link rel="stylesheet" href="css/common.css" type="text/css" />
- <link rel="stylesheet" href="css/alert.css" type="text/css" />
- <script src="system/js/jquery-1.7.2.min.js"></script>
- <script src="js/js.js"></script>
- <style>
- body {
- margin: 0;
- padding: 20px;
- background: #fff;
- }
- #man_zone {
- margin-left: 0;
- }
- </style>
- </head>
- <body class="clear">
- <?php // require_once 'panel.php'; ?>
- <div id="man_zone">
- <?php
- $act = $_GET['act'] ?? '';
- $page = $_GET['Page'] ?? '';
- $keys = urlencode($_GET['Keys'] ?? '');
- $hrefstr = "?keys=" . $keys;
- // 使用SQL拼接方式
- $employee_id = intval($_SESSION['employee_id']);
- ?>
- <form id="form1" method="post" action="?act=postchk&Keys=<?= $keys ?>&Page=<?= $page ?>" onSubmit="return false">
- <div class="fastSelect clear">
- <H1>异常客户</H1>
- </div>
- <div width="100%" border="0" cellpadding="3" cellspacing="1" class="table2 em<?= $employee_id ?>">
- <div class="theader">
- <div class="col1"><input type="checkbox" name="chkall" id="chkall" onClick="chkboxall(this,'chkbox')" /></div>
- <div class="col2">序号</div>
- <div class="col3">客户编号</div>
- <div class="col4">渠道来源</div>
- <div class="col5">区域</div>
- <div class="col6">客户类型</div>
- <div class="col6">跟进阶段</div>
- <div class="colmark">颜色标记</div>
- <div class="col6">录入时间</div>
- <div class="col9">操作</div>
- </div>
- <?php
- // 适配新的customer_contact表结构并使用SQL拼接方式
- $sqlStr = "SELECT c.id,
- MAX(c.cs_code) as cs_code,
- MAX(c.cs_from) as cs_from,
- MAX(c.cs_country) as cs_country,
- MAX(c.cs_type) as cs_type,
- MAX(c.cs_deal) as cs_deal,
- MAX(c.cs_addtime) as cs_addtime,
- MAX(c.colortag) as colortag,
- MAX(c.cs_note) as cs_note,
- MAX(c.cs_claimFrom) as cs_claimFrom,
- GROUP_CONCAT(DISTINCT cc.id) as contact_ids,
- GROUP_CONCAT(DISTINCT cc.contact_name) as contact_names,
- GROUP_CONCAT(DISTINCT cc.tel_1) as tel_1_list,
- GROUP_CONCAT(DISTINCT cc.tel_2) as tel_2_list,
- GROUP_CONCAT(DISTINCT cc.tel_3) as tel_3_list,
- GROUP_CONCAT(DISTINCT cc.email_1) as email_1_list,
- GROUP_CONCAT(DISTINCT cc.email_2) as email_2_list,
- GROUP_CONCAT(DISTINCT cc.email_3) as email_3_list,
- GROUP_CONCAT(DISTINCT cc.whatsapp_1) as whatsapp_1_list,
- GROUP_CONCAT(DISTINCT cc.whatsapp_2) as whatsapp_2_list,
- GROUP_CONCAT(DISTINCT cc.whatsapp_3) as whatsapp_3_list,
- GROUP_CONCAT(DISTINCT cc.wechat_1) as wechat_1_list,
- GROUP_CONCAT(DISTINCT cc.wechat_2) as wechat_2_list,
- GROUP_CONCAT(DISTINCT cc.wechat_3) as wechat_3_list,
- GROUP_CONCAT(DISTINCT cc.linkedin_1) as linkedin_1_list,
- GROUP_CONCAT(DISTINCT cc.linkedin_2) as linkedin_2_list,
- GROUP_CONCAT(DISTINCT cc.linkedin_3) as linkedin_3_list,
- GROUP_CONCAT(DISTINCT cc.facebook_1) as facebook_1_list,
- GROUP_CONCAT(DISTINCT cc.facebook_2) as facebook_2_list,
- GROUP_CONCAT(DISTINCT cc.facebook_3) as facebook_3_list,
- GROUP_CONCAT(DISTINCT cc.alibaba_1) as alibaba_1_list,
- GROUP_CONCAT(DISTINCT cc.alibaba_2) as alibaba_2_list,
- GROUP_CONCAT(DISTINCT cc.alibaba_3) as alibaba_3_list
- FROM customer c
- LEFT JOIN customer_contact cc ON c.id = cc.customer_id
- WHERE (
- (NOT EXISTS (SELECT 1 FROM customer_contact WHERE customer_id = c.id AND alibaba_1 <> '')
- AND (c.cs_code LIKE '%阿里%' OR c.cs_code LIKE '%1688%')
- AND c.cs_belong = " . $employee_id . ")
- OR
- (c.cs_from = 8
- AND NOT EXISTS (SELECT 1 FROM customer_contact WHERE customer_id = c.id AND wechat_1 <> '')
- AND c.cs_belong = " . $employee_id . ")
- )
- GROUP BY c.id
- ORDER BY MAX(c.colortag) DESC, c.id DESC";
- $result = $conn->query($sqlStr);
- if ($result && $result->num_rows > 0) {
- $pageSize = 20;
- $page = empty($page) ? 1 : $page;
- $page = $page === 'end' ? ceil($result->num_rows / $pageSize) : $page;
- $page = !is_numeric($page) || $page < 1 ? 1 : (int)$page;
- $totalPages = ceil($result->num_rows / $pageSize);
- $page = $page > $totalPages ? $totalPages : $page;
- $offset = $pageSize * ($page - 1);
-
- // Store all results in array
- $rows = [];
- while ($row = $result->fetch_assoc()) {
- $rows[] = $row;
- }
-
- // Get paginated results
- $paginatedRows = array_slice($rows, $offset, $pageSize);
- $tempNum = $offset;
-
- foreach ($paginatedRows as $row) {
- $tempNum++;
- ?>
- <div class="tline color<?= $row['colortag'] ?>">
- <div class="col1" align="center"><input type="checkbox" name="chkbox[]" value="<?= $row['id'] ?>" /></div>
- <div class="col2"><?= $tempNum ?></div>
- <div class="col3 slidepanel"><?= htmlspecialcharsFix($row['cs_code']) ?><?php if ($row['cs_claimFrom'] > 0): ?><img src="../images/yijiao.png" class="handover" title="来自认领"><?php endif; ?></div>
- <div class="col4">
- <?php
- // 使用SQL拼接方式
- $cs_from = intval($row['cs_from']);
- $qudaoResult = $conn->query("SELECT ch_name FROM qudao WHERE id = " . $cs_from);
- if ($qudaoRow = $qudaoResult->fetch_assoc()) {
- echo htmlspecialcharsFix($qudaoRow['ch_name']);
- } else {
- echo "未填写";
- }
- ?>
- </div>
- <div class="col5">
- <?php
- // 使用SQL拼接方式
- $cs_country = intval($row['cs_country']);
- $countryResult = $conn->query("SELECT countryName FROM country WHERE id = " . $cs_country);
- if ($countryRow = $countryResult->fetch_assoc()) {
- echo htmlspecialcharsFix($countryRow['countryName']);
- } else {
- echo "未填写";
- }
- ?>
- </div>
- <div class="col6">
- <?php
- // 使用SQL拼接方式
- $cs_type = intval($row['cs_type']);
- $typeResult = $conn->query("SELECT businessType FROM clienttype WHERE id = " . $cs_type);
- if ($typeRow = $typeResult->fetch_assoc()) {
- echo htmlspecialcharsFix($typeRow['businessType']);
- } else {
- echo "未填写";
- }
- ?>
- </div>
- <div class="col6">
- <?php
- switch ($row['cs_deal']) {
- case 3:
- echo '<span style="color:red;">成交</span>';
- break;
- case 2:
- echo '明确需求';
- break;
- case 1:
- echo '背景调查';
- break;
- default:
- echo '无响应';
- }
- ?>
- </div>
- <div class="colmark colormark">
- <ul class="colorlist" data-id="<?= $row['id'] ?>">
- <li value="1" class="color1"></li>
- <li value="2" class="color2"></li>
- <li value="3" class="color3"></li>
- <li value="4" class="color4"></li>
- <li value="0" class="color0"></li>
- </ul>
- </div>
- <div class="col6"><?= $row['cs_addtime'] ?></div>
- <div class="col9"><a href="customerEdit.php?Keys=<?= $keys ?>&fliterDeal=<?= $_GET['fliterDeal'] ?? '' ?>&fliterBusiness=<?= $_GET['fliterBusiness'] ?? '' ?>&Page=<?= $page ?>&act=edit&id=<?= $row['id'] ?>" class="ico_edit ico">修改</a></div>
- </div>
- <div class="notepanel clear">
- <div class="noteItem">联系方式</div>
- <div class="lx">
- <?php
- // 显示联系人和联系方式
- $contacts = explode(',', $row['contact_names']);
- $contactIds = explode(',', $row['contact_ids']);
-
- // 处理电话
- echo '<div class="tel">';
- if (!empty($row['tel_1_list'])) echo htmlspecialcharsFix($row['tel_1_list']) . '<br>';
- if (!empty($row['tel_2_list'])) echo htmlspecialcharsFix($row['tel_2_list']) . '<br>';
- if (!empty($row['tel_3_list'])) echo htmlspecialcharsFix($row['tel_3_list']);
- echo '</div>';
-
- // 处理邮箱
- echo '<div class="mail">';
- if (!empty($row['email_1_list'])) echo '<a href="mailto:' . htmlspecialcharsFix($row['email_1_list']) . '">' . htmlspecialcharsFix($row['email_1_list']) . '</a><br>';
- if (!empty($row['email_2_list'])) echo '<a href="mailto:' . htmlspecialcharsFix($row['email_2_list']) . '">' . htmlspecialcharsFix($row['email_2_list']) . '</a><br>';
- if (!empty($row['email_3_list'])) echo '<a href="mailto:' . htmlspecialcharsFix($row['email_3_list']) . '">' . htmlspecialcharsFix($row['email_3_list']) . '</a>';
- echo '</div>';
-
- // 处理WhatsApp
- echo '<div class="whatsapp">';
- if (!empty($row['whatsapp_1_list'])) echo htmlspecialcharsFix($row['whatsapp_1_list']) . '<br>';
- if (!empty($row['whatsapp_2_list'])) echo htmlspecialcharsFix($row['whatsapp_2_list']) . '<br>';
- if (!empty($row['whatsapp_3_list'])) echo htmlspecialcharsFix($row['whatsapp_3_list']);
- echo '</div>';
-
- // 处理微信
- echo '<div class="wechat">';
- if (!empty($row['wechat_1_list'])) echo htmlspecialcharsFix($row['wechat_1_list']) . '<br>';
- if (!empty($row['wechat_2_list'])) echo htmlspecialcharsFix($row['wechat_2_list']) . '<br>';
- if (!empty($row['wechat_3_list'])) echo htmlspecialcharsFix($row['wechat_3_list']);
- echo '</div>';
-
- // 处理LinkedIn
- echo '<div class="linkedin">';
- if (!empty($row['linkedin_1_list'])) echo htmlspecialcharsFix($row['linkedin_1_list']) . '<br>';
- if (!empty($row['linkedin_2_list'])) echo htmlspecialcharsFix($row['linkedin_2_list']) . '<br>';
- if (!empty($row['linkedin_3_list'])) echo htmlspecialcharsFix($row['linkedin_3_list']);
- echo '</div>';
-
- // 处理Facebook
- echo '<div class="facebook">';
- if (!empty($row['facebook_1_list'])) echo htmlspecialcharsFix($row['facebook_1_list']) . '<br>';
- if (!empty($row['facebook_2_list'])) echo htmlspecialcharsFix($row['facebook_2_list']) . '<br>';
- if (!empty($row['facebook_3_list'])) echo htmlspecialcharsFix($row['facebook_3_list']);
- echo '</div>';
-
- // 处理阿里巴巴
- echo '<div class="alibaba">';
- if (!empty($row['alibaba_1_list'])) echo htmlspecialcharsFix($row['alibaba_1_list']) . '<br>';
- if (!empty($row['alibaba_2_list'])) echo htmlspecialcharsFix($row['alibaba_2_list']) . '<br>';
- if (!empty($row['alibaba_3_list'])) echo htmlspecialcharsFix($row['alibaba_3_list']);
- echo '</div>';
- ?>
- </div>
- <div class="noteItem2">备注</div>
- <div class="notecontent"><?= htmlUnCode($row['cs_note']) ?></div>
- </div>
- <?php
- }
- } else {
- if (empty($keys)) {
- ?>
- <tr>
- <div align="center" colspan="9">Sorry,当前暂无信息</div>
- </tr>
- <?php
- } else {
- ?>
- <tr>
- <div align="center" colspan="9"><a href="?">Sorry,没有找到"<?= $keyscode ?? '' ?>"相关的信息,点击返回</a></div>
- </tr>
- <?php
- }
- }
- ?>
- <div colspan="9">
- <div class="showpagebox">
- <?php
- if (isset($totalPages) && $totalPages > 1) {
- $pageName = "?Keys=" . $keys . ($urlStr ?? '') . "&";
- $pagelen = 3;
- // First page and Previous page
- if ($page > 1) {
- echo "<a href=\"{$pageName}Page=1\">首页</a>";
- echo "<a href=\"{$pageName}Page=" . ($page - 1) . "\">上一页</a>";
- }
- // Calculate page range
- if ($pagelen * 2 + 1 >= $totalPages) {
- $startPage = 1;
- $endPage = $totalPages;
- } else {
- if ($page <= $pagelen + 1) {
- $startPage = 1;
- $endPage = $pagelen * 2 + 1;
- } else {
- $startPage = $page - $pagelen;
- $endPage = $page + $pagelen;
- }
- if ($page + $pagelen > $totalPages) {
- $startPage = $totalPages - $pagelen * 2;
- $endPage = $totalPages;
- }
- }
- // Page numbers
- for ($i = $startPage; $i <= $endPage; $i++) {
- if ($i == $page) {
- echo "<a class=\"current\">{$i}</a>";
- } else {
- echo "<a href=\"{$pageName}Page={$i}\">{$i}</a>";
- }
- }
- // Next page and Last page
- if ($page < $totalPages) {
- if ($totalPages - $page > $pagelen) {
- echo "<a href=\"{$pageName}Page={$totalPages}\">...{$totalPages}</a>";
- }
- echo "<a href=\"{$pageName}Page=" . ($page + 1) . "\">下一页</a>";
- echo "<a href=\"{$pageName}Page={$totalPages}\">尾页</a>";
- }
- }
- ?>
- </div>
- </div>
- </div>
- </form>
- </div>
- </body>
- </html>
|