Files
sam-kd/bid/fetch_modal.php
hskwon aca1767eb9 초기 커밋: 5130 레거시 시스템
- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경
- DB 연결 하드코딩 → .env 기반으로 변경
- MySQL strict mode DATE 오류 수정
2025-12-10 20:14:31 +09:00

290 lines
14 KiB
PHP

<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
$mode = $_POST['mode'] ?? '';
$num = $_POST['num'] ?? '';
$tablename = 'bid';
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
$pdo = db_connect();
$title_message = ($mode === 'modify') ? '현설 정보 수정' : (($mode === 'copy') ? '현설 정보 복사' : '현설 정보 신규 등록');
if ($mode === 'modify' && $num) {
try {
$sql = "SELECT * FROM ". $DB . "." . $tablename . " WHERE num=?";
$stmh = $pdo->prepare($sql);
$stmh->bindValue(1, $num, PDO::PARAM_INT);
$stmh->execute();
$row = $stmh->fetch(PDO::FETCH_ASSOC);
include '_row.php';
} catch (PDOException $Exception) {
echo "오류: ".$Exception->getMessage();
exit;
}
}
else if ($mode === 'copy' && $num) {
try {
$sql = "SELECT * FROM ". $DB . "." . $tablename . " WHERE num=?";
$stmh = $pdo->prepare($sql);
$stmh->bindValue(1, $num, PDO::PARAM_INT);
$stmh->execute();
$row = $stmh->fetch(PDO::FETCH_ASSOC);
include '_row.php';
$mode = 'copy';
$num = null;
} catch (PDOException $Exception) {
echo "오류: ".$Exception->getMessage();
exit;
}
}
else {
include '_request.php';
$mode = 'insert';
$registedate = date('Y-m-d');
}
?>
<input type="hidden" id="update_log" name="update_log" value="<?=$update_log?>">
<input type="hidden" id="totalitem" name="totalitem" value="<?=$totalitem?>">
<input type="hidden" name="participantJson" value="<?= htmlspecialchars($participantJson, ENT_QUOTES, 'UTF-8') ?>">
<div class="d-flex align-items-center justify-content-center m-2">
<span class="text-center fs-5 mx-3"><?=$title_message?></span>
<button type="button" data-num="<?=$num?>" class="btn btn-outline-dark btn-sm me-5" id="showlogBtn" >
Log 기록
</button>
</div>
<div class="row">
<div class="col-sm-6">
<div class="table-responsive">
<table class="table table-bordered table-sm" id="listTable" >
<tbody>
<tr>
<td class="text-center fw-bold w90px">등록일</td>
<td class="text-center" colspan="1">
<input type="date" class="form-control noborder-input w120px" id="registedate" autocomplete="off" name="registedate" style="width:130px;" value="<?=$registedate?>">
</td>
<td class="text-center text-primary fw-bold w90px">시공사</td>
<td class="text-center">
<div class="d-flex align-items-center justify-content-center">
<input type="text" id="secondord" name="secondord" value="<?=$secondord?>" class="form-control noborder-input text-start w-80" autocomplete="off" onkeydown="if(event.keyCode == 13) { phonebookBtn('secondord'); }"> &nbsp;
<input type="text" class="form-control w50px mx-1" id="secondordnum" placeholder="코드" autocomplete="off" name="secondordnum" value="<?=$secondordnum?>">
<button type="button" id="searchsecondord" class="btn btn-primary searchsecondord btn-sm" onclick="phonebookBtn('secondord');" > <i class="bi bi-search"></i> </button>
</div>
</td>
</tr>
<tr>
<td class="text-center fw-bold">현장명</td>
<td class="text-center" colspan="3">
<input type="text" class="form-control noborder-input" id="workplacename" autocomplete="off" name="workplacename" value="<?=$workplacename?>">
</td>
</tr>
<tr>
<td class="text-center fw-bold">주소</td>
<td class="text-center" colspan="3">
<input type="text" class="form-control noborder-input" id="address" autocomplete="off" name="address" value="<?=$address?>">
</td>
</tr>
<tr>
<td class="text-center fw-bold">시공사 담당</td>
<td class="text-center">
<input type="text" class="form-control noborder-input" id="receiver" autocomplete="off" name="receiver" value="<?=$receiver?>">
</td>
<td class="text-center fw-bold">연락처</td>
<td class="text-center">
<input type="text" class="form-control noborder-input" id="receiver_tel" autocomplete="off" name="receiver_tel" value="<?=$receiver_tel?>">
</td>
</tr>
<tr>
<td class="text-center text-success ">견적 산출 </td>
<td class="text-center" colspan="3">
<input type="text" class="form-control noborder-input text-success w200px" id="estimatedbyPerson" autocomplete="off" name="estimatedbyPerson" value="<?=$estimatedbyPerson?>">
</td>
</tr>
<tr>
<td class="text-center fw-bold">현설일</td>
<td class="text-center">
<input type="date" class="form-control noborder-input w120px" id="siteDate" autocomplete="off" name="siteDate" value="<?=$siteDate?>">
</td>
<td class="text-center fw-bold">현설참석자</td>
<td class="text-center">
<input type="text" class="form-control noborder-input" id="siteAttendance" autocomplete="off" name="siteAttendance" value="<?=$siteAttendance?>">
</td>
</tr>
<tr>
<td class="text-center fw-bold">진행상태</td>
<td class="text-center">
<select id="siteStatus" name="siteStatus" class="form-select w120px" style="font-size: 0.8rem; height: 32px;">
<?php
$options = ['(선택)', '현설', '투찰','확정'];
foreach ($options as $option):
?>
<option value="<?= $option ?>" <?= ($siteStatus === $option) ? 'selected' : '' ?>>
<?= $option ?>
</option>
<?php endforeach; ?>
</select>
</td>
<td class="text-center fw-bold">입찰금액<br>(간접비 포함)<br>공급가액 </td>
<td class="text-center" colspan="3">
<input type="text" class="form-control noborder-input w100px text-end" autocomplete="off"
id="fee" name="fee"
value="<?= number_format((int)str_replace(',', '', $fee)) ?>"
oninput="inputNumberFormat(this)">
</td>
</tr>
<tr>
<td class="text-center fw-bold">입찰일자</td>
<td class="text-center">
<input type="date" class="form-control noborder-input w120px" autocomplete="off" id="bidDate" name="bidDate" autocomplete="off" value="<?=$bidDate?>">
</td>
<td class="text-center fw-bold">결과</td>
<td class="text-center">
<select id="siteresult" name="siteresult" class="form-select w120px" autocomplete="off" style="font-size: 0.8rem; height: 32px;">
<?php
$options = ['(선택)','탈락', '낙찰', '유찰'];
foreach ($options as $option):
?>
<option value="<?= $option ?>" <?= ($siteresult === $option) ? 'selected' : '' ?>>
<?= $option ?>
</option>
<?php endforeach; ?>
</select>
</td>
</tr>
<tr>
<td class="text-center fw-bold">비고</td>
<td class="text-center" colspan="3">
<textarea class="form-control text-start textareaClass" id="memo" name="memo"><?=$memo?></textarea>
</td>
</tr>
</tbody>
</table>
</div>
<!-- 비고란 밑에 현설 참여업체 및 메모 기능 동적구현: 동적 행 추가/삭제 (table-responsive) -->
<div class="table-responsive">
<table class="table table-bordered table-sm align-middle mb-2" id="participantTable">
<thead>
<tr>
<th class="text-center" style="width: 15%;">+/-</th>
<th class="text-center" style="width: 85%;">현설 참여업체 및 메모</th>
</tr>
</thead>
<tbody>
<tr>
<td class="text-center">
<button type="button" class="btn btn-outline-dark btn-sm addRowBtn"> + </button>
<button type="button" class="btn btn-outline-dark btn-sm deleteRowBtn"> - </button>
</td>
<td>
<input type="text" class="form-control text-start" name="participant[]" placeholder="현설 참여업체 및 메모" autocomplete="off">
</td>
</tr>
</tbody>
</table>
</div>
</div> <!-- end of col-sm-6 -->
<div class="col-sm-6">
<div class="table-responsive">
<?php
// JSON을 PHP 배열로 변환
$quantityData = json_decode($quantityJson, true);
if (!is_array($quantityData)) {
$quantityData = []; // JSON 파싱 오류 방지
}
$items = [
'스크린방화셔터 | 8,000*4,000 이하(품질인정제품)',
'스크린방화셔터 | 8,000*4,000 초과(품질인정제품)',
'스크린방화셔터 | 현장명 시험',
'철재방화셔터 | 8,000*4,000 이하(품질인정제품)',
'철재방화셔터 | 8,000*4,000 초과(품질인정제품)',
'철재방화셔터 | 현장명 시험',
'무지주셔터(와이어,지퍼) | 8,000*4,000 이하(품질인정제품)',
'무지주셔터(와이어,지퍼) | 8,000*4,000 초과(품질인정제품)',
'무지주셔터(와이어,지퍼) | 현장명 시험',
'2시간 단열,차열셔터 | 8,000*4,000 이하(품질인정제품)',
'2시간 단열,차열셔터 | 8,000*4,000 초과(품질인정제품)',
'2시간 단열,차열셔터 | 현장명 시험',
'제연커튼',
'기타 셔터',
'외주',
];
// 5번 방법셔터 -> 대형 스크린방화(품질인정제품) 대체
// 6번 AL셔터 => 2시간 단열 or 차열셔터 (품질인정제품) 대체
// 데이터베이스에 저장된 아이템 중 $items에 없는 것들을 찾기
$savedItems = [];
if (is_array($quantityData)) {
foreach ($quantityData as $data) {
if (isset($data['item']) && !in_array($data['item'], $items)) {
$savedItems[] = $data['item'];
}
}
}
// 중복 제거
$savedItems = array_unique($savedItems);
// 모든 아이템을 합치기 (기본 아이템 + 저장된 추가 아이템)
$allItems = array_merge($items, $savedItems);
?>
<div class="table-responsive">
<table class="table table-bordered table-sm table-hover" id="itemTable">
<thead class="table-primary text-center">
<tr>
<th style="width: 65%;">아이템 종류</th>
<th style="width: 10%;">수량</th>
<th style="width: 25%;">비고</th>
</tr>
</thead>
<tbody>
<?php foreach ($allItems as $index => $item):
// 해당 아이템의 수량 찾기
$matchedItem = array_filter($quantityData, function ($q) use ($item) {
return isset($q['item']) && $q['item'] === $item;
});
// echo "<pre>";
// print_r($note);
// echo "</pre>";
// 수량이 존재하면 가져오고, 없으면 빈 값 (0이면 공백)
$quantityValue = !empty($matchedItem) ? reset($matchedItem)['quantity'] : "";
$quantityValue = ($quantityValue === "0") ? "" : $quantityValue;
// 비고가 존재하면 가져오고, 없으면 빈 값
$noteValue = !empty($matchedItem) ? reset($matchedItem)['note'] : "";
$noteValue = ($noteValue === "0") ? "" : $noteValue;
?>
<tr>
<td class="text-start quantityArray">
<input type="text" class="form-control text-start" name="item[]" autocomplete="off" value="<?= htmlspecialchars($item, ENT_QUOTES, 'UTF-8') ?>">
</td>
<td class="text-center ">
<input type="text" class="form-control text-center" name="quantity[]" autocomplete="off" value="<?= htmlspecialchars($quantityValue, ENT_QUOTES, 'UTF-8') ?>">
</td>
<td class="text-start ">
<input type="text" class="form-control text-start" name="note[]" autocomplete="off" value="<?= htmlspecialchars($noteValue, ENT_QUOTES, 'UTF-8') ?>">
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>