diff --git a/public_html/assets/api/install.php b/public_html/assets/api/install.php index 9fa3861..fb7048a 100644 --- a/public_html/assets/api/install.php +++ b/public_html/assets/api/install.php @@ -1122,7 +1122,7 @@ trait InstallAPI { qry($sql); } - // + // 최초 install if ($install_date) { $install_yyyymmdd = str_replace('-', '', $install_date); @@ -1142,22 +1142,57 @@ trait InstallAPI { } } + // c_exchangedate: 최신 install_date 또는 pickup_date + $exchangeDates = []; + + if ($install_date) { + $exchangeDates[] = str_replace('-', '', $install_date); + } + if ($pickup_date) { + $exchangeDates[] = str_replace('-', '', $pickup_date); + } - $pickup_yyyymmdd = str_replace('-', '', $pickup_date); + if (!empty($exchangeDates)) { + rsort($exchangeDates); + $latestExchangeDate = $exchangeDates[0]; - $r = qry("SELECT c_removaldate FROM tbl_customer WHERE c_uid='{$c_uid}'"); - $row = mysqli_fetch_assoc($r); - $current = $row['c_removaldate']; + qry(" + UPDATE tbl_customer + SET c_exchangedate = '{$latestExchangeDate}' + WHERE c_uid = '{$c_uid}' + "); + } - if (!$current || $current === 'N/A' || $pickup_yyyymmdd > $current) { + // c_removaldate: 작업 후 active container가 하나도 없으면 최종 수거일 업데이트 + // 반대로 active container가 있으면 c_removaldate 초기화 + $r = qry(" + SELECT COUNT(*) AS active_cnt + FROM tbl_customer_container + WHERE cc_customer_uid = '{$c_uid}' + AND cc_status = 'A' + "); + + $row = mysqli_fetch_assoc($r); + $activeCnt = (int)($row['active_cnt'] ?? 0); + + if ($activeCnt === 0) { + if ($pickup_date) { + $pickup_yyyymmdd = str_replace('-', '', $pickup_date); qry(" UPDATE tbl_customer - SET c_removaldate='{$pickup_yyyymmdd}' - WHERE c_uid='{$c_uid}' + SET c_removaldate = '{$pickup_yyyymmdd}' + WHERE c_uid = '{$c_uid}' "); } + } else { + qry(" + UPDATE tbl_customer + SET c_removaldate = '' + WHERE c_uid = '{$c_uid}' + and c_removaldate <> '' + "); } diff --git a/public_html/doc/map.php b/public_html/doc/map.php index e784c30..ca2986c 100644 --- a/public_html/doc/map.php +++ b/public_html/doc/map.php @@ -2608,7 +2608,7 @@ function popup(){ fd.append('actionStr', 'ADDIMAGE'); fd.append('i_type', 'install_order'); fd.append('i_customeruid', SimpleInstall.customer_uid); - fd.append('i_memberuid', SimpleInstall.driver_uid); + fd.append('i_memberuid', SimpleInstall.member_uid); fd.append('i_note', $installNote); fd.append('i_sourceuid', iw_uid);