246 lines
6.7 KiB
PHP
246 lines
6.7 KiB
PHP
<?php
|
|
include getenv("DOCUMENT_ROOT")."/include/session_include.php";
|
|
require_once getenv("DOCUMENT_ROOT")."/assets/dbCon.php";
|
|
|
|
$c_uid = $_GET['c_uid'];
|
|
$goStr = $_GET['goStr'];
|
|
|
|
//Load driver list
|
|
if ($_SESSION['ss_LEVEL'] == 9) {
|
|
$qrySTR = " AND (m_uid = '".$_SESSION['ss_UID']."') ";
|
|
} else {
|
|
$qrySTR = "";
|
|
}
|
|
|
|
$drivers = array();
|
|
$sqDriver = qry("SELECT
|
|
*
|
|
FROM
|
|
tbl_member
|
|
WHERE
|
|
m_level in (8,9) AND m_status = 'A' ".$qrySTR." AND m_gid = 0
|
|
ORDER BY
|
|
m_initial ASC ");
|
|
while($rstDriver = fetch_array($sqDriver)){
|
|
$drivers[] = array(
|
|
"id" => $rstDriver['m_uid'],
|
|
"name" => $rstDriver['m_initial']
|
|
);
|
|
}
|
|
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>Upload Image</title>
|
|
</head>
|
|
<body>
|
|
|
|
<div class="upload-box">
|
|
|
|
<div class="title-row">
|
|
<span>UPLOAD IMAGE</span>
|
|
</div>
|
|
<p style="font-size:12px; color:#666; margin-top:4px;">
|
|
※ Maximum 6 images can be uploaded <br>
|
|
※ Info Type image will stay the same <br>
|
|
※ Other Type images will be replaced with newly uploaded images<br>
|
|
</p>
|
|
<form method="POST" action="/lib/user_process.php" enctype="multipart/form-data">
|
|
|
|
<input type="hidden" name="actionStr" value="ADDIMAGE">
|
|
<input type="hidden" name="i_customeruid" value="<?=$c_uid?>">
|
|
<input type="hidden" name="i_memberuid" value="<?=$_SESSION['ss_UID']?>">
|
|
<input type="hidden" name="goStr" value="<?=$goStr?>">
|
|
<input type="hidden" name="mode" value="create">
|
|
|
|
<div class="tb-info">
|
|
|
|
<label>Created By</label>
|
|
<select name="i_createdby" id="driver" class="custom-select-map-orderby" required>
|
|
<option value="">Select</option>
|
|
<?php
|
|
foreach($drivers as $driver) {
|
|
// 양쪽 값의 공백을 제거하고 문자열로 강제 변환하여 비교
|
|
$is_selected = (trim((string)$driver['id']) === trim((string)$_SESSION['ss_UID']));
|
|
$selected = $is_selected ? "selected" : "";
|
|
echo '<option value="'.$driver['id'].'" '.$selected.'>'.$driver['name'].'</option>';
|
|
}
|
|
?>
|
|
</select>
|
|
|
|
<label>Type</label>
|
|
<select name="i_type" id="i_type" required>
|
|
<?php if ($_SESSION['ss_LEVEL'] == 9) { ?>
|
|
<option value="info" selected>Info</option>
|
|
<?php } else { ?>
|
|
<option value="info">Info</option>
|
|
<option value="install">Install</option>
|
|
<option value="install_order">Install Request</option>
|
|
<option value="clean_before">Before Clean</option>
|
|
<option value="clean_after">After Clean</option>
|
|
<?php } ?>
|
|
</select>
|
|
|
|
<label>Image</label>
|
|
|
|
<input type="file" id="uploadFileInput" name="upload_file[]" accept="image/*" multiple required>
|
|
|
|
<div id="previewList" style="display:flex; gap:8px; flex-wrap:wrap; margin-top:12px;"></div>
|
|
|
|
<label>Note</label>
|
|
<textarea name="i_note" rows="3"></textarea>
|
|
|
|
</div>
|
|
|
|
<button type="submit" class="btn-save">UPLOAD</button>
|
|
<button type="button" class="btn-close" onclick="window.close();">CLOSE</button>
|
|
</form>
|
|
|
|
</div>
|
|
|
|
<script>
|
|
document.addEventListener("DOMContentLoaded", function () {
|
|
|
|
// driver 기본값 세팅
|
|
<?php if ($_SESSION['ss_LEVEL'] == 9) { ?>
|
|
const driver = document.getElementById("driver");
|
|
if (driver) {
|
|
driver.value = "<?= $_SESSION['ss_UID'] ?>";
|
|
driver.dispatchEvent(new Event('change'));
|
|
}
|
|
<?php } ?>
|
|
|
|
// 이미지 preview
|
|
const input = document.getElementById("uploadFileInput");
|
|
const previewList = document.getElementById("previewList");
|
|
|
|
if (input) {
|
|
input.addEventListener("change", function () {
|
|
previewList.innerHTML = "";
|
|
|
|
Array.from(this.files).forEach(file => {
|
|
if (!file.type.startsWith("image/")) return;
|
|
|
|
const reader = new FileReader();
|
|
reader.onload = function () {
|
|
const img = document.createElement("img");
|
|
img.src = reader.result;
|
|
img.style.width = "90px";
|
|
img.style.height = "70px";
|
|
img.style.objectFit = "cover";
|
|
img.style.border = "1px solid #ccc";
|
|
img.style.borderRadius = "6px";
|
|
previewList.appendChild(img);
|
|
};
|
|
reader.readAsDataURL(file);
|
|
});
|
|
});
|
|
}
|
|
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|
|
|
|
|
|
<style>
|
|
body {
|
|
background: #f5f7fb;
|
|
font-family: Arial, Helvetica, sans-serif;
|
|
padding: 40px;
|
|
}
|
|
|
|
.upload-box {
|
|
width: 450px;
|
|
margin: 0 auto;
|
|
background: #fff;
|
|
border-radius: 12px;
|
|
box-shadow: 0 6px 18px rgba(0,0,0,0.1);
|
|
padding: 25px 30px;
|
|
}
|
|
|
|
.title-row {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
font-size: 17px;
|
|
font-weight: bold;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
.clear-btn {
|
|
background: #ccc;
|
|
border: none;
|
|
padding: 4px 12px;
|
|
border-radius: 6px;
|
|
cursor: pointer;
|
|
font-size: 13px;
|
|
color: #333;
|
|
}
|
|
|
|
.tb-info label {
|
|
display: block;
|
|
font-size: 14px;
|
|
margin-top: 12px;
|
|
font-weight: bold;
|
|
}
|
|
|
|
.tb-info select,
|
|
.tb-info input[type=file],
|
|
.tb-info textarea {
|
|
width: 100%;
|
|
box-sizing: border-box;
|
|
padding: 8px;
|
|
border: 1px solid #ccc;
|
|
border-radius: 6px;
|
|
margin-top: 6px;
|
|
font-size: 14px;
|
|
display: block;
|
|
}
|
|
|
|
.preview-img {
|
|
margin-top: 12px;
|
|
width: 200px;
|
|
border: 1px solid #ccc;
|
|
border-radius: 6px;
|
|
display: none;
|
|
}
|
|
|
|
.btn-save {
|
|
background: #76c06b;
|
|
color: #fff;
|
|
width: 100%;
|
|
padding: 14px 0;
|
|
margin-top: 18px;
|
|
border: none;
|
|
border-radius: 8px;
|
|
font-size: 16px;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.btn-save:hover {
|
|
background: #2A9B56;
|
|
}
|
|
|
|
.btn-close {
|
|
width: 100%;
|
|
margin-top: 10px;
|
|
padding: 12px 0;
|
|
background: #8e8e8e;
|
|
color: #fff;
|
|
border: none;
|
|
border-radius: 8px;
|
|
font-size: 15px;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.btn-close:hover {
|
|
background: #7a7a7a ;
|
|
}
|
|
|
|
</style>
|