checkLevelModal(5); // ============================ // Search filters (LEFT ONLY) // ============================ $where = []; if (!empty($kw_customer)) $where[] = "(iw_customer_name LIKE '%{$kw_customer}%' OR iw_address LIKE '%{$kw_customer}%' OR iw_accountno LIKE '%{$kw_customer}%' OR iw_city LIKE '%{$kw_customer}%')"; if (!empty($kw_work)) $where[] = "(iw_work_type = '{$kw_work}')"; if (!empty($_GET['kw_two_person'])) $where[] = "(iw_required_person_cnt IS NOT NULL AND iw_required_person_cnt > 0)"; if (!empty($_GET['kw_draft'])) $where[] = "(iw_status = 'DRAFT')"; if (!empty($where)) { $add_where = ' AND ' . implode(' AND ', $where); } function db_escape($jdb, $str) { return mysqli_real_escape_string($jdb->DBConn, $str); } // ============================ // Total count // ============================ $sql_cnt = " SELECT COUNT(*) FROM tbl_install_waitlist WHERE iw_status in ('WAITING','DRAFT') $add_where "; $total_count = $jdb->rQuery($sql_cnt, "Install wait list count error"); // ============================ // 1) Load waitlist // ============================ $sql = " SELECT * FROM tbl_install_waitlist WHERE iw_status in ('WAITING','DRAFT') $add_where ORDER BY iw_requested_due_date ASC, iw_request_at ASC "; $rs = $jdb->nQuery($sql, "Load waitlist error"); $rows = []; $iw_uids = []; $customer_uids = []; while ($r = mysqli_fetch_assoc($rs)) { $rows[] = $r; $iw_uids[] = (int)$r['iw_uid']; if (!empty($r['iw_customer_uid'])) { $customer_uids[] = (int)$r['iw_customer_uid']; } } $iw_uids = array_values(array_unique($iw_uids)); $customer_uids = array_values(array_unique($customer_uids)); /* ============================ * 2) Customer containers (cc_status='A') * ============================ */ $customerContainerMap = []; // [customer_uid => [rows...]] if ($customer_uids) { $in = implode(',', $customer_uids); $sql_cc = " SELECT cc_customer_uid, cc_type, cc_owner_type, cc_is_used, cc_has_lock, cc_has_wheel, cc_has_woodframe FROM tbl_customer_container WHERE cc_status = 'A' AND cc_customer_uid IN ($in) ORDER BY cc_customer_uid, cc_type, cc_uid "; $rc = $jdb->nQuery($sql_cc, "Load customer containers error"); while ($c = mysqli_fetch_assoc($rc)) { $cu = (int)$c['cc_customer_uid']; if (!isset($customerContainerMap[$cu])) $customerContainerMap[$cu] = []; $customerContainerMap[$cu][] = $c; } } /* ============================ * 3) Task containers (waitlist) * ============================ */ $taskMap = []; // [iw_uid => rows] if ($iw_uids) { $in = implode(',', $iw_uids); $sql_task = " SELECT * FROM tbl_install_waitlist_container WHERE iwc_wait_uid IN ($in) ORDER BY iwc_wait_uid, iwc_uid "; $rt = $jdb->nQuery($sql_task, "Load task containers error"); while ($t = mysqli_fetch_assoc($rt)) { $taskMap[$t['iwc_wait_uid']][] = $t; } } /* ============================ * 4) Customer images (install_order) * ============================ */ $imageMap = []; // [customer_uid => true] if ($customer_uids) { $in = implode(',', $customer_uids); $sql_img = " SELECT DISTINCT i_customeruid FROM tbl_customer_image WHERE i_status = 'A' AND i_type = 'install_order' AND i_customeruid IN ($in) "; $ri = $jdb->nQuery($sql_img, "Load customer images error"); while ($img = mysqli_fetch_assoc($ri)) { $imageMap[(int)$img['i_customeruid']] = true; } } // ============================ // 5) customer driver // ============================ $customerDriverMap = []; // [customer_uid => driver_uid] if ($customer_uids) { $in = implode(',', $customer_uids); $sql_cd = " SELECT c.c_uid, d.dr_initial FROM tbl_customer c LEFT JOIN tbl_member m ON c.c_regionuid = m.m_regionuid LEFT JOIN tbl_driver d ON m.m_defaultdriver = d.dr_uid WHERE c.c_uid IN ($in) AND d.dr_type = 'UCO' "; $rc = $jdb->nQuery($sql_cd, "Load customer driver error"); while ($c = mysqli_fetch_assoc($rc)) { $cu = (int)$c['c_uid']; $customerDriverMap[$cu] = $c['dr_initial'] ?? ''; } } // ============================ // 6) install drivers // ============================ $drivers = []; $sql_install = " SELECT dr_uid, dr_initial FROM tbl_driver WHERE dr_status = 'A' AND dr_type = 'INSTALL' ORDER BY dr_initial "; $ris = $jdb->nQuery($sql_install, "Load install drivers error"); while ($r = mysqli_fetch_assoc($ris)) { $drivers[] = $r; } // ============================ // 7) driver initials (modal) // ============================ $driverInitialMap = []; // [dr_uid => dr_initial] $sql_driver = " SELECT dr_uid, dr_initial FROM tbl_driver WHERE dr_status = 'A' "; $res = $jdb->nQuery($sql_driver, "Load driver map error"); while ($r = mysqli_fetch_assoc($res)) { $driverInitialMap[(int)$r['dr_uid']] = $r['dr_initial']; } // ============================ // 전화번호 // ============================ function formatPhone($phone) { $digits = preg_replace('/\D+/', '', (string)$phone); // 10 digits => (xxx) xxx-xxxx if (strlen($digits) === 10) { return sprintf( '(%s) %s - %s', substr($digits, 0, 3), substr($digits, 3, 3), substr($digits, 6, 4) ); } return $phone; } ?>
No waiting items.
Draft 1): ?> x
Every days · Last
Due:
, , ·
Request (by )
CS
Work
Pickup Install
'; if ($t['iwc_has_wheel'] === 'Y') $optIcons .= ' '; if ($t['iwc_has_woodframe'] === 'Y') $optIcons .= ' '; ?>
$d): ?>
Stops: 0  
# Customer UCO Address Type Pickup Install
Customer"; $sql_driver = " SELECT dr_uid, dr_initial FROM tbl_driver WHERE dr_status = 'A' ORDER BY dr_initial "; $rmem = $jdb->nQuery($sql_driver, "Load driver list error"); while ($row = mysqli_fetch_assoc($rmem)) { $driveruid = $row['dr_uid']; $ini = htmlspecialchars(trim($row['dr_initial'])); if ($ini === '') continue; $iwRequestByOptions .= ""; } ?>