diff --git a/public_html/assets/api/install.php b/public_html/assets/api/install.php index fb7048a..a1e3972 100644 --- a/public_html/assets/api/install.php +++ b/public_html/assets/api/install.php @@ -748,9 +748,25 @@ trait InstallAPI { return intval($a['di_order_seq'] ?? 0) <=> intval($b['di_order_seq'] ?? 0); }); + $has_existing = is_array($existing_rows) && count($existing_rows) > 0; + $has_trial = is_array($trial_rows) && count($trial_rows) > 0; + + $base_seq = 0; + + if (!$has_existing && $has_trial) { + $qr_max = qry(" + SELECT MAX(di_order_seq) AS max_seq + FROM tbl_daily_install + WHERE di_driver_uid = '{$di_driver_uid}' + AND di_install_date = '{$di_install_date}' + "); + + $row_max = fetch_array($qr_max); + $base_seq = intval($row_max['max_seq'] ?? 0); + } + $seq = 1; foreach($all as &$r){ - // base_seq 더해줌 $r['di_order_seq'] = $base_seq + $seq++; } unset($r); diff --git a/public_html/doc/install_wait_list.php b/public_html/doc/install_wait_list.php index f393fbd..ca33c4f 100644 --- a/public_html/doc/install_wait_list.php +++ b/public_html/doc/install_wait_list.php @@ -30,8 +30,10 @@ $total_count = $jdb->rQuery($sql_cnt, "Install wait list count error"); // 1) Load waitlist // ============================ $sql = " - SELECT * - FROM tbl_install_waitlist + SELECT iw.*, CONCAT(m.m_firstname, ' ', m.m_lastname) as iw_created_member + FROM tbl_install_waitlist iw + LEFT OUTER JOIN tbl_member m + ON iw.iw_created_by = m.m_uid WHERE iw_status in ('WAITING','DRAFT') $add_where ORDER BY iw_requested_due_date ASC, iw_request_at ASC @@ -329,6 +331,44 @@ function formatPhone($phone) { modal.show(); } + function openRoute() { + + const OFFICE = "4490 Chesswood Dr, North York, ON M3J 2B9"; + + const rows = []; + + document.querySelectorAll('#iwListBody tr').forEach(tr => { + + const address = tr.dataset.address || ''; + const city = tr.dataset.city || ''; + const postal = tr.dataset.postal || ''; + + if (!address) return; + + rows.push({ + address: [address, city, postal].filter(Boolean).join(', '), + order: parseInt(tr.dataset.orderSeq || 0) + }); + }); + + if (!rows.length) { + showPopupMessage('No route data.', 'error', 1500); + return; + } + + // 순서 정렬 (중요) + rows.sort((a, b) => a.order - b.order); + + const waypoints = rows.map(r => r.address).join('|'); + + let url = `https://www.google.com/maps/dir/?api=1`; + url += `&origin=${encodeURIComponent(OFFICE)}`; + url += `&destination=${encodeURIComponent(OFFICE)}`; + url += `&waypoints=${encodeURIComponent(waypoints)}`; + + window.open(url, '_blank'); + } + function loadInstallWaitForEdit(iw_uid) { // 1) install_wait 메타 로드 api('get_install_wait_detail', { iw_uid }, data => { @@ -577,7 +617,8 @@ function formatPhone($phone) {
- + + created by @@ -857,6 +898,10 @@ function formatPhone($phone) {
+ + @@ -1167,6 +1212,9 @@ function formatPhone($phone) { rows.forEach(r => { const tr = document.createElement('tr'); + tr.dataset.address = r.di_address || ''; + tr.dataset.city = r.di_city || ''; + tr.dataset.postal = r.di_postal || ''; if (r.is_trial) { tr.dataset.isTrial = '1'; tr.dataset.iwUid = r.iw_uid; // waitlist uid @@ -1866,6 +1914,14 @@ while ($row = mysqli_fetch_assoc($rmem)) { return; } + const routeBtn = e.target.closest('#btnRouteSchedule'); + if (routeBtn) { + e.preventDefault(); + + openRoute(); + return; + } + // 3) WAIT CARD CLICK (trial toggle) const card = e.target.closest('.wait-card'); if (!card) return;