Files
sam-kd/output/view_requestACI.php

982 lines
42 KiB
PHP
Raw Normal View History

<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/instock/commonRequest.php'; // 구글드라이브 세션 파일 포함
$title_message = '자동방화셔터(인정제품) 제품검사요청서';
$tablename = 'output';
$item ='자동방화셔터(인정제품)제품검사요청서';
$emailTitle ='자동방화셔터(인정제품)제품검사요청서';
include $_SERVER['DOCUMENT_ROOT'] . '/load_header.php';
?>
<title> <?=$title_message?> </title>
<link rel="stylesheet" href="css/style.css">
<style>
textarea.noborder-input {
resize: none; /* 기본 리사이즈 비활성화 */
overflow: hidden; /* 스크롤 바 숨김 */
min-height: 40px; /* 최소 높이 설정 */
}
</style>
</head>
<body>
<?php
// JavaScript에서 전달된 변수들 받기
$num = isset($_REQUEST['num']) ? $_REQUEST['num'] : '';
$lotNum = isset($_REQUEST['lotNum']) ? $_REQUEST['lotNum'] : '';
$outdate = isset($_REQUEST['outdate']) ? $_REQUEST['outdate'] : ''; // 출고일
// 출고일이 존재할 경우에만 다음날 계산
if ($outdate) {
// 출고일을 DateTime 객체로 변환
$date = new DateTime($outdate);
// 1일 더하기
$date->modify('+1 day');
// 형식화된 날짜 (예: Y-m-d 형식)로 출력
$outdateplusone = $date->format('Y-m-d');
} else {
// 출고일이 없을 경우 기본값
$outdateplusone = '';
}
$orderdate = isset($_REQUEST['orderdate']) ? $_REQUEST['orderdate'] : ''; // 발주일
$prodCode = isset($_REQUEST['prodCode']) ? $_REQUEST['prodCode'] : ''; // prodCode 받기
$warrantyNum = isset($_REQUEST['warrantyNum']) ? $_REQUEST['warrantyNum'] : ''; // warrantyNum 받기
// 추가된 변수 받기
$delivery = isset($_REQUEST['delivery']) ? $_REQUEST['delivery'] : ''; // 배송 옵션 받기
$outworkplace = isset($_REQUEST['outworkplace']) ? $_REQUEST['outworkplace'] : ''; // 출고 작업장 받기
$outputplace = isset($_REQUEST['outputplace']) ? $_REQUEST['outputplace'] : ''; // 배송 주소지
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
require_once($_SERVER['DOCUMENT_ROOT'] . "/estimate/fetch_unitprice.php");
$pdo = db_connect();
try {
$sql = "select * from {$DB}.{$tablename} where num = ? ";
$stmh = $pdo->prepare($sql);
$stmh->bindValue(1, $num, PDO::PARAM_STR);
$stmh->execute();
$count = $stmh->rowCount();
if ($count < 1) {
print "검색결과가 없습니다.<br>";
} else {
$row = $stmh->fetch(PDO::FETCH_ASSOC);
include "_row.php";
// output_extra 테이블에서 데이터 불러오기
require_once $_SERVER['DOCUMENT_ROOT'] . '/output/load_output_extraTable.php';
}
} catch (PDOException $Exception) {
print "오류: " . $Exception->getMessage();
}
// 전체수량 합산
$shutterSurang = 0; // 셔터 수량 합계를 저장할 변수 초기화
$shutterSurang_slat = 0; // 철재
$lotVolumn = 0;
// 길이, 높이
$screen_width = [];
$screen_height = [];
$slat_width = [];
$slat_height = [];
// JSON 데이터를 배열로 디코딩
$eList_screenData = json_decode($eList_screen, true);
$eList_slatData = json_decode($eList_slat, true);
// 초기화
$eList = [];
if (is_array($eList_screenData) && !empty($eList_screenData)) {
foreach ($eList_screenData as $item) {
$shutterSurang += isset($item['col14']) ? (int)$item['col14'] : 0;
$screen_width[] = isset($item['col8']) ? intval($item['col8']) : 0;
$screen_height[] = isset($item['col9']) ? intval($item['col9']) : 0;
}
$screenorslat = '스크린';
$eList = $eList_screenData; // eList 설정
if ($shutterSurang > 0) {
$lotVolumn = $shutterSurang;
}
}
if (is_array($eList_slatData) && !empty($eList_slatData)) {
foreach ($eList_slatData as $item) {
$shutterSurang_slat += isset($item['col15']) ? (int)$item['col15'] : 0;
$slat_width[] = isset($item['col8']) ? intval($item['col8']) : 0;
$slat_height[] = isset($item['col9']) ? intval($item['col9']) : 0;
}
$screenorslat = '철재';
$eList = $eList_slatData; // eList 설정
if ($shutterSurang_slat > 0) {
$lotVolumn = $shutterSurang_slat;
}
}
// echo '<pre>';
// print_r($eList);
// echo '</pre>';
// echo '<pre>';
// print_r($lotVolumn);
// echo '</pre>';
// 각 배열 요소가 모두 빈 문자열인지 확인하는 함수
function isEmptyData($dataArray) {
if (!is_array($dataArray)) {
return true;
}
foreach ($dataArray as $item) {
// 객체 형태로 저장된 경우 (연관 배열)
if (is_array($item) && isset($item['value'])) {
if (trim($item['value']) !== '') {
return false; // 하나라도 빈값이 아니면 false
}
} else {
// 만약 단순 값이라면
if (trim($item) !== '') {
return false;
}
}
}
return true;
}
$jsonFilePath = "../output/real_json/" . $num . ".json";
if (file_exists($jsonFilePath)) {
$data = file_get_contents($jsonFilePath);
$realiList = json_decode($data, true);
// 검사할 필드 목록 (저장할 때 사용한 모든 키)
$fields = [
'inputValue',
'beforeWidth',
'beforeHeight',
'afterWidth',
'afterHeight',
'recordComent',
'exceptCheck'
];
$allEmpty = true;
foreach ($fields as $field) {
// 해당 필드가 존재하고, 값이 비어있지 않다면 전체가 빈 상태가 아님.
if (isset($realiList[$field]) && !isEmptyData($realiList[$field])) {
$allEmpty = false;
break;
}
}
// 모든 지정된 필드가 비어있다면 기본값으로 설정
if ($allEmpty) {
$realiList = '{}';
}
} else {
$realiList = '{}'; // 파일이 없으면 기본값 사용
}
echo "<script>";
echo "var realiList = " . json_encode($realiList) . ";"; // 전역 변수 realiList에 할당
echo "var realiListData;"; // realiListData 변수만 선언
echo "$(document).ready(function() {";
echo " realiListData = realiList; console.log('초기로드 데이터 상태:', realiListData);";
echo "});";
echo "</script>";
$prodName = ""; // 상품명을 저장할 변수
// if문을 사용하여 제품 코드에 따른 상품명 설정
if ($prodCode == 'KSS01') {
$prodName = '국민방화 스크린 셔터';
$arrayWidth = $screen_width[$page-1] ;
$arrayHeight = $screen_height[$page-1] ;
} elseif ($prodCode == 'KSE01') {
$prodName = '국민방화 스크린 셔터';
$arrayWidth = $screen_width[$page-1] ;
$arrayHeight = $screen_height[$page-1] ;
} elseif ($prodCode == 'KWE01') {
$prodName = '국민방화 스크린 플러스 셔터';
$arrayWidth = $screen_width[$page-1] ;
$arrayHeight = $screen_height[$page-1] ;
} elseif ($prodCode == 'KD-SL60') {
$prodName = '국민방화 스틸 셔터';
$arrayWidth = $slat_width[$page-1] ;
$arrayHeight = $slat_height[$page-1] ;
} elseif ($prodCode == 'KTE01') {
$prodName = '국민방화 스틸 셔터';
$arrayWidth = $slat_width[$page-1] ;
$arrayHeight = $slat_height[$page-1] ;
} elseif ($prodCode == 'KQTS01') {
$prodName = '국민방화 투시형 스틸 셔터';
$arrayWidth = $slat_width[$page-1] ;
$arrayHeight = $slat_height[$page-1] ;
} else {
$prodName = "유효하지 않은 제품 코드입니다.";
}
$pageWidth = $arrayWidth;
$pageHeight = $arrayHeight;
// 품질담당자 및 관리자인 경우 권한 부여
$QCadmin = false ;
if($user_name=='이세희' || $user_name=='개발자' || $user_name=='함신옥' || $user_name=='노완호' )
$QCadmin = true ;
?>
<div class="container mt-2">
<div class="d-flex align-items-center justify-content-end mt-1 m-1">
<button type="button" class="btn btn-dark btn-sm ms-1" onclick='location.reload();' > <i class="bi bi-arrow-clockwise"></i> </button>
<button type="button" class="btn btn-dark btn-sm me-1 ms-1 saveData" > <i class="bi bi-floppy2-fill"></i> 서버 저장 </button>
<button type="button" class="btn btn-danger btn-sm me-1 ms-1 initialBtn" > <i class="bi bi-arrow-counterclockwise"></i> 초기화 </button>
<button type="button" class="btn btn-dark btn-sm ms-1 me-1 loadACIBtn" > <i class="bi bi-window"></i> 인정검사서 보기 </button>
<button type="button" class="btn btn-dark btn-sm ms-1 me-1" onclick="generatePDF()"> PDF 저장 </button>
<button type="button" class="btn btn-secondary btn-sm ms-1 " onclick="self.close();"> <i class="bi bi-x-lg"></i> 닫기 </button>
</div>
</div>
<form id="board_form" name="board_form" method="post" enctype="multipart/form-data" onkeydown="return captureReturnKey(event)" >
<input type="hidden" id="id" name="id" value="<?= isset($num) ? $num : '' ?>" >
<input type="hidden" id="item" name="item" value="<?= isset($item) ? $item : '' ?>" >
<input type="hidden" id="page" name="page" value="<?= isset($page) ? $page : 1 ?>" >
<input type="hidden" id="tablename" name="tablename" value="<?= isset($tablename) ? $tablename : '' ?>" >
<input type="hidden" id="prodcode" name="prodcode" value="<?= isset($prodcode) ? $prodcode : '' ?>" >
<input type="hidden" id="drivetablename" name="drivetablename" value="<?= isset($drivetablename) ? $drivetablename : $tablename ?>" >
<input type="hidden" id="savetitle" name="savetitle" value="<?= isset($savetitle) ? $savetitle : '' ?>" >
<input type="hidden" id="mode" name="mode" value="<?= isset($mode) ? $mode : '' ?>" >
<input type="hidden" id="timekey" name="timekey" value="<?= isset($timekey) ? $timekey : '' ?>" >
<input type="hidden" id="num" name="num" value="<?= isset($num) ? $num : '' ?>">
<input type="hidden" id="user_name" name="user_name" value="<?= isset($user_name) ? $user_name : '' ?>">
<input type="hidden" id="update_log" name="update_log" value="<?= isset($update_log) ? $update_log : NULL ?>">
<input type="hidden" id="item_name" name="item_name" value="<?= isset($item_name) ? $item_name : '' ?>">
<input type="hidden" id="screenorslat" name="screenorslat" value="<?= isset($screenorslat) ? $screenorslat : '' ?>">
<input type="hidden" id="ACIdoneDate" name="ACIdoneDate" value="<?= isset($ACIdoneDate) ? $ACIdoneDate : null ?>">
<input type="hidden" id="realiList" name="realiList" >
<!-- 수신처 모달 Modal -->
<div class="container-fluid justify-content-center align-items-center">
<div id="telModal" class="modal fade" tabindex="-1">
<div class="modal-dialog modal-full" style="width:1180px;" role="document">
<div class="modal-content">
<div class="modal-header">
<h2 class="modal-title">수신처 조회</h2>
<button type="button" class="btn btn-outline-dark Modalclose" data-dismiss="modal">
<i class="bi bi-x-lg"></i>
</button>
</div>
<div class="modal-body">
<table class="table table-hover">
<thead class="table-primary">
<tr>
<th class="text-center" style="width:5%;">번호</th>
<th class="text-center" style="width:15%;">유통업자 회사명</th>
<th class="text-center" style="width:15%;">성명</th>
<th class="text-center" style="width:45%;">회사주소</th>
<th class="text-center" style="width:15%;">전화번호</th>
</tr>
</thead>
<tbody id="ModalBody">
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-dark btn-sm Modalclose" data-dismiss="modal">
<i class="bi bi-x-lg"></i> 닫기
</button>
</div>
</div>
</div>
</div>
</div>
<div id="content-to-print">
<br>
<div class="container mt-2 mb-5">
<div class="row">
<div class="d-flex align-items-center justify-content-center">
<table class="table" style="border-collapse: collapse;">
<tbody>
<tr>
<th colspan="6" rowspan="2" class="text-center" >
<div class="row align-items-center">
<div class="col-sm-2">
<img src="../img/kdlogo.png" alt="경동기업" class="me-1" style="width:60%; height:auto;">
</div>
<div class="col-sm-10">
<div class="d-flex align-items-center justify-content-center m-1">
<span class="text-dark ms-2 me-2 fs-3">자동방화셔터(인정제품) 제품검사요청서</span>
</div>
</div>
</div>
</th>
<th colspan="1" rowspan="2" class="text-center" style="border: 0!important;">
<div class="d-flex align-items-center justify-content-center m-1">
<span class="text-dark ms-2 me-2">접수일</span>
</div>
<div class="d-flex align-items-center justify-content-center m-1" style="border: 0;">
<input type="date" class="form-control text-center inputValue noborder-input" id="ACIregDate" name="ACIregDate" value="<?= isset($ACIregDate) && $ACIregDate !== '0000-00-00' ? $ACIregDate : ''?>">
</div>
</th>
</tr>
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="d-flex align-items-center justify-content-start">
<table class="table " style="border-collapse: collapse;">
<thead>
<tr>
<th colspan="4" class="text-center align-middle blueBlackBold fs-5">기본정보</th>
</tr>
<tr>
<th class="text-center align-middle lightgray">발주처(업체명)</th>
<th class="text-center" style="width:500px;">
<input type="text" class="form-control text-center text-primary inputValue noborder-input" id="secondord" name="secondord" value="<?=$secondord?>">
</th>
<th class="text-center align-middle lightgray">담당자</th>
<th colspan="1" class="text-center">
<input type="text" class="form-control text-center text-primary inputValue noborder-input" id="receiver" name="receiver" value="<?=$receiver?>">
</th>
</tr>
<tr>
<th class="text-center align-middle lightgray">발주번호</th>
<th class="text-center">
<input type="text" class="form-control text-center text-primary inputValue noborder-input" id="lotNum" name="lotNum" value="<?=$lotNum?>">
</th>
<th class="text-center align-middle lightgray">담당자 연락처</th>
<th class="text-center">
<input type="text" class="form-control text-center text-primary inputValue noborder-input" id="hp" name="hp" value="<?=$_SESSION['hp']?>">
</th>
</tr>
<tr>
<th class="text-center align-middle lightgray">현장명</th>
<th colspan="1" class="text-center">
<input type="text" class="form-control text-center text-primary inputValue noborder-input" id="outworkplace" name="outworkplace" value="<?=$outworkplace?>">
</th>
<th class="text-center align-middle lightgray">납품일</th>
<th colspan="1" class="text-center">
<div class="row d-flex justify-content-center align-items-center">
<input type="date" class="form-control text-center text-primary inputValue noborder-input " id="outdate" name="outdate" value="<?=$outdate?>">
</div>
</th>
</tr>
<tr>
<th class="text-center align-middle lightgray">현장주소</th>
<th colspan="1" class="text-center">
<div class="d-flex justify-content-center align-items-center">
<input type="text" class="form-control text-center text-primary inputValue noborder-input" id="outputplace" name="outputplace" value="<?=$outputplace?>">
</div>
</th>
<th class="text-center align-middle lightgray">셔터총수량</th>
<th class="text-center">
<div class="d-flex justify-content-center text-center align-items-center w130px">
<input type="text" class="form-control text-primary text-end inputValue noborder-input me-1 " id="lotVolumn" name="lotVolumn" value="<?=$lotVolumn?>"> (개소)
</div>
</th>
</tr>
</thead>
</table>
</div>
</div>
<div class="row">
<div class="d-flex align-items-center justify-content-start">
<table class="table" style="border-collapse: collapse;">
<thead>
<tr>
<th colspan="2" class="text-center align-middle orangeBlueBold w200px" style="width:100px;">검사방문요청일(전화예정)</th>
<th colspan="5" class="text-start align-middle orangeBlueBold w490px">
<input type="date" class="form-control text-primary inputValue noborder-input w100px" id="ACIaskDate" name="ACIaskDate" value="<?=$ACIaskDate?>">
</th>
</tr>
</thead>
</table>
</div>
</div>
<div class="row mt-2">
<div class="d-flex align-items-center justify-content-center">
<table class="table table-bordered" style="border-collapse: collapse;">
<tbody>
<tr>
<td colspan="5" class="text-center align-middle blueRedBold fs-5" style="padding: 0;">*필수 입력사항*</td>
</tr>
<tr>
<td rowspan="2" class="text-center lightgray align-middle w100px">건축공사장 </td>
<td class="text-center morelightgray w60px">현장</td>
<td colspan="3" class="text-center align-middle">
<input type="text" class="form-control text-center inputValue noborder-input" id="outworkplace_detail" name="outworkplace_detail" value="<?=$outworkplace?>">
</td>
</tr>
<tr>
<td class="text-center morelightgray w80px">대지위치</td>
<td colspan="1" class="text-center align-middle" style="width:300px;">
<textarea class="form-control text-center inputValue noborder-input" id="outputplace_detail" name="outputplace_detail" ><?=$outputplace?></textarea>
</td>
<td class="text-center morelightgray w80px">지번</td>
<td colspan="1" class="text-center align-middle">
<input type="text" class="form-control text-center inputValue noborder-input" id="landNumber" name="landNumber" value="<?=isset($landNumber) ? $landNumber : ''?>">
</td>
</tr>
<tr>
<td rowspan="2" class="text-center lightgray align-middle w100px">
<span class="text-priamry fw-bold loadDistributorBtn ms-1 me-1" style="cursor:pointer;"> 자재유통업자 <br> <i class="bi bi-journal-plus"></i> </span>
</td>
<td class="text-center morelightgray ">성명</td>
<td colspan="1" class="text-center align-middle">
<input type="text" class="form-control text-center inputValue noborder-input" id="distributor_name" name="distributor_name" value="<?=isset($distributor_name) ? $distributor_name : ''?>">
</td>
<td class="text-center morelightgray w80px">회사명</td>
<td colspan="1" class="text-center align-middle">
<input type="text" class="form-control text-center inputValue noborder-input" id="distributor_corp" name="distributor_corp" value="<?=isset($distributor_corp) ? $distributor_corp : ''?>">
</td>
</tr>
<tr>
<td class="text-center morelightgray w80px">회사주소</td>
<td colspan="1" class="text-center align-middle">
<textarea class="form-control text-center inputValue noborder-input" id="distributor_addr" name="distributor_addr" ><?=$distributor_addr?></textarea>
</td>
<td class="text-center morelightgray w80px">전화번호</td>
<td colspan="1" class="text-center align-middle">
<input type="text" class="form-control text-center inputValue noborder-input" id="distributor_tel" name="distributor_tel" value="<?=isset($distributor_tel) ? $distributor_tel : ''?>">
</td>
</tr>
<tr>
<td rowspan="2" class="text-center lightgray align-middle w100px">
<span class="text-priamry fw-bold loadCEBtn ms-1 me-1" style="cursor:pointer;"> 공사시공자 <br> <i class="bi bi-journal-plus"></i>
<span class="text-danger fw-bold"> (건설사) </span>
</span>
</td>
<td class="text-center morelightgray ">성명</td>
<td colspan="1" class="text-center align-middle">
<input type="text" class="form-control text-center inputValue noborder-input" id="civilEngineer_name" name="civilEngineer_name" value="<?=isset($civilEngineer_name) ? $civilEngineer_name : ''?>">
</td>
<td class="text-center morelightgray w80px">회사명</td>
<td colspan="1" class="text-center align-middle">
<input type="text" class="form-control text-center inputValue noborder-input" id="civilEngineer_corp" name="civilEngineer_corp" value="<?=isset($civilEngineer_corp) ? $civilEngineer_corp : ''?>">
</td>
</tr>
<tr>
<td class="text-center morelightgray w80px">회사주소</td>
<td colspan="1" class="text-center align-middle">
<textarea class="form-control text-center inputValue noborder-input" id="civilEngineer_addr" name="civilEngineer_addr" ><?=$civilEngineer_addr?></textarea>
</td>
<td class="text-center morelightgray w80px">전화번호</td>
<td colspan="1" class="text-center align-middle">
<input type="text" class="form-control text-center inputValue noborder-input" id="civilEngineer_tel" name="civilEngineer_tel" value="<?=isset($civilEngineer_tel) ? $civilEngineer_tel : ''?>">
</td>
</tr>
<tr>
<td rowspan="2" class="text-center lightgray align-middle w100px">
<span class="text-priamry fw-bold loadSUBtn ms-1 me-1" style="cursor:pointer;"> 공사감리자 <br> <i class="bi bi-journal-plus"></i> </span>
</td>
<td class="text-center morelightgray ">성명</td>
<td colspan="1" class="text-center align-middle">
<input type="text" class="form-control text-center inputValue noborder-input" id="supervisor_name" name="supervisor_name" value="<?=isset($supervisor_name) ? $supervisor_name : ''?>">
</td>
<td class="text-center morelightgray w80px">회사명</td>
<td colspan="1" class="text-center align-middle">
<input type="text" class="form-control text-center inputValue noborder-input" id="supervisor_corp" name="supervisor_corp" value="<?=isset($supervisor_corp) ? $supervisor_corp : ''?>">
</td>
</tr>
<tr>
<td class="text-center morelightgray w80px">회사주소</td>
<td colspan="1" class="text-center align-middle">
<textarea class="form-control text-center inputValue noborder-input" id="supervisor_addr" name="supervisor_addr" ><?=$supervisor_addr?></textarea>
</td>
<td class="text-center morelightgray w80px">전화번호</td>
<td colspan="1" class="text-center align-middle">
<input type="text" class="form-control text-center inputValue noborder-input" id="supervisor_tel" name="supervisor_tel" value="<?=isset($supervisor_tel) ? $supervisor_tel : ''?>">
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="row mt-2">
<div class="d-flex align-items-center justify-content-center">
<table class="table table-bordered" style="border-collapse: collapse;">
<thead>
<tr>
<th colspan="9" class="text-center align-middle blueBlackBold fs-5" style="padding 0;" > 검사대상 사전 고지 정보 </th>
</tr>
<tr>
<th rowspan="3" class="text-center align-middle w50px"> 일련<br>번호 </th>
<th rowspan="3" class="text-center align-middle w50px"> 층수 </th>
<th rowspan="3" class="text-center align-middle w100px"> 부호 </th>
<th colspan="5" class="text-center align-middle fs-6 w200px"> 오픈사이즈 </th>
<th rowspan="3" class="text-center align-middle w250px"> 변경사유 </th>
</tr>
<tr>
<th colspan="2" class="text-center align-middle morelightgray "> 발주규격 </th>
<th colspan="2" class="text-center align-middle morelightgray "> 시공후규격 </th>
<th rowspan="3" class="text-center align-middle w30px"> <br> </th>
</tr>
<tr>
<th class="text-center align-middle morelightgray "> 가로 </th>
<th class="text-center align-middle morelightgray "> 세로 </th>
<th class="text-center align-middle morelightgray "> 가로 </th>
<th class="text-center align-middle morelightgray "> 세로 </th>
</tr>
</thead>
<tbody>
<?php
$row_count = 0;
foreach ($eList as $row) {
echo '<tr>';
for ($i = 1; $i <= 13; $i++) {
switch ($i) {
case 1:
echo '<td class="text-center"><input type="text" class="form-control text-center inputValue noborder-input" id="col1_' . $row_count . '" name="col1_' . $row_count . '" readonly value="' . $row['col1'] . '"></td>';
break;
case 2:
echo '<td class="text-center"><input type="text" class="form-control text-center inputValue noborder-input" id="col2_' . $row_count . '" name="col2_' . $row_count . '" value="' . $row['col2'] . '"></td>';
break;
case 3:
echo '<td class="text-center"><input type="text" class="form-control text-center inputValue noborder-input" id="col3_' . $row_count . '" name="col3_' . $row_count . '" value="' . $row['col3'] . '"></td>';
break;
case 4:
echo '<td class="text-center"><input type="text" class="form-control text-center beforeWidth noborder-input" id="col8_' . $row_count . '" name="col8_' . $row_count . '" value="' . htmlspecialchars($row['col8']) . '"></td>';
break;
case 5:
echo '<td class="text-center"><input type="text" class="form-control text-center beforeHeight noborder-input" id="col9_' . $row_count . '" name="col9_' . $row_count . '" value="' . htmlspecialchars($row['col9']) . '"></td>';
break;
case 6:
echo '<td class="text-center"><input type="text" class="form-control text-center afterWidth noborder-input" id="col8_plus_' . $row_count . '" name="col8_plus_' . $row_count . '" value="' . htmlspecialchars($row['col8'] ) . '"></td>';
break;
case 7:
echo '<td class="text-center"><input type="text" class="form-control text-center afterHeight noborder-input" id="col9_plus_' . $row_count . '" name="col9_plus_' . $row_count . '" value="' . htmlspecialchars($row['col9'] ) . '"></td>';
break;
case 8:
echo '<td class="text-center">
<input type="checkbox"
class="exceptCheck"
id="exceptCheck' . $row_count . '"
name="exceptCheck' . $row_count . '"
value="1"' .
(!empty($exceptCheck_) ? ' checked' : '') .
'>
</td>';
break;
case 9:
echo '<td class="text-center"><input type="text" class="form-control text-center recordComent noborder-input" id="changeComent_' . $row_count . '" name="changeComent_' . $row_count . '" value="' . (isset($changeComent) ? $changeComent : '') . '"></td>';
break;
}
}
echo '</tr>';
$row_count ++ ;
}
?>
</tbody>
</table>
</div>
</div>
</div>
</form>
</div> <!-- end of container -->
<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/' . $tablename . '/common/pdftooltip.php'; ?> <!-- generatePDF, BS tootip 등 공통 JS -->
<script>
// 초기 정보 로딩
$(document).ready(function () {
var realiList = <?= json_encode($realiList ?: (object)[]) ?>;
if (realiList) {
console.log('if문 realiList 실행', realiList );
Object.keys(realiList).forEach((key) => {
const classData = realiList[key];
// classData가 배열인지 확인
if (!Array.isArray(classData)) {
console.warn(`"${key}" 데이터가 유효하지 않아 무시됩니다.`);
return;
}
classData.forEach((item, index) => {
const $element = $(`.${key}`).eq(index); // 클래스와 인덱스로 요소 선택
if (key === 'exceptCheck') {
// 체크박스 처리: 저장 시 객체 구조라면, 예를 들어 item.checked로 저장했다면:
if ($element.is(':checkbox')) {
$element.prop('checked', item.checked === '1'); // '1'이면 체크, 아니면 체크 해제
} else {
console.warn(`"${key}" 클래스의 ${index}번째 요소가 체크박스가 아님.`);
}
} else if ($element.is('input, textarea, select')) {
// 일반 입력 요소 처리: 객체의 value 프로퍼티를 사용
$element.val(item.value || '');
} else {
console.warn(`"${key}" 클래스의 ${index}번째 요소가 입력 가능하지 않음.`);
}
});
});
}
console.log('초기로드 데이터 상태:', realiList);
$(document).on('click', '.saveData', function() {
saveData();
});
$(document).on('click', '.loadACIBtn', function() {
loadACI();
});
function loadACI() {
$("#overlay").show(); // 오버레이 표시
$("button").prop("disabled", true); // 모든 버튼 비활성화
const prodcode = $("#prodcode").val();
const tablename = $("#tablename").val();
const num = $("#num").val();
let url;
// prodcode에 따라 URL 설정
if (prodcode.startsWith('KS') || prodcode.startsWith('KW')) {
url = "write_ACI.php?num=" + num + "&tablename=" + tablename;
} else {
url = "write_ACI_slat.php?num=" + num + "&tablename=" + tablename;
}
customPopup(url, '인정검사', 800, 900);
$("button").prop("disabled", false); // 모든 버튼 비활성화
hideMsgModal();
$("#overlay").hide(); // 오버레이 숨김
}
function saveData() {
$("#overlay").show(); // 오버레이 표시
$("button").prop("disabled", true); // 모든 버튼 비활성화
// FormData 초기화
var form = $('#board_form')[0];
var datasource = new FormData(form);
// JSON 데이터 생성
let formData = {};
// 처리할 클래스 목록
const classList = ['inputValue', 'beforeWidth', 'beforeHeight', 'afterWidth', 'afterHeight', 'recordComent'];
// 클래스별 데이터 수집 (id와 value 함께 저장)
classList.forEach((className) => {
let classData = [];
$(`.${className}`).each(function () {
classData.push({
id: $(this).attr('id'), // 해당 요소의 id 저장
value: $(this).val() || '' // 값 저장
});
});
formData[className] = classData;
});
// 제외 체크박스 데이터 처리
let checkboxData = [];
$('.exceptCheck').each(function () {
checkboxData.push($(this).is(':checked') ? '1' : '0'); // 체크 여부 저장
});
formData['exceptCheck'] = checkboxData;
// JSON 문자열로 변환 및 숨겨진 필드에 저장
try {
const jsonString = JSON.stringify(formData, null, 2);
$('#realiList').val(jsonString); // hidden input에 JSON 문자열 저장
console.log('JSON 데이터로 변환하여 저장 전 자료 jsonString : ', jsonString);
} catch (error) {
console.error('JSON 직렬화 오류:', error);
alert("JSON 직렬화 중 오류가 발생했습니다.");
return;
}
datasource.append('realiList', $('#realiList').val()); // FormData에 추가
// AJAX 요청
ajaxRequest = $.ajax({
enctype: 'multipart/form-data',
processData: false,
contentType: false,
cache: false,
timeout: 600000,
url: "insert_realiList.php",
type: "post",
data: datasource,
dataType: "json",
success: function (data) {
console.log(data);
setTimeout(function () {
$("button").prop("disabled", false); // 모든 버튼 활성화
hideMsgModal();
$("#overlay").hide(); // 오버레이 숨김
Toastify({
text: "저장완료",
duration: 3000,
close: true,
gravity: "top",
position: "center",
style: {
background: "linear-gradient(to right, #00b09b, #96c93d)"
},
}).showToast();
}, 1000);
},
error: function (jqxhr, status, error) {
console.log(jqxhr, status, error);
alert("An error occurred: " + error);
}
});
}
// Enter 키를 감지하여 버튼 클릭 이벤트 트리거
$(document).on('keydown', '#distributor_corp', function (e) {
if (e.key === 'Enter') {
e.preventDefault(); // 기본 동작 방지
$('.loadDistributorBtn').trigger('click'); // 버튼 클릭 이벤트 트리거
}
});
// 버튼 클릭 이벤트 처리
$(document).on('click', '.loadDistributorBtn', function (e) {
e.preventDefault(); // 기본 동작 방지
var $button = $(this); // 클릭된 버튼
if ($button.prop('disabled')) {
return; // 이미 비활성화된 상태라면 아무 작업도 하지 않음
}
var search = $("#distributor_corp").val().trim(); // 검색어 가져오기 및 공백 제거
// if (!search) {
// // 검색어가 없을 경우 SweetAlert2로 경고 창 표시
// Swal.fire({
// icon: 'warning',
// title: '자재유통회사명을 입력하세요',
// text: '검색어를 입력한 후 다시 시도해주세요.',
// confirmButtonText: '확인'
// });
// return; // 이후 코드 실행 중단
// }
$button.prop('disabled', true); // 버튼 비활성화
var href = '../phonebook/list.php?searchItem=distributor&search=' + encodeURIComponent(search); // 검색어를 URL에 추가
popupCenter(href, '유통업자 검색', 1600, 800);
// 팝업 창 감지 후 다시 활성화 (대기 시간 조정 가능)
setTimeout(function () {
$button.prop('disabled', false); // 버튼 활성화
}, 1000); // 1초 후 버튼 활성화
});
// Enter 키를 감지하여 버튼 클릭 이벤트 트리거
$(document).on('keydown', '#civilEngineer_corp', function (e) {
if (e.key === 'Enter') {
e.preventDefault(); // 기본 동작 방지
$('.loadCEBtn').trigger('click'); // 버튼 클릭 이벤트 트리거
}
});
// 버튼 클릭 이벤트 처리
$(document).on('click', '.loadCEBtn', function (e) {
e.preventDefault(); // 기본 동작 방지
var $button = $(this); // 클릭된 버튼
if ($button.prop('disabled')) {
return; // 이미 비활성화된 상태라면 아무 작업도 하지 않음
}
var search = $("#civilEngineer_corp").val().trim(); // 검색어 가져오기 및 공백 제거
// if (!search) {
// // 검색어가 없을 경우 SweetAlert2로 경고 창 표시
// Swal.fire({
// icon: 'warning',
// title: '시공업체명을 입력하세요',
// text: '검색어를 입력한 후 다시 시도해주세요.',
// confirmButtonText: '확인'
// });
// return; // 이후 코드 실행 중단
// }
$button.prop('disabled', true); // 버튼 비활성화
var href = '../phonebook_CE/list.php?searchItem=CE&search=' + encodeURIComponent(search); // 검색어를 URL에 추가
popupCenter(href, '공사시공자 검색', 1600, 800);
// 팝업 창 감지 후 다시 활성화 (대기 시간 조정 가능)
setTimeout(function () {
$button.prop('disabled', false); // 버튼 활성화
}, 1000); // 1초 후 버튼 활성화
});
// Enter 키를 감지하여 버튼 클릭 이벤트 트리거
$(document).on('keydown', '#supervisor_corp', function (e) {
if (e.key === 'Enter') {
e.preventDefault(); // 기본 동작 방지
$('.loadSUBtn').trigger('click'); // 버튼 클릭 이벤트 트리거
}
});
// 버튼 클릭 이벤트 처리
$(document).on('click', '.loadSUBtn', function (e) {
e.preventDefault(); // 기본 동작 방지
var $button = $(this); // 클릭된 버튼
if ($button.prop('disabled')) {
return; // 이미 비활성화된 상태라면 아무 작업도 하지 않음
}
var search = $("#supervisor_corp").val().trim(); // 검색어 가져오기 및 공백 제거
// if (!search) {
// // 검색어가 없을 경우 SweetAlert2로 경고 창 표시
// Swal.fire({
// icon: 'warning',
// title: '감리업체명을 입력하세요',
// text: '검색어를 입력한 후 다시 시도해주세요.',
// confirmButtonText: '확인'
// });
// return; // 이후 코드 실행 중단
// }
$button.prop('disabled', true); // 버튼 비활성화
var href = '../phonebook_SU/list.php?searchItem=SU&search=' + encodeURIComponent(search); // 검색어를 URL에 추가
popupCenter(href, '감리업체 검색', 1600, 800);
// 팝업 창 감지 후 다시 활성화 (대기 시간 조정 가능)
setTimeout(function () {
$button.prop('disabled', false); // 버튼 활성화
}, 1000); // 1초 후 버튼 활성화
});
$('.noborder-input').on('input', function () {
const $input = $(this);
const text = $input.val();
// Canvas를 사용하여 텍스트 폭 계산
const canvas = document.createElement('canvas');
const context = canvas.getContext('2d');
const font = window.getComputedStyle($input[0]).font;
context.font = font; // 현재 input 요소의 폰트를 적용
const textWidth = context.measureText(text).width;
$input.css('width', `${Math.max(textWidth + 20, 130)}px`); // 최소 130px 폭 유지
});
$(document).on('input', 'textarea.noborder-input', function () {
const $textarea = $(this);
const text = $textarea.val();
// Canvas를 사용하여 텍스트 폭 계산
const canvas = document.createElement('canvas');
const context = canvas.getContext('2d');
const font = window.getComputedStyle($textarea[0]).font;
context.font = font; // 현재 textarea의 폰트를 캔버스에 적용
const textWidth = context.measureText(text).width;
// 폭과 높이 조정
$textarea.css('width', `${Math.max(textWidth + 20, 120)}px`); // 최소 120px 폭 유지
$textarea.css('height', 'auto'); // 초기 높이 설정
$textarea.css('height', `${$textarea[0].scrollHeight}px`); // 내용에 따라 높이 조정
});
});
$(document).ready(function () {
$('.initialBtn').on('click', function () {
Swal.fire({
title: '초기화',
text: "모든 데이터를 초기화하시겠습니까?",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: '예, 초기화합니다',
cancelButtonText: '취소'
}).then((result) => {
if (result.isConfirmed) {
let formData = {};
// 수정: 저장 시 사용한 클래스 목록과 동일하게 구성
const classList = ['inputValue', 'beforeWidth', 'beforeHeight', 'afterWidth', 'afterHeight', 'recordComent'];
// 각 클래스별로 id와 빈 value로 초기화
classList.forEach((className) => {
let initialArray = [];
$(`.${className}`).each(function () {
initialArray.push({
id: $(this).attr('id'),
value: '' // 초기값은 빈 문자열
});
});
formData[className] = initialArray;
});
// 제외 체크박스도 동일하게 초기화 (필요한 경우)
let checkboxInitial = [];
$('.exceptCheck').each(function () {
checkboxInitial.push({
id: $(this).attr('id'),
checked: '0'
});
});
formData['exceptCheck'] = checkboxInitial;
// JSON 문자열로 변환
const initialData = JSON.stringify(formData, null, 2);
// realiList hidden input에 초기화된 데이터 설정
$('#realiList').val(initialData);
// 초기화된 데이터 저장 요청
$.ajax({
url: 'insert_realiList.php',
type: 'POST',
data: {
num: $('#num').val(),
tablename: $('#tablename').val(),
update_log: $('#update_log').val(),
realiList: initialData
},
success: function (response) {
Swal.fire({
title: '초기화 완료',
text: "모든 데이터가 초기화되었습니다.",
icon: 'success',
confirmButtonText: '확인'
}).then(() => {
location.reload();
});
},
error: function (jqxhr, status, error) {
Swal.fire({
title: '오류',
text: "초기화 중 오류가 발생했습니다.",
icon: 'error',
confirmButtonText: '확인'
});
console.log("AJAX Error: ", status, error);
}
});
}
});
});
});
</script>
</body>
</html>