diff --git a/public_html/assets/api/install.php b/public_html/assets/api/install.php index d579391..587c841 100644 --- a/public_html/assets/api/install.php +++ b/public_html/assets/api/install.php @@ -264,11 +264,10 @@ trait InstallAPI { while ($img = mysqli_fetch_assoc($ri)) { - $imgPath = $img['i_filepath'] . $img['i_filename']; - $photos[] = [ - 'i_uid' => (int)$img['i_uid'], - 'imgPath' => $imgPath + 'i_uid' => (int)$img['i_uid'], + 'i_filepath' => $img['i_filepath'], + 'i_filename' => $img['i_filename'] ]; } @@ -1708,20 +1707,19 @@ trait InstallAPI { $fail('select_di', 'daily_install not found'); } - if(!isset($_FILES['photo']) || $_FILES['photo']['error'] !== 0){ - $fail('file', 'no file'); + if(!isset($_FILES['photos'])){ + $fail('file', 'no files'); } - $file = $_FILES['photo']; $customer_uid = intval($di['di_customer_uid']); - $ok = $this->save_customer_image_single( + $ok = $this->save_customer_image_multi( $customer_uid, $member_uid, $i_type, - $di_uid, // i_sourceuid = di_uid + $di_uid, $note, - $file + $_FILES['photos'] ); if(!$ok){ @@ -1732,7 +1730,7 @@ trait InstallAPI { exit; } - private function save_customer_image_single($i_customeruid, $i_memberuid, $i_type, $i_sourceuid, $i_note, $file){ + private function save_customer_image_multi($i_customeruid, $i_memberuid, $i_type, $i_sourceuid, $i_note, $files){ $conn = $GLOBALS['conn']; @@ -1744,36 +1742,48 @@ trait InstallAPI { $i_noteEsc = mysqli_real_escape_string($conn, trim($i_note)); $i_createddate = date("YmdHis"); - // 확장자 체크(최소 보안) $allowed = ['jpg','jpeg','png','webp']; - $ext = strtolower(pathinfo($file['name'] ?? '', PATHINFO_EXTENSION)); - if(!$ext || !in_array($ext, $allowed)){ - return false; - } - // 작업 단위 1장 유지: (customeruid + type, sourceuid 는 제외) + // 기존 row 비활성화 $qry_update = " UPDATE tbl_customer_image SET i_status = 'I' WHERE i_customeruid = '{$i_customeruid}' - AND i_type = '{$i_type}' - AND i_status = 'A' + AND i_type = '{$i_type}' + AND i_status = 'A' "; if(qry($qry_update) === false) return false; - // 저장 폴더 + // 폴더 $upload_folder = getenv("DOCUMENT_ROOT")."/upload/customer_image/".$i_customeruid; if(!is_dir($upload_folder)){ mkdir($upload_folder, 0777, true); } - $newFileName = "IMG_".$i_customeruid."_".time().rand(1000,9999)."_0.jpg"; - $savePath = $upload_folder . "/" . $newFileName; + $savedFiles = []; - if (!$this->compressAndResizeImage($file['tmp_name'], $savePath, $ext, 1200, 75)) { - return false; + foreach ($files['name'] as $i => $name) { + + if ($files['error'][$i] !== 0) continue; + + $ext = strtolower(pathinfo($name, PATHINFO_EXTENSION)); + if(!$ext || !in_array($ext, $allowed)) continue; + + $tmp = $files['tmp_name'][$i]; + + $newFileName = "IMG_".$i_customeruid."_".time().rand(1000,9999)."_".$i.".jpg"; + $savePath = $upload_folder . "/" . $newFileName; + + if (!$this->compressAndResizeImage($tmp, $savePath, $ext, 1200, 75)) { + continue; + } + + $savedFiles[] = $newFileName; } + if(empty($savedFiles)) return false; + + $fileNameString = implode(',', $savedFiles); $dbFilePath = "/upload/customer_image/".$i_customeruid."/"; $sqlIns = " @@ -1794,7 +1804,7 @@ trait InstallAPI { '{$i_memberuid}', '{$i_createddate}', '{$i_type}', - '{$newFileName}', + '{$fileNameString}', '{$dbFilePath}', 'A', '{$i_noteEsc}', diff --git a/public_html/doc/customer_detail.php b/public_html/doc/customer_detail.php index 23dfa8a..a4d83ff 100644 --- a/public_html/doc/customer_detail.php +++ b/public_html/doc/customer_detail.php @@ -2048,137 +2048,116 @@ if( $total_count < 1 ) {
nQuery($qry_img, "image list error"); + // 이미지 가져오기 + $qry_img = " + SELECT * + FROM tbl_customer_image tci + LEFT OUTER JOIN tbl_member tm ON tci.i_createdby = tm.m_uid + WHERE tci.i_customeruid = '$c_uid' + AND tci.i_status = 'A' + ORDER BY tci.i_uid DESC + "; + $rt_img = $jdb->nQuery($qry_img, "image list error"); - // 분류 배열 - $install = []; - $container = []; + function getImageTypeLabel($type) { + switch ($type) { + case 'install': + return 'Install Image'; + case 'install_order': + return 'Container Request Image'; + case 'clean_before': + return 'Before Clean'; + case 'clean_after': + return 'After Clean'; + default: + return ucfirst(str_replace('_', ' ', $type)); + } + } - while ($img = mysqli_fetch_array($rt_img, MYSQLI_ASSOC)) { - if ($img['i_type'] == "install") $install[] = $img; - else $container[] = $img; - } - - if (count($install) + count($container) == 0) { + if (mysqli_num_rows($rt_img) == 0) { echo "No images found.
"; - } else { + } else { + echo '