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

820 lines
36 KiB
PHP

<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/instock/commonRequest.php'; // 구글드라이브 세션 파일 포함
$title_message = '자동방화셔터(인정제품) 제품검사요청서';
$tablename = 'output';
$item ='자동방화셔터(인정제품)제품검사요청서';
$emailTitle ='자동방화셔터(인정제품)제품검사요청서';
// 품질담당자 및 관리자인 경우 권한 부여
$QCadmin = false ;
if($user_name=='이세희' || $user_name=='개발자' || $user_name=='함신옥' || $user_name=='노완호' )
$QCadmin = true ;
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
// 전달받은 groupListCode 디코딩 및 콤마(,)로 분리하여 배열 생성
$groupListCode = $_REQUEST['groupListCode'] ?? '';
$groupCode = $_REQUEST['groupCode'] ?? '';
$groupListCode = urldecode($groupListCode);
$groupCodeArray = explode(',', $groupListCode);
// print_r($groupCodeArray);
// 전달받은 groupListCode 디코딩 및 콤마(,)로 분리하여 배열 생성
$groupListCode = $_REQUEST['groupListCode'] ?? '';
$groupCode = $_REQUEST['groupCode'] ?? '';
$groupListCode = urldecode($groupListCode);
$groupCodeArray = explode(',', $groupListCode);
// print_r($groupCodeArray);
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
require_once($_SERVER['DOCUMENT_ROOT'] . "/estimate/fetch_unitprice.php");
$pdo = db_connect();
//---------------------------------------------------------------------
// 최종 combined JSON 파일은 여러 수주리스트(품질관리서)의 기초자료를
// lotNum을 키로 저장하는 구조로 만듭니다.
// 여기서 $groupCode는 고유 코드이므로 '-' 등 특수문자는 제거하여 파일명에 사용합니다.
$safeGroupCode = preg_replace('/[^a-zA-Z0-9]/', '', $groupCode);
$combinedJsonFilePath = "../output/qc_json/" . $safeGroupCode . ".json";
// 기존 JSON 파일이 있으면 불러오기, 없으면 빈 배열 초기화
if (file_exists($combinedJsonFilePath)) {
$existingData = file_get_contents($combinedJsonFilePath);
$lotData = json_decode($existingData, true);
if (!is_array($lotData)) {
$lotData = [];
$jsonCreation = 'new';
}
} else {
$lotData = [];
$jsonCreation = 'new';
}
//---------------------------------------------------------------------
// echo '<pre>';
// print_r($lotData);
// echo '</pre>';
// 'inputValue' 배열의 각 항목에서 'value'를 값으로, 'id'를 키로 재구성
$inputValuesById = array_column($lotData['inputValue'], 'value', 'id');
// 원하는 값들을 변수에 할당 (값이 없으면 빈 문자열 할당)
$aciRegDateValue = $inputValuesById['ACIregDate'] ?? '';
$secondordValue = $inputValuesById['secondord'] ?? '';
$receiverValue = $inputValuesById['receiver'] ?? '';
$lotNumValue = $inputValuesById['lotNum'] ?? '';
$hpValue = $inputValuesById['hp'] ?? '';
$outworkplaceValue = $inputValuesById['outworkplace'] ?? '';
$outdateValue = $inputValuesById['outdate'] ?? '';
$outputplaceValue = $inputValuesById['outputplace'] ?? '';
$lotVolumnValue = $inputValuesById['lotVolumn'] ?? '';
$ACIaskDateValue = $inputValuesById['ACIaskDate'] ?? '';
$outworkplace_detailValue = $inputValuesById['outworkplace_detail'] ?? '';
$outputplace_detailValue = $inputValuesById['outputplace_detail'] ?? '';
$landNumberValue = $inputValuesById['landNumber'] ?? '';
$distributor_nameValue = $inputValuesById['distributor_name'] ?? '';
$distributor_corpValue = $inputValuesById['distributor_corp'] ?? '';
$distributor_addrValue = $inputValuesById['distributor_addr'] ?? '';
$distributor_telValue = $inputValuesById['distributor_tel'] ?? '';
$civilEngineer_nameValue = $inputValuesById['civilEngineer_name'] ?? '';
$civilEngineer_corpValue = $inputValuesById['civilEngineer_corp'] ?? '';
$civilEngineer_addrValue = $inputValuesById['civilEngineer_addr'] ?? '';
$civilEngineer_telValue = $inputValuesById['civilEngineer_tel'] ?? '';
$supervisor_nameValue = $inputValuesById['supervisor_name'] ?? '';
$supervisor_corpValue = $inputValuesById['supervisor_corp'] ?? '';
$supervisor_addrValue = $inputValuesById['supervisor_addr'] ?? '';
$supervisor_telValue = $inputValuesById['supervisor_tel'] ?? '';
$prodCode = $inputValuesById['prodCode'] ?? '';
$lotNumString = $inputValuesById['lotNumString'] ?? '';
$groupCode = $inputValuesById['groupCode'] ?? '';
$warrantyNum = $inputValuesById['warrantyNum'] ?? '';
$ACIdoneDate = $inputValuesById['ACIdoneDate'] ?? date('Y-m-d') ;
// 동적으로 셔터수량등은 설정이 될 수 있으니 동적으로 적용하기
$columns = [];
foreach ($inputValuesById as $key => $value) {
// 키가 "col1_", "col2_", "col3_" 형태인지 확인
if (preg_match('/^(col[123])_(\d+)$/', $key, $matches)) {
$colName = $matches[1]; // 예: "col1"
$index = $matches[2]; // 인덱스 값 (문자열이지만, 숫자로 취급 가능)
$columns[$index][$colName] = $value;
$lotVolumn ++ ;
}
}
$lotVolumn = $lotVolumn/3;
// echo '<pre>';
// print_r($realiList['afterWidth']);
// echo '</pre>';
// 'afterWidthById' 배열의 각 항목에서 'value'를 값으로, 'id'를 키로 재구성
$afterWidthById = array_column($lotData['afterWidth'], 'value', 'id');
// 동적으로 셔터수량등은 설정이 될 수 있으니 동적으로 적용하기
$columns = [];
$innercount = 0;
foreach ($afterWidthById as $key => $value) {
// 키가 "col8_plus_"로 시작하는지 확인
if (preg_match('/^(col8_plus)_(\d+)$/', $key, $matches)) {
$colName = $matches[1]; // 예: "col8_plus"
$index = $matches[2]; // 인덱스 값 (문자열이지만 숫자로 취급 가능)
$columns[$index][$colName] = $value;
if ($innercount == 0) {
$width = $value;
}
$innercount++;
}
}
// echo '<pre>';
// print_r($realiList['afterHeight']);
// echo '</pre>';
// 'afterHeightById' 배열의 각 항목에서 'value'를 값으로, 'id'를 키로 재구성
$afterHeightById = array_column($lotData['afterHeight'], 'value', 'id');
// 두 번째 foreach에서는 $columns 배열을 다시 초기화하지 않도록 합니다.
$innercount = 0;
$columns = [];
foreach ($afterHeightById as $key => $value) {
// 키가 "col9_plus_"로 시작하는지 확인
if (preg_match('/^(col9_plus)_(\d+)$/', $key, $matches)) {
$colName = $matches[1]; // 예: "col9_plus"
$index = $matches[2]; // 인덱스 값 (문자열이지만 숫자로 취급 가능)
$columns[$index][$colName] = $value;
if ($innercount == 0) {
$height = $value;
}
$innercount++;
}
}
//2000*3000*0.84 mm 외 0개소 의 형태 만들기
$prodName = ""; // 상품명을 저장할 변수
// if문을 사용하여 제품 코드에 따른 상품명 설정
if ($prodCode == 'KSS01') {
$prodName = '국민방화 스크린 셔터';
$arrayWidth = $screen_width[$page-1] ;
$arrayHeight = $screen_height[$page-1] ;
$thickness = '0.84';
} elseif ($prodCode == 'KSE01') {
$prodName = '국민방화 스크린 셔터';
$arrayWidth = $screen_width[$page-1] ;
$arrayHeight = $screen_height[$page-1] ;
$thickness = '0.84';
} elseif ($prodCode == 'KWE01') {
$prodName = '국민방화 스크린 플러스 셔터';
$arrayWidth = $screen_width[$page-1] ;
$arrayHeight = $screen_height[$page-1] ;
$thickness = '0.84';
} elseif ($prodCode == 'KD-SL60') {
$prodName = '국민방화 스틸 셔터';
$arrayWidth = $slat_width[$page-1] ;
$arrayHeight = $slat_height[$page-1] ;
$thickness = '1.55';
} elseif ($prodCode == 'KTE01') {
$prodName = '국민방화 스틸 셔터';
$arrayWidth = $slat_width[$page-1] ;
$arrayHeight = $slat_height[$page-1] ;
$thickness = '1.55';
} elseif ($prodCode == 'KQTS01') {
$prodName = '국민방화 투시형 스틸 셔터';
$arrayWidth = $slat_width[$page-1] ;
$arrayHeight = $slat_height[$page-1] ;
$thickness = '1.55';
} else {
$prodName = "유효하지 않은 제품 코드입니다.";
}
$pageWidth = $arrayWidth;
$pageHeight = $arrayHeight;
$contents = $width . '*' . $height . '*' . $thickness . ' mm';
$gaeso = $lotVolumn - 1;
?>
<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 mx-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 loadrequestACIBtn" > <i class="bi bi-window"></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="groupCode" name="groupCode" value="<?= isset($groupCode) ? $groupCode : null ?>">
<input type="hidden" id="safeGroupCode" name="safeGroupCode" value="<?= isset($safeGroupCode) ? $safeGroupCode : null ?>">
<input type="hidden" id="jsonCreation" name="jsonCreation" value="<?= isset($jsonCreation) ? $jsonCreation : null ?>"> <!-- 새로데이터 생성시 new로 저장됨 -->
<input type="hidden" id="realiList" name="realiList" >
<div id="content-to-print" >
<div class="container mt-2">
<p> ■ 건축물의 피난ㆍ방화구조 등의 기준에 관한 규칙 [별지 제4호서식] <span class='text-primary'> <개정 2021. 12. 23.> </span> </p>
<div class="row d-flex justify-content-center">
<h4 class="text-center fw-bold">자동방화셔터 품질관리서</h4>
</div>
<div class="row d-flex justify-content-center">
<table id="mainTable" class="table" style="border-collapse: collapse;">
<tbody>
<tr>
<td class="text-center fw-bold" colspan="1" rowspan="2"> 제출인
<br>
(건축주)
</td>
<td colspan="5" class="text-start fw-bold" >
성명(법인명) :
</td>
</tr>
<tr>
<td colspan="5" class="text-start">
주소 :
</td>
</tr>
<tr>
<td rowspan="2" class="text-start fw-bold">공사현장</td>
<td colspan="5" class="text-start"> 현장명 : &nbsp; <?=$outworkplace_detailValue?> </td>
</tr>
<tr>
<td colspan="3" class="text-start"> 대지위치 : &nbsp; <?=$outputplace_detailValue?> </td>
<td colspan="2" class="text-start"> 지번 : &nbsp; <?=$landNumberValue?> </td>
</tr>
<tr>
<td rowspan="2" class=" fw-bold">자재 <br> 개요 </td>
<td colspan="2" class="text-start ">■ 연기 및 불꽃을 차단 할 수 있는 <br>
시간이 60분 이상
</td>
<td rowspan="2"> 셔터 규격 <br>
(가로 X 세로 X 두께) <br>
<?=$contents?><br>
외 <?=$gaeso?>개소 <br>
</td>
<td rowspan="2"> 제품명 <br> <?=$prodCode?> <br>
품질관리서번호 <br>
<?=$groupCode?>
</td>
<td rowspan="2"> 성적서 번호 <br>
(품질인정번호) <br>
<?=$warrantyNum?>
<br>
</td>
</tr>
<tr>
<td colspan="1" class="text-start "> 일체형<br> 셔터여부 </td>
<td colspan="1" class="text-start "> □ 예 <br> ■ 아니오 </td>
</tr>
<tr>
<td rowspan="4" class=" fw-bold">자재 <br> 제조업자 </td>
<td colspan="2" class="text-start ">성명 &nbsp; 이경호
<td colspan="1" class="text-start ">생년월일 &nbsp; 70.12.07
<td rowspan="4" colspan="2" class="text-start " >■ 성능을 갖춘 ■ 품질인정을 받은 자동방화셔터 <br>
<?=$lotVolumn?> 개를 ■ 자재유통업자 □ 공사시공자에게 납품했음 <br><br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <?= date('Y년 n월 j일', strtotime($ACIdoneDate)) ?> <br><br>
소속 : (주)경동기업 &nbsp; &nbsp; 성명 : 이 경 호 (서명 또는 인)
</td>
</tr>
<tr>
<td colspan="2" class="text-start ">회사명 &nbsp; (주)경동기업
<td colspan="1" class="text-start ">법인등록번호 <br> 124411-0174300
</tr>
<tr>
<td colspan="3" class="text-start "> 로트번호 &nbsp; &nbsp; <?=$lotNumString?> </td>
</tr>
<tr>
<td colspan="3" class="text-start "> 주소 &nbsp; &nbsp; 경기 김포시 통진읍 옹정로 45-22 <br> (전화번호 : 031-983-5130) </td>
</tr>
<tr>
<td rowspan="4" class=" fw-bold">자재 <br> 유통업자 </td>
<td colspan="2" class="text-start ">성명 &nbsp; <?=$distributor_nameValue?>
<td colspan="1" class="text-start ">생년월일
<td rowspan="4" colspan="2" class="text-start " >
■ 성능을 갖춘 ■ 품질인정을 받은 공급받은 자동방화셔터<br>
<?=$lotVolumn?> 개를 공사시공자에게 납품했음 <br>
&nbsp; &nbsp; &nbsp; &nbsp; 20 &nbsp; &nbsp; 년 &nbsp; &nbsp; &nbsp; 월 &nbsp; &nbsp; &nbsp; 일 <br>
소속 : <?=$distributor_corpValue?> &nbsp; &nbsp; 성명 : <?=$distributor_nameValue?> (서명 또는 인)
</td>
</tr>
<tr>
<td colspan="2" class="text-start ">회사명 &nbsp; <?=$distributor_corpValue?>
<td colspan="1" class="text-start ">법인등록번호 <br>
</tr>
<tr>
<td colspan="3" class="text-start "> 로트번호 &nbsp; &nbsp; <?=$landNumberValue?> </td>
</tr>
<tr>
<td colspan="3" class="text-start "> 주소 &nbsp; &nbsp; <?=$distributor_addrValue?> <br> (전화번호 : <?=$distributor_telValue?> ) </td>
</tr>
<tr>
<td rowspan="3" class="text-danger fw-bold" >공사 <br> 시공자 </td>
<td colspan="2" class="text-start ">성명 &nbsp; <?=$civilEngineer_nameValue?>
<td colspan="1" class="text-start ">생년월일
<td rowspan="3" colspan="2" class="text-start ">
■ 성능을 갖춘 ■ 품질인정을 받은 자동방화셔터 <br>
<?=$lotVolumn?> 개를 □ 자재제조업자 ■ 자재유통업자로부터 인수했음<br>
&nbsp; &nbsp; &nbsp; &nbsp; 20 &nbsp; &nbsp; 년 &nbsp; &nbsp; &nbsp; 월 &nbsp; &nbsp; &nbsp; 일 <br>
소속 : <?=$civilEngineer_corpValue?> &nbsp; &nbsp; 성명 : <?=$civilEngineer_nameValue?> (서명 또는 인) <br>
■ 성능을 갖춘 ■ 품질인정을 받은 자동방화셔터를 적정 <br>
하게 시공했음 <br>
&nbsp; &nbsp; &nbsp; &nbsp; 20 &nbsp; &nbsp; 년 &nbsp; &nbsp; &nbsp; 월 &nbsp; &nbsp; &nbsp; 일 <br>
소속 : <?=$civilEngineer_corpValue?> &nbsp; &nbsp; 성명 : <?=$civilEngineer_nameValue?> (서명 또는 인)
</td>
</tr>
<tr>
<td colspan="2" class="text-start ">회사명 &nbsp; &nbsp; <?=$civilEngineer_corpValue?>
<td colspan="1" class="text-start ">법인등록번호 <br>
</tr>
<tr>
<td colspan="3" class="text-start "> 주소 &nbsp; &nbsp; <?=$civilEngineer_addrValue?> <br> (전화번호 : <?=$civilEngineer_telValue?> ) </td>
</tr>
<tr>
<td rowspan="3" class="text-center fw-bold" >공사 <br> 감리자 </td>
<td colspan="2" class="text-start ">성명 <?=$supervisor_nameValue?>
<td colspan="1" class="text-start ">자격번호
<td rowspan="3" colspan="2" class="text-start ">
■ 성능을 갖춘 ■ 품질인정을 받은 자동방화셔터를 적정<br>
하게 시공했음을 확인함<br>
&nbsp; &nbsp; &nbsp; &nbsp; 20 &nbsp; &nbsp; 년 &nbsp; &nbsp; &nbsp; 월 &nbsp; &nbsp; &nbsp; 일 <br><br>
소속 : <?=$supervisor_corpValue?> &nbsp; &nbsp; 성명 : <?=$supervisor_nameValue?> (서명 또는 인)
</td>
</tr>
<tr>
<td colspan="2" class="text-start ">사무소명 &nbsp; &nbsp; <?=$supervisor_corpValue?>
<td colspan="1" class="text-start ">신고번호 <br>
</tr>
<tr>
<td colspan="3" class="text-start "> 사무소주소 &nbsp; &nbsp; <?=$supervisor_addrValue?> <br> (전화번호 : <?=$supervisor_telValue?> ) </td>
</tr>
<tr>
<td colspan="6" class="text-start ">
<div class="row mb-3" >
<span class='text-start' style='font-size: 15px;'>
「건축법」 제52조의4, 같은 법 시행령 제62조제1항제4호 및 「건축물의 피난ㆍ방화구조 등의 기준에 관한 <br>
규칙 」 제24조의3제2항제4호에 따라 위와 같이 품질관리서를 제출합니다. <br>
</span>
<span class='text-end mt-1 mb-1' style='font-size: 15px;'>
<span class='text-end'> 20 &nbsp; &nbsp; 년 &nbsp; &nbsp; &nbsp; 월 &nbsp; &nbsp; &nbsp; 일 </span>
</span>
<span class='text-end mt-1 mb-1' style='font-size: 15px;'>
제출인(건축주) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (서명 또는 인)
</span>
</div>
<div class="row " >
<h5 class='text-start'>
특별시장ㆍ광역시장ㆍ특별자치시장ㆍ특별자치도지사, 시장ㆍ군수ㆍ구청장 귀하
</h5>
<br>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="row d-flex justify-content-center mt-2 p-2">
<table class="table table-sm" style="border-collapse: collapse;">
<thead class="table-secondary">
<tr>
<th > 비고 </th>
</tr>
</thead>
<tbody>
<tr>
<td class="text-start" >
1. 첨부서류 : 연기 및 불꽃을 차단할 수 있는 성능이 표시된 자동방화셔터 시험성적서(법 제52조의5제1항에 따라 품질인정을 받은 경우에는 품질<br>
인정서) 사본 <br>
2. 공사시공자와 공사감리자는 첨부된 시험성적서 또는 품질인정서의 위ㆍ변조 여부를 확인한 뒤 서명 또는 날인해야 합니다. <br>
3. 공사감리자는 이 서식을 공사감리완료보고서에 첨부하여 건축주에게 제출해야 하며, 건축주는 「건축법」 제22조에 따른 사용승인을 신청할 때 <br>
「건축법 시행규칙」 별지 제17호서식의 사용승인 신청서와 함께 제출해야 합니다.
<br>
4. 자동방화셔터의 납품일 또는 시공완료일 등이 복수인 경우에는 이 서식을 각각 작성합니다.
</td>
</tr>
</tbody>
</table>
</div>
<div class="row d-flex justify-content-end" style="padding: 1px!important;">
210mmx297mm[백상지 80g/㎡]
</div>
</div><!-- end of container -->
</form>
</div> <!-- end of print to printer container -->
<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/' . $tablename . '/common/pdftooltip.php'; ?> <!-- generatePDF, BS tootip 등 공통 JS -->
<script>
// 초기 정보 로딩
$(document).ready(function () {
// PHP에서 전달한 최종 JSON 객체 (수주리스트 데이터 keyed by lotNum)
var lotData = <?= json_encode($lotData ?: (object)[]) ?>;
console.log('전체 수주리스트 데이터:', lotData);
$(document).on('click', '.saveData', function() {
saveData();
});
$(document).on('click', '.loadACIBtn', function() {
loadACI();
});
$(document).on('click', '.loadrequestACIBtn', function() {
$("#overlay").show(); // 오버레이 표시
$("button").prop("disabled", true); // 모든 버튼 비활성화
const groupCode = $("#groupCode").val();
let url;
url = "view_requestACIgroup.php?groupCode=" + encodeURIComponent(groupCode) ;
customPopup(url, '제품 인정검사 요청', 800, 900);
$("button").prop("disabled", false); // 모든 버튼 비활성화
hideMsgModal();
$("#overlay").hide(); // 오버레이 숨김
});
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'];
// 클래스별 데이터 수집
classList.forEach((className) => {
let classData = [];
$(`.${className}`).each(function () {
classData.push($(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) {
// formData 초기화
let formData = {};
// 처리할 클래스 목록
// const classList = ['inputValue', 'beforeWidth', 'beforeHeight', 'afterWidth', 'afterHeight', 'recordComent'];
const classList = ['beforeWidth', 'beforeHeight', 'afterWidth', 'afterHeight', 'recordComent'];
// 클래스별 데이터 초기화
classList.forEach((className) => {
formData[className] = []; // 빈 배열로 초기화
});
// 제외 체크박스 데이터 초기화
formData['exceptCheck'] = []; // 빈 배열로 초기화
// JSON 문자열로 변환
const initialData = JSON.stringify(formData, null, 2);
// realiList hidden input에 초기화된 데이터 설정
$('#realiList').val(initialData);
// 초기화된 데이터 저장 요청
$.ajax({
url: 'insert_realiList.php', // 데이터를 저장할 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>