Compare commits
2 Commits
19bf534086
...
0605948ab5
| Author | SHA1 | Date | |
|---|---|---|---|
| 0605948ab5 | |||
|
|
d134b27614 |
@@ -74,7 +74,10 @@ $routes->group('', ['namespace' => 'App\Controllers\Article'], static function (
|
|||||||
$routes->post('rsrvcancel', 'Receipt::rsrvcancel'); // 예약취소
|
$routes->post('rsrvcancel', 'Receipt::rsrvcancel'); // 예약취소
|
||||||
$routes->post('sendSms', 'Receipt::sendSms'); // 문자발송
|
$routes->post('sendSms', 'Receipt::sendSms'); // 문자발송
|
||||||
$routes->post('saveRecInfo', 'Receipt::saveRecInfo'); // 거주인정보저장
|
$routes->post('saveRecInfo', 'Receipt::saveRecInfo'); // 거주인정보저장
|
||||||
|
$routes->post('uploadFile', 'Receipt::uploadFile'); // 파일업로드
|
||||||
|
$routes->post('removeUploadFile', 'Receipt::removeUploadFile'); // 파일삭제
|
||||||
|
$routes->get('downloadAllImages', 'Receipt::downloadAllImages'); // 이미지 일괄 다운로드
|
||||||
|
$routes->post('saveImgLocation', 'Receipt::saveImgLocation'); // 촬영위치 저장
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
namespace App\Controllers\Article;
|
namespace App\Controllers\Article;
|
||||||
|
|
||||||
use App\Controllers\BaseController;
|
use App\Controllers\BaseController;
|
||||||
|
use App\Libraries\Common;
|
||||||
use App\Libraries\MyUpload;
|
use App\Libraries\MyUpload;
|
||||||
use App\Models\article\ReceiptModel;
|
use App\Models\article\ReceiptModel;
|
||||||
use App\Models\common\CodeModel;
|
use App\Models\common\CodeModel;
|
||||||
@@ -461,4 +462,331 @@ class Receipt extends BaseController
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 파일업로드
|
||||||
|
public function uploadFile()
|
||||||
|
{
|
||||||
|
$lib = new MyUpload();
|
||||||
|
$common = new Common();
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
$rcpt_key = $this->request->getPost('rcpt_key');
|
||||||
|
$rsrv_sq = $this->request->getPost('rsrv_sq');
|
||||||
|
$rcpt_sq = $this->request->getPost('rcpt_sq');
|
||||||
|
$img_type = $this->request->getPost('img_type');
|
||||||
|
|
||||||
|
$files = $this->request->getFiles();
|
||||||
|
$uploadPath = "/upload/result/" . $rsrv_sq . "/";
|
||||||
|
|
||||||
|
if (!isset($files['files'])) {
|
||||||
|
return $this->response->setJSON([
|
||||||
|
'success' => false,
|
||||||
|
'msg' => '파일 없음'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$uploadFiles = $files['files'];
|
||||||
|
if ($uploadFiles instanceof \CodeIgniter\HTTP\Files\UploadedFile) {
|
||||||
|
$uploadFiles = [$uploadFiles];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 매물정보 가져오기
|
||||||
|
$receipt = $this->model->getDetail($rcpt_key);
|
||||||
|
|
||||||
|
// 워터마크 이미지 조회
|
||||||
|
$watermark_info = [];
|
||||||
|
if (!empty($receipt) && ($receipt['comp_sq'] ?? '') == '2') {
|
||||||
|
$watermark_info = $this->model->getWatermarkList($receipt['rcpt_cpid']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$arrUploadfile = [];
|
||||||
|
foreach ($uploadFiles as $file) {
|
||||||
|
|
||||||
|
log_message('info', '[Receipt::uploadFile] upload start name={name} size={size} type={type} error={error}:{errorString} path={path}', [
|
||||||
|
'name' => $file->getName(),
|
||||||
|
'size' => $file->getSize(),
|
||||||
|
'type' => $file->getMimeType(),
|
||||||
|
'error' => $file->getError(),
|
||||||
|
'errorString' => $file->getErrorString(),
|
||||||
|
'path' => $uploadPath,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$uploadData = $lib->do_upload2($file, $uploadPath);
|
||||||
|
|
||||||
|
if ($uploadData !== false) {
|
||||||
|
$arrUploadfile[] = $uploadData;
|
||||||
|
log_message('info', '[Receipt::uploadFile] upload success name={name} stored={stored}', [
|
||||||
|
'name' => $file->getName(),
|
||||||
|
'stored' => $uploadData['file_name'] ?? '(unknown)',
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
log_message('error', '[Receipt::uploadFile] do_upload2 failed name={name} error={error}:{errorString}', [
|
||||||
|
'name' => $file->getName(),
|
||||||
|
'error' => $file->getError(),
|
||||||
|
'errorString' => $file->getErrorString(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$gps_lat = null;
|
||||||
|
$gps_lon = null;
|
||||||
|
$camDate = null;
|
||||||
|
if (!empty($arrUploadfile)) {
|
||||||
|
foreach ($arrUploadfile as $key => $uploadFile) {
|
||||||
|
$object_storage_url = $uploadFile['object_storage_url'];
|
||||||
|
$imgWidth = '';
|
||||||
|
$imgHeight = '';
|
||||||
|
|
||||||
|
if ($img_type !== 'V1') {
|
||||||
|
$base = $uploadFile['base_name']; // xxxx
|
||||||
|
$dir = rtrim(dirname($uploadFile['object_key']), '/'); // upload/result/*
|
||||||
|
$thumbKey = $dir . '/' . $base . '_thumb.jpg';
|
||||||
|
|
||||||
|
$imageDataBlob = file_get_contents($object_storage_url);
|
||||||
|
$im = new \Imagick();
|
||||||
|
$im->readImageBlob($imageDataBlob);
|
||||||
|
$imgWidth = $im->getImageWidth();
|
||||||
|
$imgHeight = $im->getImageHeight();
|
||||||
|
$im->thumbnailImage(105, 80, false);
|
||||||
|
$thumb_im = $im->getImageBlob();
|
||||||
|
// 썸네일 s3 전송
|
||||||
|
$lib->upload_object_storage_imagick2($thumbKey, $thumb_im);
|
||||||
|
$im->destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 워터마크 삽입
|
||||||
|
$watermark_imgs = ['I3', 'I4'];
|
||||||
|
if (in_array($img_type, $watermark_imgs)) {
|
||||||
|
if (!empty($watermark_info)) {
|
||||||
|
$common->watermarking($object_storage_url, $watermark_info, '', $receipt['rcpt_cpid'], $uploadFile['object_key']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 촬영정보 가져오기
|
||||||
|
$arrExifData = @exif_read_data($object_storage_url);
|
||||||
|
if (!is_array($arrExifData)) {
|
||||||
|
$arrExifData = [];
|
||||||
|
}
|
||||||
|
if (!isset($arrExifData['COMPUTED']) || !is_array($arrExifData['COMPUTED'])) {
|
||||||
|
$arrExifData['COMPUTED'] = [];
|
||||||
|
}
|
||||||
|
$notFound = "Unavailable";
|
||||||
|
|
||||||
|
// Make - 카메라 제조사
|
||||||
|
if (@array_key_exists('Make', $arrExifData)) {
|
||||||
|
$camMake = $arrExifData['Make'];
|
||||||
|
} else {
|
||||||
|
$camMake = $notFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Model - 카메라 모델
|
||||||
|
if (@array_key_exists('Model', $arrExifData)) {
|
||||||
|
$camModel = $arrExifData['Model'];
|
||||||
|
} else {
|
||||||
|
$camModel = $notFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Date - 촬영일시
|
||||||
|
if (@array_key_exists('DateTime', $arrExifData)) {
|
||||||
|
$camDate = $arrExifData['DateTime'];
|
||||||
|
} else {
|
||||||
|
$camDate = $notFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
// COMPUTED.Height - 세로크기
|
||||||
|
if (@array_key_exists('Height', $arrExifData['COMPUTED'])) {
|
||||||
|
$camHeight = $arrExifData['COMPUTED']['Height'];
|
||||||
|
} else {
|
||||||
|
$camHeight = $notFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
// COMPUTED.Width - 가로크기
|
||||||
|
if (@array_key_exists('Width', $arrExifData['COMPUTED'])) {
|
||||||
|
$camWidth = $arrExifData['COMPUTED']['Width'];
|
||||||
|
} else {
|
||||||
|
$camWidth = $notFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
$imageMetaData = "카메라 제조사: " . $camMake;
|
||||||
|
$imageMetaData .= "\n카메라 모델: " . $camModel;
|
||||||
|
$imageMetaData .= "\n촬영일시: " . $camDate;
|
||||||
|
$imageMetaData .= "\n가로: " . $camWidth;
|
||||||
|
$imageMetaData .= "\n세로: " . $camHeight;
|
||||||
|
|
||||||
|
$metaData = $imageMetaData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 파일업로드 내용 저장
|
||||||
|
*/
|
||||||
|
$uploadParam = [
|
||||||
|
'rcpt_key' => $rcpt_key, // 접수번호
|
||||||
|
'rsrv_sq' => $rsrv_sq, // 예약일련번호
|
||||||
|
'rcpt_sq' => $rcpt_sq, // 접수일련번호
|
||||||
|
// 'gps_lat' => $gps_lat, // latitude
|
||||||
|
// 'gps_lon' => $gps_lon, // longitude
|
||||||
|
'origin_name' => $uploadFile['origin_name'], // 원본파일명
|
||||||
|
'file_name' => $uploadFile['file_name'], // 저장파일명
|
||||||
|
'upload_path' => $uploadPath, // 저장경로
|
||||||
|
'size' => $file->getSize(),
|
||||||
|
'width' => $imgWidth,
|
||||||
|
'height' => $imgHeight,
|
||||||
|
// 'thumb_name' => $base . '_thumb.jpg',
|
||||||
|
'cam_date' => $camDate, // 촬영일
|
||||||
|
'meta_data' => $metaData, // 이미지메타데이터
|
||||||
|
'receipt' => $receipt,
|
||||||
|
'img_type' => $img_type,
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->model->saveImg($uploadParam);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->response->setJSON([
|
||||||
|
'code' => '0',
|
||||||
|
'msg' => 'success'
|
||||||
|
]);
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return $this->response->setJSON([
|
||||||
|
'code' => '9',
|
||||||
|
'msg' => $e->getMessage(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 매물사진 일괄 다운로드 (zip)
|
||||||
|
public function downloadAllImages()
|
||||||
|
{
|
||||||
|
$rsrv_sq = $this->request->getGet('rsrv_sq');
|
||||||
|
$img_type = $this->request->getGet('img_type') ?? 'I4';
|
||||||
|
|
||||||
|
if (empty($rsrv_sq)) {
|
||||||
|
return $this->response->setStatusCode(400)->setBody('rsrv_sq required');
|
||||||
|
}
|
||||||
|
|
||||||
|
$images = $this->model->getImageListByType($rsrv_sq, $img_type);
|
||||||
|
if (empty($images)) {
|
||||||
|
return $this->response->setStatusCode(404)->setBody('No files');
|
||||||
|
}
|
||||||
|
|
||||||
|
$zip = new \ZipArchive();
|
||||||
|
$zipName = 'images_' . $rsrv_sq . '_' . $img_type . '_' . date('Ymd_His') . '.zip';
|
||||||
|
$zipPath = WRITEPATH . 'cache/' . $zipName;
|
||||||
|
|
||||||
|
if ($zip->open($zipPath, \ZipArchive::CREATE | \ZipArchive::OVERWRITE) !== true) {
|
||||||
|
return $this->response->setStatusCode(500)->setBody('Failed to create zip');
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($images as $index => $img) {
|
||||||
|
$filePath = $img['img_path'] . $img['img_filenm'];
|
||||||
|
$zipFileName = sprintf('%02d_%s', $index + 1, basename($img['img_filenm']));
|
||||||
|
|
||||||
|
if (($img['cloud_upload_yn'] ?? 'N') === 'Y') {
|
||||||
|
$sourceUrl = NCLOUD_OBJECT_STORAGE_URL . $filePath;
|
||||||
|
$content = @file_get_contents($sourceUrl);
|
||||||
|
if ($content !== false) {
|
||||||
|
$zip->addFromString($zipFileName, $content);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$localPath = FCPATH . ltrim($filePath, '/');
|
||||||
|
if (is_file($localPath)) {
|
||||||
|
$zip->addFile($localPath, $zipFileName);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$content = @file_get_contents($filePath);
|
||||||
|
if ($content !== false) {
|
||||||
|
$zip->addFromString($zipFileName, $content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$zip->close();
|
||||||
|
|
||||||
|
if (!is_file($zipPath)) {
|
||||||
|
return $this->response->setStatusCode(500)->setBody('Zip not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
register_shutdown_function(static function () use ($zipPath) {
|
||||||
|
if (is_file($zipPath)) {
|
||||||
|
@unlink($zipPath);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return $this->response->download($zipPath, null)->setFileName($zipName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 촬영위치 저장
|
||||||
|
public function saveImgLocation()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
|
||||||
|
$img_sq = $this->request->getPost('img_sq');
|
||||||
|
$rsrv_sq = $this->request->getPost('rsrv_sq');
|
||||||
|
$location = $this->request->getPost('location');
|
||||||
|
|
||||||
|
$this->model->saveImgLocation($img_sq, $rsrv_sq, $location);
|
||||||
|
|
||||||
|
return $this->response->setJSON([
|
||||||
|
'code' => '0',
|
||||||
|
'msg' => 'success'
|
||||||
|
]);
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return $this->response->setJSON([
|
||||||
|
'code' => '9',
|
||||||
|
'msg' => $e->getMessage(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 업로드파일 삭제
|
||||||
|
public function removeUploadFile()
|
||||||
|
{
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
$rcpt_sq = $this->request->getPost('rcpt_sq');
|
||||||
|
$img_sq = $this->request->getPost('img_sq');
|
||||||
|
|
||||||
|
// 파일정보 조회
|
||||||
|
$file = $this->model->getUploadFileInfo($img_sq);
|
||||||
|
if (!empty($file)) {
|
||||||
|
$lib = new MyUpload();
|
||||||
|
|
||||||
|
$path = $file['img_path'] . "" . $file['img_filenm'];
|
||||||
|
|
||||||
|
|
||||||
|
$thumb = explode(".", $file['img_filenm']);
|
||||||
|
$thumbPath = $file['img_path'] . "" . $thumb[0] . "_thumb." . $thumb[1];
|
||||||
|
|
||||||
|
// if ($file['cloud_upload_yn'] == "Y") {
|
||||||
|
// $path = NCLOUD_OBJECT_STORAGE_URL . $path;
|
||||||
|
// }
|
||||||
|
|
||||||
|
$lib->deleteFile($path);
|
||||||
|
$lib->deleteFile($thumbPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->model->removeUploadFile($rcpt_sq, $img_sq);
|
||||||
|
|
||||||
|
|
||||||
|
return $this->response->setJSON([
|
||||||
|
'code' => '0',
|
||||||
|
'msg' => 'success'
|
||||||
|
]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return $this->response->setJSON([
|
||||||
|
'code' => '0',
|
||||||
|
'msg' => 'success'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -38,11 +38,7 @@ class Common
|
|||||||
*/
|
*/
|
||||||
public function watermarking($imagePath, $watermark_info, $wmText, $cpid, $key = '')
|
public function watermarking($imagePath, $watermark_info, $wmText, $cpid, $key = '')
|
||||||
{
|
{
|
||||||
|
$uploader = new MyUpload();
|
||||||
|
|
||||||
$CI =& get_instance();
|
|
||||||
|
|
||||||
$CI->load->library('upload');
|
|
||||||
|
|
||||||
$wmImagePath = ''; // 워터마크 이미지의 경로
|
$wmImagePath = ''; // 워터마크 이미지의 경로
|
||||||
$wmSpaceHeihgt = 0; // 워터마크 이미지 하단 공백
|
$wmSpaceHeihgt = 0; // 워터마크 이미지 하단 공백
|
||||||
@@ -54,9 +50,31 @@ class Common
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// $img = new Imagick($imagePath);
|
|
||||||
$img = new \Imagick();
|
$img = new \Imagick();
|
||||||
$img->readImageBlob($imagePath);
|
if (is_string($imagePath) && is_file($imagePath)) {
|
||||||
|
$img->readImage($imagePath);
|
||||||
|
} elseif (is_string($imagePath) && filter_var($imagePath, FILTER_VALIDATE_URL)) {
|
||||||
|
$headers = @get_headers($imagePath, 1) ?: [];
|
||||||
|
$blob = @file_get_contents($imagePath);
|
||||||
|
$contentType = '';
|
||||||
|
if (!empty($headers)) {
|
||||||
|
$contentType = is_array($headers['Content-Type'] ?? null)
|
||||||
|
? end($headers['Content-Type'])
|
||||||
|
: ($headers['Content-Type'] ?? '');
|
||||||
|
}
|
||||||
|
log_message('info', '[watermarking] source url={url} status={status} content_type={ctype} size={size}', [
|
||||||
|
'url' => $imagePath,
|
||||||
|
'status' => is_array($headers) && isset($headers[0]) ? $headers[0] : '(no status)',
|
||||||
|
'ctype' => $contentType,
|
||||||
|
'size' => $blob === false ? 0 : strlen($blob),
|
||||||
|
]);
|
||||||
|
if ($blob === false) {
|
||||||
|
throw new \RuntimeException('Failed to load image from URL');
|
||||||
|
}
|
||||||
|
$img->readImageBlob($blob);
|
||||||
|
} else {
|
||||||
|
$img->readImageBlob($imagePath);
|
||||||
|
}
|
||||||
|
|
||||||
$hImg = $img->getImageHeight();
|
$hImg = $img->getImageHeight();
|
||||||
$wImg = $img->getImageWidth();
|
$wImg = $img->getImageWidth();
|
||||||
@@ -90,7 +108,7 @@ class Common
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
$wm = new Imagick(FCPATH . $wmImagePath);
|
$wm = new \Imagick($wmImagePath);
|
||||||
$hWm = $wm->getImageHeight();
|
$hWm = $wm->getImageHeight();
|
||||||
$wWm = $wm->getImageWidth();
|
$wWm = $wm->getImageWidth();
|
||||||
|
|
||||||
@@ -98,22 +116,25 @@ class Common
|
|||||||
$wmImgTop = floor(($hImg - $hWm - $wmSpaceHeihgt - $wmTextHeight) / 2); // 워터마크 이미지의 위치 top
|
$wmImgTop = floor(($hImg - $hWm - $wmSpaceHeihgt - $wmTextHeight) / 2); // 워터마크 이미지의 위치 top
|
||||||
$wmTxtTop = $wmImgTop + $hWm + $wmSpaceHeihgt + ($wmTextHeight * 0.6); // 워터마크 텍스트의 위치
|
$wmTxtTop = $wmImgTop + $hWm + $wmSpaceHeihgt + ($wmTextHeight * 0.6); // 워터마크 텍스트의 위치
|
||||||
|
|
||||||
$img->compositeImage($wm, imagick::COMPOSITE_OVER, $wmImgLeft, $wmImgTop, imagick::ALIGN_CENTER);
|
$img->compositeImage($wm, \Imagick::COMPOSITE_OVER, $wmImgLeft, $wmImgTop);
|
||||||
$wm->destroy();
|
$wm->destroy();
|
||||||
|
|
||||||
$draw = new \ImagickDraw();
|
$draw = new \ImagickDraw();
|
||||||
|
|
||||||
$wmFont = BASEPATH . 'fonts/' . $wmFont;
|
$basePath = defined('BASEPATH') ? BASEPATH : (defined('ROOTPATH') ? ROOTPATH . 'system/' : '');
|
||||||
$draw->setFont($wmFont);
|
$wmFont = $basePath . 'fonts/' . $wmFont;
|
||||||
|
if (is_file($wmFont)) {
|
||||||
|
$draw->setFont($wmFont);
|
||||||
|
}
|
||||||
|
|
||||||
$draw->setFontSize($wmFontSize);
|
$draw->setFontSize($wmFontSize);
|
||||||
$draw->setFillColor(new ImagickPixel($wmTextColor));
|
$draw->setFillColor(new \ImagickPixel($wmTextColor));
|
||||||
// $draw->setFillAlpha( $wmTextAlpha );
|
// $draw->setFillAlpha( $wmTextAlpha );
|
||||||
$draw->setFillOpacity($wmTextAlpha); // 워터마크 텍스트 투명도 설정
|
$draw->setFillOpacity($wmTextAlpha); // 워터마크 텍스트 투명도 설정
|
||||||
$draw->setTextAlignment(2); // center
|
$draw->setTextAlignment(2); // center
|
||||||
$draw->setStrokeAntialias(1);
|
$draw->setStrokeAntialias(1);
|
||||||
$draw->setStrokeWidth(1);
|
$draw->setStrokeWidth(1);
|
||||||
$draw->setStrokeColor(new ImagickPixel('#000000'));
|
$draw->setStrokeColor(new \ImagickPixel('#000000'));
|
||||||
// $draw->setStrokeAlpha(0.1);
|
// $draw->setStrokeAlpha(0.1);
|
||||||
$draw->setStrokeOpacity(0.1);
|
$draw->setStrokeOpacity(0.1);
|
||||||
$draw->annotation($wImg / 2, $wmTxtTop, $wmText);
|
$draw->annotation($wImg / 2, $wmTxtTop, $wmText);
|
||||||
@@ -125,12 +146,27 @@ class Common
|
|||||||
|
|
||||||
$watermark_img = $img->getImageBlob();
|
$watermark_img = $img->getImageBlob();
|
||||||
|
|
||||||
$CI->upload->upload_object_storage_imagick($key, $watermark_img);
|
if (empty($key)) {
|
||||||
|
throw new \RuntimeException('Empty upload key');
|
||||||
|
}
|
||||||
|
$ok = $uploader->upload_object_storage_imagick2($key, $watermark_img);
|
||||||
|
if ($ok) {
|
||||||
|
log_message('info', '[watermarking] upload success key={key} size={size} cpid={cpid}', [
|
||||||
|
'key' => $key,
|
||||||
|
'size' => strlen($watermark_img),
|
||||||
|
'cpid' => $cpid,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
log_message('error', '[watermarking] upload failed key={key} cpid={cpid}', [
|
||||||
|
'key' => $key,
|
||||||
|
'cpid' => $cpid,
|
||||||
|
]);
|
||||||
|
}
|
||||||
$img->destroy();
|
$img->destroy();
|
||||||
|
|
||||||
// $object_upload = $this->upload->upload_object_storage($imagePath , $imagePath , 'data');
|
// $object_upload = $this->upload->upload_object_storage($imagePath , $imagePath , 'data');
|
||||||
} catch (Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
echo $e->getMessage();
|
log_message('error', '[watermarking] ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1035,6 +1035,7 @@ class ReceiptModel extends Model
|
|||||||
,a.rcpt_sido
|
,a.rcpt_sido
|
||||||
,a.rcpt_gugun
|
,a.rcpt_gugun
|
||||||
,a.rcpt_dong
|
,a.rcpt_dong
|
||||||
|
,c.region_nm AS addr
|
||||||
,a.rcpt_dtl_addr
|
,a.rcpt_dtl_addr
|
||||||
,a.rcpt_li_addr
|
,a.rcpt_li_addr
|
||||||
,a.rcpt_jibun_addr
|
,a.rcpt_jibun_addr
|
||||||
@@ -1145,7 +1146,6 @@ class ReceiptModel extends Model
|
|||||||
,get_code_name('RECEIPT_STATUS3', a.rcpt_stat) AS rcpt_stat_nm
|
,get_code_name('RECEIPT_STATUS3', a.rcpt_stat) AS rcpt_stat_nm
|
||||||
,DATE_FORMAT(a.insert_tm, '%Y년 %m월 %d일') as insert_tm2
|
,DATE_FORMAT(a.insert_tm, '%Y년 %m월 %d일') as insert_tm2
|
||||||
,DATE_FORMAT(a.rsrv_date, '%Y-%m-%d') as rsrv_date2
|
,DATE_FORMAT(a.rsrv_date, '%Y-%m-%d') as rsrv_date2
|
||||||
,c.region_nm as addr
|
|
||||||
,c.dept_sq as region_dept_sq
|
,c.dept_sq as region_dept_sq
|
||||||
,c.usr_sq as region_usr_sq
|
,c.usr_sq as region_usr_sq
|
||||||
,d.pdept_sq
|
,d.pdept_sq
|
||||||
@@ -1348,6 +1348,20 @@ class ReceiptModel extends Model
|
|||||||
return $query->getResultArray();
|
return $query->getResultArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getImageListByType($rsrv_sq, $img_type)
|
||||||
|
{
|
||||||
|
$sql = "SELECT * " .
|
||||||
|
" FROM result_imgs" .
|
||||||
|
" WHERE rsrv_sq = ?" .
|
||||||
|
" AND img_type = ?" .
|
||||||
|
" AND use_yn = 'Y'" .
|
||||||
|
" ORDER BY view_odr";
|
||||||
|
|
||||||
|
$data = [$rsrv_sq, $img_type];
|
||||||
|
$query = $this->db->query($sql, $data);
|
||||||
|
return $query->getResultArray();
|
||||||
|
}
|
||||||
|
|
||||||
public function getImageCountByType($rsrv_sq)
|
public function getImageCountByType($rsrv_sq)
|
||||||
{
|
{
|
||||||
$sql = "SELECT img_type, COUNT(*) img_cnt" .
|
$sql = "SELECT img_type, COUNT(*) img_cnt" .
|
||||||
@@ -1669,9 +1683,9 @@ class ReceiptModel extends Model
|
|||||||
";
|
";
|
||||||
$param = [
|
$param = [
|
||||||
$data['rsrv_sq'],
|
$data['rsrv_sq'],
|
||||||
$f['file_path'],
|
$f['upload_path'],
|
||||||
$f['new_name'],
|
$f['file_name'],
|
||||||
$f['orig_name'],
|
$f['origin_name'],
|
||||||
$f['size'],
|
$f['size'],
|
||||||
$data['rec_tel'],
|
$data['rec_tel'],
|
||||||
$data['rec_nm'],
|
$data['rec_nm'],
|
||||||
@@ -1709,4 +1723,325 @@ class ReceiptModel extends Model
|
|||||||
'success' => true,
|
'success' => true,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 워터마크 조회
|
||||||
|
public function getWatermarkList($rcpt_cpid)
|
||||||
|
{
|
||||||
|
$builder = $this->db->table('watermark');
|
||||||
|
|
||||||
|
$builder->select('cpid, wm_type, wm_img_path, wm_img_height, wm_img_width, wm_position, wm_img_opacity, wm_space, text_font, text_color, text_opacity, text_size, text_pixel, img_width_min, img_width_max');
|
||||||
|
|
||||||
|
$builder->where('cpid', $rcpt_cpid);
|
||||||
|
|
||||||
|
|
||||||
|
$row = $builder->get()->getResultArray();
|
||||||
|
return $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 업로드정보 저장
|
||||||
|
public function saveImg($param)
|
||||||
|
{
|
||||||
|
$this->db->transStart();
|
||||||
|
|
||||||
|
$usr_id = session('usr_id');
|
||||||
|
$usr_sq = session('usr_sq');
|
||||||
|
|
||||||
|
$receipt = $param['receipt'];
|
||||||
|
|
||||||
|
$cloud_upload_yn = 'Y';
|
||||||
|
|
||||||
|
if ($param['img_type'] == 'I6' || $param['img_type'] == 'I7') {
|
||||||
|
$yn_sql = "update receipt " .
|
||||||
|
" set exp_spc_yn = 'Y' " .
|
||||||
|
" where rcpt_sq = ? ";
|
||||||
|
$yn_data = [$param['rcpt_sq']];
|
||||||
|
$this->db->query($yn_sql, $yn_data);
|
||||||
|
} else if ($param['img_type'] == 'I8') {
|
||||||
|
$yn_sql = "update receipt " .
|
||||||
|
" set exp_spc_yn = 'Y' " .
|
||||||
|
" where rcpt_sq = ? ";
|
||||||
|
$yn_data = [$param['rcpt_sq']];
|
||||||
|
$this->db->query($yn_sql, $yn_data);
|
||||||
|
} else if ($param['img_type'] == 'I9') {
|
||||||
|
$yn_sql = "update receipt " .
|
||||||
|
" set image_360_yn = 'Y' " .
|
||||||
|
" where rcpt_sq = ? ";
|
||||||
|
$yn_data = [$param['rcpt_sq']];
|
||||||
|
$this->db->query($yn_sql, $yn_data);
|
||||||
|
} else if ($param['img_type'] == 'I11') {
|
||||||
|
$yn_sql = "update receipt " .
|
||||||
|
" set check_list_img_yn = 'Y' " .
|
||||||
|
" where rcpt_sq = ? ";
|
||||||
|
$yn_data = [$param['rcpt_sq']];
|
||||||
|
$this->db->query($yn_sql, $yn_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
//한장의 사진만 업로드하는것들은 UPDATE -> INSERT
|
||||||
|
$img_list = ['I1', 'I2', 'I5', 'I6', 'I7', 'V1', 'I10', 'I11'];
|
||||||
|
|
||||||
|
// 주소가 rcpt_jibun_addr 있을때는 그 주소로
|
||||||
|
$addr_nm = $receipt['addr'];
|
||||||
|
if ($receipt['rcpt_jibun_addr']) {
|
||||||
|
$img_hannm = '컨펌스_' . $addr_nm . ' ' . $receipt['rcpt_jibun_addr'] . ' ' . $receipt['rcpt_etc_addr'] . '_' . $receipt['excls_spc'] . '.jpeg';
|
||||||
|
} else {
|
||||||
|
$img_hannm = '컨펌스_' . $addr_nm . ' ' . $receipt['rcpt_dtl_addr'] . ' ' . $receipt['rcpt_ho'] . '_' . $receipt['excls_spc'] . '.jpeg';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array($param['img_type'], $img_list)) {
|
||||||
|
//업데이트할게없어도 에러가 안난다 단지 row(s)affected 가 0 일뿐
|
||||||
|
$sql = "UPDATE result_imgs" .
|
||||||
|
" SET use_yn = 'N'" .
|
||||||
|
" WHERE rsrv_sq = ?" .
|
||||||
|
" AND img_type = ?" .
|
||||||
|
" AND use_yn = 'Y'";
|
||||||
|
$data = [$param['rsrv_sq'], $param['img_type']];
|
||||||
|
$this->db->query($sql, $data);
|
||||||
|
|
||||||
|
//새로운 이미지 생성
|
||||||
|
$sql = "INSERT INTO result_imgs(rsrv_sq, use_yn, img_type, view_odr, img_path, img_filenm, img_nm, img_size, img_width, img_height, insert_usr, insert_tm, meta_data, img_hannm , cloud_upload_yn )" .
|
||||||
|
"VALUES (?, 'Y', ?, 1, ?, ?, ?, ?, ?, ?, ?, NOW(), ?,? , ?)";
|
||||||
|
$data = [
|
||||||
|
$param['rsrv_sq'],
|
||||||
|
$param['img_type'],
|
||||||
|
$param['upload_path'],
|
||||||
|
$param['file_name'],
|
||||||
|
$param['origin_name'],
|
||||||
|
$param['size'],
|
||||||
|
$param['width'],
|
||||||
|
$param['height'],
|
||||||
|
$usr_sq,
|
||||||
|
isset($param['meta_data']) ? $param['meta_data'] : null,
|
||||||
|
$img_hannm,
|
||||||
|
$cloud_upload_yn
|
||||||
|
];
|
||||||
|
$res = $this->db->query($sql, $data);
|
||||||
|
} else {
|
||||||
|
$odr_sql = "SELECT COALESCE(MAX(view_odr), 0) + 1 as seq FROM result_imgs WHERE rsrv_sq = ? AND img_type = ? AND use_yn = 'Y'";
|
||||||
|
$odr_data = array($param['rsrv_sq'], $param['img_type']);
|
||||||
|
$query = $this->db->query($odr_sql, $odr_data);
|
||||||
|
$row = $query->getRowArray();
|
||||||
|
$view_odr = $row['seq'];
|
||||||
|
|
||||||
|
$sql = "INSERT INTO result_imgs(rsrv_sq, use_yn, img_type, view_odr, img_path, img_filenm, img_nm, img_size, img_width, img_height, insert_usr, insert_tm, meta_data, img_hannm , cloud_upload_yn )" .
|
||||||
|
"VALUES (?, 'Y', ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW(), ?,?, ?)";
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
$param['rsrv_sq'],
|
||||||
|
$param['img_type'],
|
||||||
|
$view_odr,
|
||||||
|
$param['upload_path'],
|
||||||
|
$param['file_name'],
|
||||||
|
$param['origin_name'],
|
||||||
|
$param['size'],
|
||||||
|
$param['width'],
|
||||||
|
$param['height'],
|
||||||
|
$usr_sq,
|
||||||
|
isset($param['meta_data']) ? $param['meta_data'] : null,
|
||||||
|
$img_hannm,
|
||||||
|
$cloud_upload_yn
|
||||||
|
];
|
||||||
|
$res = $this->db->query($sql, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($res) {
|
||||||
|
switch ($param['img_type']) {
|
||||||
|
case 'I1':
|
||||||
|
$remark = "홍보확인서 사진 업로드";
|
||||||
|
break;
|
||||||
|
case 'I2':
|
||||||
|
$remark = "현장확인 내역서 사진 업로드";
|
||||||
|
break;
|
||||||
|
case 'I3':
|
||||||
|
$remark = "건물외관 사진 업르도";
|
||||||
|
break;
|
||||||
|
case 'I4':
|
||||||
|
$remark = "매물사진 업로드";
|
||||||
|
break;
|
||||||
|
case 'I5':
|
||||||
|
$remark = "평면도 업로드";
|
||||||
|
break;
|
||||||
|
case 'I6':
|
||||||
|
$remark = "전용면적 파일 업로드";
|
||||||
|
break;
|
||||||
|
case 'I7':
|
||||||
|
$remark = "공용면적 파일 업로드";
|
||||||
|
break;
|
||||||
|
case 'I8':
|
||||||
|
$remark = "분양권 파일 업로드";
|
||||||
|
break;
|
||||||
|
case 'I9':
|
||||||
|
$remark = "360이미지 업로드";
|
||||||
|
break;
|
||||||
|
case 'I10':
|
||||||
|
$remark = "촬영동의서 사진 업로드";
|
||||||
|
break;
|
||||||
|
case 'I11':
|
||||||
|
$remark = "체크리스트 사진 업로드";
|
||||||
|
break;
|
||||||
|
case 'V1':
|
||||||
|
$remark = "동영상 업로드";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$this->saveChangedHistory($param['rcpt_sq'], $receipt['rcpt_stat'], 'C16', $usr_id, $remark);
|
||||||
|
|
||||||
|
$this->db->transComplete();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'success' => true,
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
return [
|
||||||
|
'success' => false,
|
||||||
|
'msg' => '저장실패',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 파일정보조회
|
||||||
|
public function getUploadFileInfo($img_sq)
|
||||||
|
{
|
||||||
|
$sql = "SELECT * FROM result_imgs WHERE img_sq = ?";
|
||||||
|
|
||||||
|
$query = $this->db->query($sql, [$img_sq]);
|
||||||
|
$row = $query->getRowArray();
|
||||||
|
|
||||||
|
return $row;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 업로드파일 삭제
|
||||||
|
public function removeUploadFile($rcpt_sq, $img_sq)
|
||||||
|
{
|
||||||
|
$this->db->transStart();
|
||||||
|
|
||||||
|
$usr_id = session('usr_id');
|
||||||
|
|
||||||
|
// 이미지정보 조회
|
||||||
|
$row = $this->getUploadFileInfo($img_sq);
|
||||||
|
|
||||||
|
if (!empty($row)) {
|
||||||
|
|
||||||
|
if ($row['img_type'] == 'I6' || $row['img_type'] == 'I7') {
|
||||||
|
$yn_sql = "update receipt " .
|
||||||
|
" set exp_spc_yn = 'N' " .
|
||||||
|
" where rcpt_sq = ? ";
|
||||||
|
$yn_data = [$rcpt_sq];
|
||||||
|
$this->db->query($yn_sql, $yn_data);
|
||||||
|
} else if ($row['img_type'] == 'I8') {
|
||||||
|
$yn_sql = "UPDATE receipt" .
|
||||||
|
" SET parcel_out_yn = CASE (SELECT COUNT('x')" .
|
||||||
|
" FROM result_imgs " .
|
||||||
|
" WHERE rsrv_sq = (SELECT rsrv_sq FROM result_imgs WHERE img_sq = ? AND img_type = 'I8')" .
|
||||||
|
" AND use_yn = 'Y'" .
|
||||||
|
" AND img_type = 'I8') WHEN 0 THEN 'N' ELSE 'Y' END" .
|
||||||
|
" WHERE rcpt_sq = ? ";
|
||||||
|
$yn_data = [$rcpt_sq];
|
||||||
|
$this->db->query($yn_sql, $yn_data);
|
||||||
|
} else if ($row['img_type'] == 'I9') {
|
||||||
|
$yn_sql = "UPDATE receipt" .
|
||||||
|
" SET image_360_yn = (" .
|
||||||
|
" CASE (SELECT COUNT(1)" .
|
||||||
|
" FROM result_imgs" .
|
||||||
|
" WHERE rsrv_sq = (SELECT rsrv_sq FROM result_imgs WHERE img_sq = ? AND img_type = 'I9')" .
|
||||||
|
" AND img_type = 'I9' AND use_yn = 'Y')" .
|
||||||
|
" WHEN 0 THEN 'N'" .
|
||||||
|
" ELSE 'Y'" .
|
||||||
|
" END" .
|
||||||
|
" )" .
|
||||||
|
" WHERE rcpt_sq = ?";
|
||||||
|
$yn_data = [$rcpt_sq];
|
||||||
|
$this->db->query($yn_sql, $yn_data);
|
||||||
|
} else if ($row['img_type'] == 'I11') {
|
||||||
|
$yn_sql = "update receipt " .
|
||||||
|
" set check_list_img_yn = 'N' " .
|
||||||
|
" where rcpt_sq = ? ";
|
||||||
|
$yn_data = [$rcpt_sq];
|
||||||
|
$this->db->query($yn_sql, $yn_data);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//삭제이미지보다 순번이 높은거는 순번 업데이트
|
||||||
|
$sql = "UPDATE result_imgs SET view_odr = view_odr - 1 WHERE rsrv_sq = ? AND img_type = ? AND view_odr > ? AND use_yn = 'Y'";
|
||||||
|
$data = [$row['rsrv_sq'], $row['img_type'], $row['view_odr']];
|
||||||
|
|
||||||
|
$this->db->query($sql, $data);
|
||||||
|
|
||||||
|
|
||||||
|
//이미지 삭제
|
||||||
|
$sql = "DELETE FROM result_imgs WHERE img_sq = ?";
|
||||||
|
$data = [$img_sq];
|
||||||
|
|
||||||
|
if ($this->db->query($sql, $data) === false) {
|
||||||
|
return [
|
||||||
|
'success' => false,
|
||||||
|
'msg' => '삭제실패',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (in_array($row['img_type'], ['I1', 'I2', 'I8', 'I10', 'I11'])) {
|
||||||
|
$remark = "";
|
||||||
|
switch ($row['img_type']) {
|
||||||
|
case 'I1':
|
||||||
|
$remark = "홍보확인서 사진 삭제";
|
||||||
|
break;
|
||||||
|
case 'I2':
|
||||||
|
$remark = "현장확인 내역서 사진 삭제";
|
||||||
|
break;
|
||||||
|
case 'I8':
|
||||||
|
$remark = "분양권 파일 삭제";
|
||||||
|
break;
|
||||||
|
case 'I10':
|
||||||
|
$remark = "촬영동의서 사진 삭제";
|
||||||
|
break;
|
||||||
|
case 'I11':
|
||||||
|
$remark = "체크리스트 사진 삭제";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 상태값을 가져오기위한 쿼리 해오기
|
||||||
|
$sql = "SELECT rcpt_stat FROM receipt WHERE rcpt_sq = ?";
|
||||||
|
$data = [$rcpt_sq];
|
||||||
|
$query = $this->db->query($sql, $data);
|
||||||
|
$row = $query->getRowArray();
|
||||||
|
|
||||||
|
$this->saveChangedHistory($rcpt_sq, $row['rcpt_stat'], 'C31', $usr_id, $remark);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->db->transComplete();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'success' => true,
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 촬영위치 저장
|
||||||
|
public function saveImgLocation($img_sq, $rsrv_sq, $location)
|
||||||
|
{
|
||||||
|
$sql = "UPDATE result_imgs" .
|
||||||
|
" SET img_location = ?" .
|
||||||
|
" WHERE img_sq = ?" .
|
||||||
|
" AND rsrv_sq = ?";
|
||||||
|
|
||||||
|
$data = [$location, $img_sq, $rsrv_sq];
|
||||||
|
|
||||||
|
if ($this->db->query($sql, $data) === false) {
|
||||||
|
return [
|
||||||
|
'success' => false,
|
||||||
|
'msg' => '저장실패',
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
return [
|
||||||
|
'success' => true,
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user