各组数据

日期筛选
query("SELECT id, em_user FROM employee WHERE em_role=0 AND id<>13"); while ($row = $result->fetch_assoc()) { $clstr = ""; // Get total customer count $c1Result = $conn->query("SELECT COUNT(DISTINCT c.cs_code) as c1 FROM customer c WHERE c.cs_belong=" . $row['id']); $c1Row = $c1Result->fetch_assoc(); $c1 = $c1Row['c1']; // Get customers going to public sea $c2Result = $conn->query("SELECT COUNT(c.id) as c2 FROM customer c WHERE c.cs_deal<>3 AND c.cs_deal<>0 AND c.cs_type<>2 AND DATEDIFF(NOW(), c.cs_updatetime) > 90 AND c.cs_belongclient=0 AND c.cs_belong=" . $row['id']); $c2Row = $c2Result->fetch_assoc(); $c2 = $c2Row['c2']; // Get deals in date range $c3Result = $conn->query("SELECT DISTINCT c.cs_code FROM customer c WHERE c.cs_dealdate > '" . $conn->real_escape_string($datestart) . "' AND c.cs_dealdate <= '" . $conn->real_escape_string($dateend) . "' AND c.cs_deal=3 AND c.cs_belong=" . $row['id']); $c3 = $c3Result->num_rows; while ($c3Row = $c3Result->fetch_assoc()) { $clstr .= $c3Row['cs_code'] . "
"; } // Get claimed customers count $c4Result = $conn->query("SELECT COUNT(DISTINCT c.cs_code) as c4 FROM customer c WHERE c.cs_claimdate > '" . $conn->real_escape_string($datestart) . "' AND c.cs_claimdate <= '" . $conn->real_escape_string($dateend) . "' AND c.cs_belong=" . $row['id']); $c4Row = $c4Result->fetch_assoc(); $c4 = $c4Row['c4']; // Get team member count $c5Result = $conn->query("SELECT COUNT(id) as c5 FROM employee WHERE em_role=" . $row['id']); $c5Row = $c5Result->fetch_assoc(); $c5 = $c5Row['c5']; ?> query("SELECT id, em_user FROM employee WHERE em_role=" . $row['id']); while ($memberRow = $memberResult->fetch_assoc()) { $clstr = ""; // Get member's total customer count $mc1Result = $conn->query("SELECT COUNT(DISTINCT c.cs_code) as c1 FROM customer c WHERE c.cs_belong=" . $memberRow['id']); $mc1Row = $mc1Result->fetch_assoc(); $mc1 = $mc1Row['c1']; // Get member's customers going to public sea $mc2Result = $conn->query("SELECT COUNT(DISTINCT c.cs_code) as c2 FROM customer c WHERE c.cs_deal<>3 AND c.cs_deal<>0 AND c.cs_type<>2 AND DATEDIFF(NOW(), c.cs_updatetime) > 90 AND c.cs_belongclient=0 AND c.cs_belong=" . $memberRow['id']); $mc2Row = $mc2Result->fetch_assoc(); $mc2 = $mc2Row['c2']; // Get member's deals in date range $mc3Result = $conn->query("SELECT DISTINCT c.cs_code FROM customer c WHERE c.cs_dealdate > '" . $conn->real_escape_string($datestart) . "' AND c.cs_dealdate <= '" . $conn->real_escape_string($dateend) . "' AND c.cs_deal=3 AND c.cs_belong=" . $memberRow['id']); $mc3 = $mc3Result->num_rows; while ($mc3Row = $mc3Result->fetch_assoc()) { $clstr .= $mc3Row['cs_code'] . "
"; } // Get member's claimed customers count $mc4Result = $conn->query("SELECT COUNT(c.id) as c4 FROM customer c WHERE c.cs_claimdate > '" . $conn->real_escape_string($datestart) . "' AND c.cs_claimdate <= '" . $conn->real_escape_string($dateend) . "' AND c.cs_belong=" . $memberRow['id']); $mc4Row = $mc4Result->fetch_assoc(); $mc4 = $mc4Row['c4']; ?>
组长 组员 总客户数量 本月成交 进公海客户总数 公海认领