@@ -83,9 +99,16 @@ if ($c_paymenttype =="CA") {
+
+ | Restaurant Name |
+
+ =$c_name?>
+ |
+
+
| Payment Type |
-
+ |
=$c_paymenttypeSTR?>
|
@@ -93,7 +116,7 @@ if ($c_paymenttype =="CA") {
if ($c_paymenttype =="CA") { ?>
| Pay Status |
-
+ |
=$d_paystatusSTR?>
|
@@ -101,18 +124,32 @@ if ($c_paymenttype =="CA") {
| Comment |
-
+ |
|
| Container Location |
-
+ |
|
+
+ | Installation Image |
+
+
+ View Image
+
+ No image
+
+ |
+
+ ADD
+ |
+
+
@@ -237,6 +274,11 @@ $(document).ready(function(){
});
});
+
+function popup() {
+ const url = `/lib/customer_image_upload_popup.php?c_uid==$c_uid?>&goStr==$goStr?>`;
+ window.open(url, "uploadImage", "width=600,height=750,scrollbars=yes");
+}
diff --git a/public_html/lib/user_process.php b/public_html/lib/user_process.php
index 3b0b9b3..38ff1c3 100644
--- a/public_html/lib/user_process.php
+++ b/public_html/lib/user_process.php
@@ -950,6 +950,317 @@ if ($actionStr == "DELETENOTE" && $mode == "delete") {
}
+//////////////////////////////////////////////
+// ADD IMAGE (Customer Detail - Image Upload)
+//////////////////////////////////////////////
+if ($actionStr == "ADDIMAGE") {
+
+ $i_note = isset($_POST['i_note']) ? trim($_POST['i_note']) : "";
+ $i_createddate = date("YmdHis");
+
+ if ($i_customeruid == "" || $i_memberuid == "") {
+ $msg = "Invalid data. Please try again. [Err - i_customeruid, i_memberuid]";
+ $func->modalMsg($msg, "");
+ exit();
+ }
+
+ // 기존 이미지 비활성화
+ if ($i_type == "install") {
+ $qry_update = "
+ UPDATE tbl_customer_image
+ SET i_status = 'I'
+ WHERE i_customeruid = '$i_customeruid'
+ AND i_type = 'install'
+ AND i_status = 'A'
+ ";
+ $jdb->nQuery($qry_update, "update error");
+ }
+
+ if ($i_type == "container") {
+ $qry_update2 = "
+ UPDATE tbl_customer_image
+ SET i_status = 'I'
+ WHERE i_customeruid = '$i_customeruid'
+ AND i_type = 'container'
+ AND i_status = 'A'
+ ";
+ $jdb->nQuery($qry_update2, "update error");
+ }
+
+ // 이미지 최대 6개 제한 체크
+ if ($i_type == "container") {
+ // 기존 이미지 수 조회
+ $qry_cnt = "
+ SELECT i_filename
+ FROM tbl_customer_image
+ WHERE i_customeruid = '$i_customeruid'
+ AND i_type = 'container'
+ AND i_status = 'A'
+ ORDER BY i_uid DESC LIMIT 1
+ ";
+ $rt_cnt = $jdb->fQuery($qry_cnt, "error");
+
+ $existingCount = 0;
+ if (!empty($rt_cnt['i_filename'])) {
+ $existingFiles = explode(",", $rt_cnt['i_filename']);
+ $existingCount = count($existingFiles);
+ }
+
+ // 이번에 업로드할 파일 개수
+ $newCount = is_array($_FILES['upload_file']['name'])
+ ? count($_FILES['upload_file']['name'])
+ : 1;
+
+ if ($existingCount + $newCount > 6) {
+ $msg = "Container 이미지는 최대 6개까지 업로드할 수 있습니다.";
+ $func->modalMsg($msg, "/index_intranet.php?view=customer_detail&mode=update&c_uid=$i_customeruid&$goStr");
+ exit();
+ }
+ }
+
+ // 업로드 파일 체크
+ if (!isset($_FILES['upload_file'])) {
+ $msg = "Upload failed. Please try again.";
+ $func->modalMsg($msg, "/index_intranet.php?view=customer_detail&mode=update&c_uid=$i_customeruid&$goStr");
+ exit();
+ }
+
+ // 저장 폴더 생성
+ $upload_folder = getenv("DOCUMENT_ROOT")."/upload/customer_image/".$i_customeruid;
+ if (!is_dir($upload_folder)) {
+ mkdir($upload_folder, 0777, true);
+ }
+
+ // 파일 개수
+ $fileCount = is_array($_FILES['upload_file']['name'])
+ ? count($_FILES['upload_file']['name'])
+ : 1;
+
+ $uploadedFileNames = array(); // 콤마로 합쳐서 넣을 리스트
+
+ for ($i = 0; $i < $fileCount; $i++) {
+
+ $fileTmp = is_array($_FILES['upload_file']['tmp_name'])
+ ? $_FILES['upload_file']['tmp_name'][$i]
+ : $_FILES['upload_file']['tmp_name'];
+
+ $fileName = is_array($_FILES['upload_file']['name'])
+ ? $_FILES['upload_file']['name'][$i]
+ : $_FILES['upload_file']['name'];
+
+ $fileError = is_array($_FILES['upload_file']['error'])
+ ? $_FILES['upload_file']['error'][$i]
+ : $_FILES['upload_file']['error'];
+
+ if ($fileError != 0) continue;
+
+ // 확장자
+ $ext = pathinfo($fileName, PATHINFO_EXTENSION);
+
+ // 새 파일명 생성
+ $newFileName = "IMG_".$i_customeruid."_".time().rand(1000,9999)."_".$i.".".$ext;
+
+ // 저장 경로
+ $savePath = $upload_folder . "/" . $newFileName;
+
+ if (!move_uploaded_file($fileTmp, $savePath)) {
+ continue;
+ }
+
+ // 업로드된 파일명 저장 (DB에 콤마로 넣을 배열)
+ $uploadedFileNames[] = $newFileName;
+ }
+
+ // 한 개도 업로드되지 않으면 종료
+ if (count($uploadedFileNames) == 0) {
+ $msg = "No files uploaded.";
+ $func->modalMsg($msg, "/index_intranet.php?view=customer_detail&mode=update&c_uid=$i_customeruid&$goStr");
+ exit();
+ }
+
+ $fileNameString = implode(",", $uploadedFileNames);
+ $dbFilePath = "/upload/customer_image/".$i_customeruid."/";
+
+ // DB INSERT
+ $columns = array(
+ "i_customeruid",
+ "i_memberuid",
+ "i_createdby",
+ "i_createddate",
+ "i_type",
+ "i_filename",
+ "i_filepath",
+ "i_status",
+ "i_note"
+ );
+
+ $values = array(
+ $i_customeruid,
+ $i_memberuid,
+ $i_createdby,
+ $i_createddate,
+ $i_type,
+ $fileNameString,
+ $dbFilePath,
+ "A",
+ $i_note
+ );
+
+ $jdb->iQuery("tbl_customer_image", $columns, $values);
+
+ // 완료 후 이동
+ // $msg = "Image uploaded successfully.";
+ // $urlSTR = "/index_intranet.php?view=customer_detail&mode=update&c_uid=$i_customeruid&$goStr";
+ // $func->modalMsg($msg, $urlSTR);
+ echo "
+
+ ";
+ exit();
+}
+
+
+//////////////////////////////////////////////
+// UPDATE IMAGE
+//////////////////////////////////////////////
+if ($actionStr == "UPDATEIMAGEFULL") {
+
+ $i_uid = $_POST['i_uid'] ?? "";
+ $i_customeruid = $_POST['i_customeruid'] ?? "";
+ $i_note = trim($_POST['i_note'] ?? "");
+ $goStr = $_POST['goStr'] ?? "";
+
+ if ($i_uid == "" || $i_customeruid == "") {
+ $msg = "Invalid data.";
+ $func->modalMsg($msg, "");
+ exit();
+ }
+
+ // 이미지 최대 6개 제한 체크
+ if ($i_type == "container") {
+ // 기존 이미지 수 조회
+ $qry_cnt = "
+ SELECT i_filename
+ FROM tbl_customer_image
+ WHERE i_customeruid = '$i_customeruid'
+ AND i_type = 'container'
+ AND i_status = 'A'
+ ORDER BY i_uid DESC LIMIT 1
+ ";
+ $rt_cnt = $jdb->fQuery($qry_cnt, "error");
+
+ $existingCount = 0;
+ if (!empty($rt_cnt['i_filename'])) {
+ $existingFiles = explode(",", $rt_cnt['i_filename']);
+ $existingCount = count($existingFiles);
+ }
+
+ // 이번에 업로드할 파일 개수
+ $newCount = is_array($_FILES['upload_file']['name'])
+ ? count($_FILES['upload_file']['name'])
+ : 1;
+
+ if ($existingCount + $newCount > 6) {
+ $msg = "Container 이미지는 최대 6개까지 업로드할 수 있습니다.";
+ $func->modalMsg($msg, "/index_intranet.php?view=customer_detail&mode=update&c_uid=$i_customeruid&$goStr");
+ exit();
+ }
+ }
+
+ // 기존 데이터 가져오기
+ $qry = "SELECT * FROM tbl_customer_image WHERE i_uid = '$i_uid'";
+ $rt = $jdb->fQuery($qry, "Image read error");
+
+ $oldFiles = explode(",", $rt['i_filename']);
+ $filepath = $rt['i_filepath'];
+
+ // 이미지 삭제 처리
+ $deleteFiles = $_POST['delete_files'] ?? [];
+ $newList = [];
+
+ foreach ($oldFiles as $f) {
+ $f = trim($f);
+ if (in_array($f, $deleteFiles)) {
+ $full = getenv("DOCUMENT_ROOT") . $filepath . $f;
+ if (file_exists($full)) unlink($full);
+ } else {
+ $newList[] = $f; // 삭제되지 않은 파일 유지
+ }
+ }
+
+ // 새 이미지 업로드 처리
+ if (isset($_FILES['upload_file'])) {
+
+ $upload_folder = getenv("DOCUMENT_ROOT") . $filepath;
+
+ if (!is_dir($upload_folder)) mkdir($upload_folder, 0777, true);
+
+ $fileCount = count($_FILES['upload_file']['name']);
+
+ for ($i = 0; $i < $fileCount; $i++) {
+
+ if ($_FILES['upload_file']['error'][$i] != 0) continue;
+
+ $ext = pathinfo($_FILES['upload_file']['name'][$i], PATHINFO_EXTENSION);
+ $newName = "IMG_".$i_customeruid."_".time().rand(1000,9999)."_".$i.".".$ext;
+
+ $savePath = $upload_folder . $newName;
+
+ if (move_uploaded_file($_FILES['upload_file']['tmp_name'][$i], $savePath)) {
+ $newList[] = $newName;
+ }
+ }
+ }
+
+ // 콤마 문자열 재정리
+ $finalFiles = implode(",", $newList);
+
+ // DB 업데이트
+ $columns = ["i_filename", "i_note"];
+ $values = [$finalFiles, $i_note];
+
+ $jdb->uQuery("tbl_customer_image", $columns, $values, "WHERE i_uid = '$i_uid'");
+
+ $msg = "Updated successfully.";
+ $url = "/index_intranet.php?view=customer_detail&mode=update&c_uid=$i_customeruid&$goStr";
+
+ $func->modalMsg($msg, $url);
+ exit();
+}
+
+
+//////////////////////////////////////////////
+// DELETE IMAGE (i_status = 'I')
+//////////////////////////////////////////////
+if ($actionStr == "DELETEIMAGE") {
+
+ $i_uid = $_POST['i_uid'] ?? "";
+ $i_customeruid = $_POST['i_customeruid'] ?? "";
+
+ if ($i_uid == "" || $i_customeruid == "") {
+ $msg = "Invalid image data.";
+ $func->modalMsg($msg, "");
+ exit();
+ }
+
+ $columns = array("i_status");
+ $values = array("I");
+ $where = "WHERE i_uid = '$i_uid'";
+
+ $jdb->uQuery("tbl_customer_image", $columns, $values, $where);
+
+ // 완료 후 이동
+ $msg = "Image deleted successfully.";
+ $urlSTR = "/index_intranet.php?view=customer_detail&mode=update&c_uid=$i_customeruid&$goStr";
+
+ $func->modalMsg($msg, $urlSTR);
+ exit();
+}
//////////////////////////////////////////////