tag.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <?php
  2. require_once 'conn.php';
  3. checkLogin();
  4. $act = $_GET['act'] ?? '';
  5. $tagName = $_GET['tagName'] ?? '';
  6. if (empty($tagName)) {
  7. header('Location: customers.php');
  8. exit;
  9. }
  10. if ($act == 'postchk') {
  11. $keys = urlencode($_GET['Keys'] ?? '');
  12. $chkact = str_replace('t', '', $_POST['chkact'] ?? '');
  13. if (isset($_POST['chkbox'])) {
  14. $sqlStr = "(" . implode(',', array_map('intval', (array)$_POST['chkbox'])) . ")";
  15. $updateStr = "UPDATE customer SET
  16. cs_updatetime='" . date('Y-m-d H:i:s') . "',
  17. cs_code=REPLACE(cs_code, '-', '/' + (SELECT em_code FROM employee WHERE id=" . (int)$chkact . ") + '-'),
  18. cs_belong=" . (int)$chkact . ",
  19. cs_chain=CONCAT(cs_chain,'," . (int)$chkact . "')
  20. WHERE id IN " . $sqlStr;
  21. $deleteTag = "DELETE FROM tagtable WHERE customerId IN " . $sqlStr;
  22. $conn->query($updateStr);
  23. $conn->query($deleteTag);
  24. }
  25. header('Location: tag.php?tagName=' . urlencode($tagName));
  26. exit;
  27. }
  28. // Get all tags for the current employee
  29. $tagStr = '';
  30. $result = $conn->query("SELECT DISTINCT tagName FROM tagtable WHERE employeeId=" . $_SESSION['employee_id']);
  31. while ($row = $result->fetch_assoc()) {
  32. $tagStr .= "<span>" . htmlspecialcharsFix($row['tagName']) . "</span>,";
  33. }
  34. ?>
  35. <!DOCTYPE html>
  36. <html xmlns="http://www.w3.org/1999/xhtml">
  37. <head>
  38. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  39. <title>管理区域</title>
  40. <link rel="stylesheet" href="css/common.css" type="text/css" />
  41. <link rel="stylesheet" href="css/alert.css" type="text/css" />
  42. <script src="system/js/jquery-1.7.2.min.js"></script>
  43. <script src="js/js.js"></script>
  44. <style>
  45. body {
  46. margin: 0;
  47. padding: 20px;
  48. background: #fff;
  49. }
  50. #man_zone {
  51. margin-left: 0;
  52. }
  53. </style>
  54. </head>
  55. <body class="clear">
  56. <?php // require_once 'panel.php'; ?>
  57. <div id="man_zone">
  58. <div class="fastSelect clear">
  59. <H1 class="taghead" contenteditable="true" data-originaltag="<?= htmlspecialcharsFix($tagName) ?>" data-em="<?= $_SESSION['employee_id'] ?>"><?= htmlspecialcharsFix($tagName) ?></H1>
  60. </div>
  61. <form id="form1" method="post" action="?act=postchk&tagName=<?= urlencode($tagName) ?>" onsubmit="return false">
  62. <div width="100%" border="0" cellpadding="3" cellspacing="1" class="table2">
  63. <div class="theader">
  64. <div class="col1"><input type="checkbox" name="chkall" id="chkall" onclick="chkboxall(this,'chkbox')"></div>
  65. <div class="col2">序号</div>
  66. <div class="col3">客户编号</div>
  67. <div class="col4">渠道来源</div>
  68. <div class="col5">区域</div>
  69. <div class="col7">跟进阶段</div>
  70. <div class="col8">录入时间</div>
  71. <div class="col10">操作</div>
  72. </div>
  73. <?php
  74. $sqlStr = "SELECT c.id, c.cs_code, c.cs_from, c.cs_country, c.cs_type, c.cs_deal, c.cs_addtime, c.cs_note,
  75. cc.id as contact_id, cc.contact_name,
  76. cc.tel_1, cc.tel_1_format, cc.tel_1_bu,
  77. cc.tel_2, cc.tel_2_format, cc.tel_2_bu,
  78. cc.tel_3, cc.tel_3_format, cc.tel_3_bu,
  79. cc.email_1, cc.email_1_bu,
  80. cc.email_2, cc.email_2_bu,
  81. cc.email_3, cc.email_3_bu,
  82. cc.whatsapp_1, cc.whatsapp_1_format, cc.whatsapp_1_bu,
  83. cc.whatsapp_2, cc.whatsapp_2_format, cc.whatsapp_2_bu,
  84. cc.whatsapp_3, cc.whatsapp_3_format, cc.whatsapp_3_bu,
  85. cc.wechat_1, cc.wechat_1_bu,
  86. cc.wechat_2, cc.wechat_2_bu,
  87. cc.wechat_3, cc.wechat_3_bu,
  88. cc.linkedin_1, cc.linkedin_1_bu,
  89. cc.linkedin_2, cc.linkedin_2_bu,
  90. cc.linkedin_3, cc.linkedin_3_bu,
  91. cc.facebook_1, cc.facebook_1_bu,
  92. cc.facebook_2, cc.facebook_2_bu,
  93. cc.facebook_3, cc.facebook_3_bu,
  94. cc.alibaba_1, cc.alibaba_1_bu,
  95. cc.alibaba_2, cc.alibaba_2_bu,
  96. cc.alibaba_3, cc.alibaba_3_bu
  97. FROM customer c
  98. LEFT JOIN customer_contact cc ON c.id = cc.customer_id
  99. WHERE c.cs_belong=" . $_SESSION['employee_id'] . "
  100. AND c.id IN (SELECT customerId FROM tagtable WHERE tagName='" . $conn->real_escape_string($tagName) . "')";
  101. $result = $conn->query($sqlStr);
  102. $tempNum = 0;
  103. while ($row = $result->fetch_assoc()) {
  104. $tempNum++;
  105. ?>
  106. <div class="tline">
  107. <div class="col1" align="center"><input type="checkbox" name="chkbox[]" value="<?= $row['id'] ?>"></div>
  108. <div class="col2"><?= $tempNum ?></div>
  109. <div class="col3 slidepanel"><?= htmlspecialcharsFix($row['cs_code']) ?></div>
  110. <div class="col4">
  111. <?php
  112. $qudaoResult = $conn->query("SELECT ch_name FROM qudao WHERE id=" . (int)$row['cs_from']);
  113. echo ($qudaoRow = $qudaoResult->fetch_assoc()) ? htmlspecialcharsFix($qudaoRow['ch_name']) : '未填写';
  114. ?>
  115. </div>
  116. <div class="col5">
  117. <?php
  118. $countryResult = $conn->query("SELECT countryName FROM country WHERE id=" . (int)$row['cs_country']);
  119. echo ($countryRow = $countryResult->fetch_assoc()) ? htmlspecialcharsFix($countryRow['countryName']) : '未填写';
  120. ?>
  121. </div>
  122. <div class="col7">
  123. <?php
  124. if ($row['cs_deal'] == 3) {
  125. echo "<span style='color:red;'>成交</span>";
  126. } elseif ($row['cs_deal'] == 2) {
  127. echo "明确需求";
  128. } elseif ($row['cs_deal'] == 1) {
  129. echo "背景调查";
  130. } else {
  131. echo "无响应";
  132. }
  133. ?>
  134. </div>
  135. <div class="col8"><?= $row['cs_addtime'] ?></div>
  136. <div class="col10"><a href="customerEdit.php?id=<?= $row['id'] ?>" class="ico_edit ico">修改</a></div>
  137. </div>
  138. <div class="notepanel clear">
  139. <div class="noteItem">联系方式</div>
  140. <div class="lx">
  141. <div class="tel">
  142. <?php if(!empty($row['tel_1'])): ?>
  143. <div><?= htmlspecialcharsFix($row['tel_1']) ?></div>
  144. <?php endif; ?>
  145. <?php if(!empty($row['tel_2'])): ?>
  146. <div><?= htmlspecialcharsFix($row['tel_2']) ?></div>
  147. <?php endif; ?>
  148. <?php if(!empty($row['tel_3'])): ?>
  149. <div><?= htmlspecialcharsFix($row['tel_3']) ?></div>
  150. <?php endif; ?>
  151. </div>
  152. <div class="mail">
  153. <?php if(!empty($row['email_1'])): ?>
  154. <div><a href="mailto:<?= htmlspecialcharsFix($row['email_1']) ?>"><?= htmlspecialcharsFix($row['email_1']) ?></a></div>
  155. <?php endif; ?>
  156. <?php if(!empty($row['email_2'])): ?>
  157. <div><a href="mailto:<?= htmlspecialcharsFix($row['email_2']) ?>"><?= htmlspecialcharsFix($row['email_2']) ?></a></div>
  158. <?php endif; ?>
  159. <?php if(!empty($row['email_3'])): ?>
  160. <div><a href="mailto:<?= htmlspecialcharsFix($row['email_3']) ?>"><?= htmlspecialcharsFix($row['email_3']) ?></a></div>
  161. <?php endif; ?>
  162. </div>
  163. <div class="whatsapp">
  164. <?php if(!empty($row['whatsapp_1'])): ?>
  165. <div><?= htmlspecialcharsFix($row['whatsapp_1']) ?></div>
  166. <?php endif; ?>
  167. <?php if(!empty($row['whatsapp_2'])): ?>
  168. <div><?= htmlspecialcharsFix($row['whatsapp_2']) ?></div>
  169. <?php endif; ?>
  170. <?php if(!empty($row['whatsapp_3'])): ?>
  171. <div><?= htmlspecialcharsFix($row['whatsapp_3']) ?></div>
  172. <?php endif; ?>
  173. </div>
  174. <div class="wechat">
  175. <?php if(!empty($row['wechat_1'])): ?>
  176. <div><?= htmlspecialcharsFix($row['wechat_1']) ?></div>
  177. <?php endif; ?>
  178. <?php if(!empty($row['wechat_2'])): ?>
  179. <div><?= htmlspecialcharsFix($row['wechat_2']) ?></div>
  180. <?php endif; ?>
  181. <?php if(!empty($row['wechat_3'])): ?>
  182. <div><?= htmlspecialcharsFix($row['wechat_3']) ?></div>
  183. <?php endif; ?>
  184. </div>
  185. <div class="linkedin">
  186. <?php if(!empty($row['linkedin_1'])): ?>
  187. <div><?= htmlspecialcharsFix($row['linkedin_1']) ?></div>
  188. <?php endif; ?>
  189. <?php if(!empty($row['linkedin_2'])): ?>
  190. <div><?= htmlspecialcharsFix($row['linkedin_2']) ?></div>
  191. <?php endif; ?>
  192. <?php if(!empty($row['linkedin_3'])): ?>
  193. <div><?= htmlspecialcharsFix($row['linkedin_3']) ?></div>
  194. <?php endif; ?>
  195. </div>
  196. <div class="facebook">
  197. <?php if(!empty($row['facebook_1'])): ?>
  198. <div><?= htmlspecialcharsFix($row['facebook_1']) ?></div>
  199. <?php endif; ?>
  200. <?php if(!empty($row['facebook_2'])): ?>
  201. <div><?= htmlspecialcharsFix($row['facebook_2']) ?></div>
  202. <?php endif; ?>
  203. <?php if(!empty($row['facebook_3'])): ?>
  204. <div><?= htmlspecialcharsFix($row['facebook_3']) ?></div>
  205. <?php endif; ?>
  206. </div>
  207. <div class="alibaba">
  208. <?php if(!empty($row['alibaba_1'])): ?>
  209. <div><?= htmlspecialcharsFix($row['alibaba_1']) ?></div>
  210. <?php endif; ?>
  211. <?php if(!empty($row['alibaba_2'])): ?>
  212. <div><?= htmlspecialcharsFix($row['alibaba_2']) ?></div>
  213. <?php endif; ?>
  214. <?php if(!empty($row['alibaba_3'])): ?>
  215. <div><?= htmlspecialcharsFix($row['alibaba_3']) ?></div>
  216. <?php endif; ?>
  217. </div>
  218. </div>
  219. <div class="noteItem2">备注</div>
  220. <div class="notecontent"><?= htmlUnCode($row['cs_note']) ?></div>
  221. <div class="coltag mytag" data-id="<?= $row['id'] ?>" data-em="<?= $_SESSION['employee_id'] ?>">
  222. <?php
  223. $tagStr1 = $tagStr;
  224. $tagResult = $conn->query("SELECT tagName FROM tagtable WHERE customerId=" . $row['id']);
  225. while ($tagRow = $tagResult->fetch_assoc()) {
  226. $tagStr1 = str_replace(
  227. "<span>" . htmlspecialcharsFix($tagRow['tagName']) . "</span>",
  228. "<span class=\"active\">" . htmlspecialcharsFix($tagRow['tagName']) . "</span>",
  229. $tagStr1
  230. );
  231. }
  232. echo $tagStr1;
  233. ?>
  234. </div>
  235. </div>
  236. <?php
  237. }
  238. ?>
  239. <div colspan="9">
  240. <div class="showpagebox">
  241. </div>
  242. <div class="postchkbox">
  243. <select id="chkact" name="chkact">
  244. <?php
  245. $result = $conn->query("SELECT id, em_code, em_user FROM employee ORDER BY em_code ASC");
  246. while ($row = $result->fetch_assoc()) {
  247. echo "<option value=\"t{$row['id']}\">转给" . htmlspecialcharsFix($row['em_user']) . "(" . htmlspecialcharsFix($row['em_code']) . ")</option>";
  248. }
  249. ?>
  250. </select>
  251. <input type="button" value="执行" onclick="postchk(1)" class="btn1">
  252. </div>
  253. </div>
  254. </div>
  255. </form>
  256. </div>
  257. </body>
  258. </html>