Forecast: add Co-visit section, fix scroll duplication error

This commit is contained in:
Jaeeun.Cho 2025-12-08 14:33:54 -05:00
parent 8dde0a3047
commit 002e9088bf
2 changed files with 95 additions and 3 deletions

View File

@ -1594,7 +1594,6 @@ $(document).on("click", "tr[data-id]", function () {
const cname = $(this).data("name"); const cname = $(this).data("name");
const $row = $(this); const $row = $(this);
console.log(cname)
// 기존 선택 스타일 제거 // 기존 선택 스타일 제거
$("tr[data-id]").removeClass("selected-row"); $("tr[data-id]").removeClass("selected-row");
@ -1651,18 +1650,20 @@ canvasEl.addEventListener("hidden.bs.offcanvas", function () {
<style> <style>
#customerInfoCanvas { #customerInfoCanvas {
width: 30%; width: 30%;
min-width: 400px;
height: 100vh !important; height: 100vh !important;
overflow-y: auto !important; overflow: hidden;
} }
.customer-offcanvas-header { .customer-offcanvas-header {
background: #2A9B56; background: #2A9B56;
color: #fff; color: #fff;
overflow: hidden;
} }
#customerInfoBody { #customerInfoBody {
max-height: calc(100vh - 60px); max-height: calc(100vh - 60px);
overflow-y: auto; overflow: auto !important;
padding-right: 10px; padding-right: 10px;
} }

View File

@ -4,6 +4,7 @@ include getenv("DOCUMENT_ROOT")."/include/session_include.php";
$c_uid = $_POST["c_uid"] ?? $_GET["c_uid"] ?? ""; $c_uid = $_POST["c_uid"] ?? $_GET["c_uid"] ?? "";
$note_page = intval($_POST["note_page"] ?? 1); $note_page = intval($_POST["note_page"] ?? 1);
$oil_page = intval($_POST["oil_page"] ?? 1); $oil_page = intval($_POST["oil_page"] ?? 1);
$co_visit_page = intval($_POST["co_visit_page"] ?? 1);
if ($c_uid == "") { if ($c_uid == "") {
echo "Invalid data. [Err - c_uid / FORECAST-POPUP]"; echo "Invalid data. [Err - c_uid / FORECAST-POPUP]";
@ -94,10 +95,38 @@ $oilQuery = "
"; ";
$oilResult = $jdb->nQuery($oilQuery, "oil query error"); $oilResult = $jdb->nQuery($oilQuery, "oil query error");
/*-----------------------------------
CO-VISIT 데이터
------------------------------------*/
$coPerPage = 5;
$coCountQuery = "
SELECT COUNT(*) AS total
FROM tbl_co_visit
WHERE cv_customer_uid = '$c_uid'
";
$coCountResult = $jdb->nQuery($coCountQuery, "co count error");
$coCount = mysqli_fetch_array($coCountResult, MYSQLI_ASSOC)['total'];
$totalCoPages = ceil($coCount / $coPerPage);
if ($co_visit_page < 1) $co_visit_page = 1;
$co_start = ($co_visit_page - 1) * $coPerPage;
$coQuery = "
SELECT cv.*, tc.c_name AS co_name, tc.c_accountno AS co_accountno
FROM tbl_co_visit cv
LEFT JOIN tbl_customer tc ON cv.cv_co_customer_uid = tc.c_uid
WHERE cv.cv_customer_uid = '$c_uid'
ORDER BY cv.cv_score DESC
LIMIT $co_start, $coPerPage
";
$coResult = $jdb->nQuery($coQuery, "co query error");
?> ?>
<div class="rightinfo-container"> <div class="rightinfo-container">
<!-- COMENT SECTION -->
<h3 class="rightinfo-title">Comment</h3> <h3 class="rightinfo-title">Comment</h3>
<div class="rightinfo-value"><?= nl2br($c_commentSTR) ?></div> <div class="rightinfo-value"><?= nl2br($c_commentSTR) ?></div>
@ -190,6 +219,57 @@ $oilResult = $jdb->nQuery($oilQuery, "oil query error");
?> ?>
</div> </div>
<!-- CO-VISIT -->
<h3 class="note-title">Recomendation</h3>
<table class="note-table">
<tr>
<th>Account</th>
<th>Customer</th>
<th>Last CoVisit</th>
<th>Distance</th>
<th>CoVisit %</th>
</tr>
<?php while ($co = mysqli_fetch_array($coResult, MYSQLI_ASSOC)) {
$last = $co['cv_last_co_visit_date'] ?: "-";
$co_total = $co['cv_visit_count'];
$co_match = $co['cv_co_visit_count'];
$percent = ($co_total > 0) ? round(($co_match / $co_total) * 100, 1) : 0;
echo "
<tr>
<td style='width:80px;'>{$co['co_accountno']}</td>
<td style='width:100px;'>{$co['co_name']}</td>
<td style='width:100px; text-align:center;'>{$last}</td>
<td style='width:50px; text-align:right;'>{$co['cv_distance']} km</td>
<td style='width:80px; text-align:right;'>{$percent} %</td>
</tr>";
} ?>
</table>
<div class="pagination">
<?php
$coBlock = ceil($co_visit_page / $blockSize);
$coStart = ($coBlock - 1) * $blockSize + 1;
$coEnd = min($coStart + $blockSize - 1, $totalCoPages);
if ($coStart > 1) {
echo "<a class='page-btn arrow' href='#' onclick='loadCoVisitPage(\"$c_uid\", ".($coStart-1)."); return false;'>&laquo;</a>";
}
for ($i = $coStart; $i <= $coEnd; $i++) {
$act = ($i == $co_visit_page) ? "active" : "";
echo "<a class='page-btn $act' href='#' onclick='loadCoVisitPage(\"$c_uid\", $i); return false;'>$i</a>";
}
if ($coEnd < $totalCoPages) {
echo "<a class='page-btn arrow' href='#' onclick='loadCoVisitPage(\"$c_uid\", ".($coEnd+1)."); return false;'>&raquo;</a>";
}
?>
</div>
</div> </div>
<script> <script>
@ -214,6 +294,17 @@ function loadOilPage(c_uid, page) {
} }
}); });
} }
function loadCoVisitPage(c_uid, page) {
$.ajax({
url: "/lib/shortInfo_right_lib.php",
type: "POST",
data: { c_uid: c_uid, co_visit_page: page },
success: function(res) {
$(".rightinfo-container").parent().html(res);
}
});
}
</script> </script>