- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경 - DB 연결 하드코딩 → .env 기반으로 변경 - MySQL strict mode DATE 오류 수정
1124 lines
51 KiB
PHP
1124 lines
51 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);
|
|
|
|
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';
|
|
}
|
|
//---------------------------------------------------------------------
|
|
|
|
// 로트번호 누적
|
|
$lotNumArray = [] ;
|
|
|
|
// 기존 자료가 없을 때만 그룹코드 배열을 순회하여 기초자료를 생성합니다.
|
|
if (empty($lotData)) {
|
|
$lotVolumn = 0;
|
|
foreach ($groupCodeArray as $groupCodeVal) {
|
|
try {
|
|
// 각 레코드 조회 (테이블 및 DB명은 기존 변수 사용)
|
|
$sql = "SELECT * FROM {$DB}.{$tablename} WHERE num = ?";
|
|
$stmh = $pdo->prepare($sql);
|
|
$stmh->bindValue(1, $groupCodeVal, PDO::PARAM_STR);
|
|
$stmh->execute();
|
|
$count = $stmh->rowCount();
|
|
if ($count < 1) {
|
|
print "num 값 '{$groupCodeVal}' 에 대한 검색결과가 없습니다.<br>";
|
|
continue;
|
|
} else {
|
|
$row = $stmh->fetch(PDO::FETCH_ASSOC);
|
|
// _row.php 파일 내에서 아래의 변수들이 설정된다고 가정합니다.
|
|
// 예: $eList_screen, $eList_slat, $lotNum, $prodCode 등
|
|
include "_row.php";
|
|
// output_extra 테이블에서 데이터 불러오기
|
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/output/load_output_extraTable.php';
|
|
// ※ _row.php를 여러 번 include 시 변수 충돌에 유의하시기 바랍니다.
|
|
$lotNumArray[] = $lotNum;
|
|
|
|
}
|
|
} catch (PDOException $Exception) {
|
|
print "오류: " . $Exception->getMessage();
|
|
continue;
|
|
}
|
|
|
|
// per-record(수주리스트별) 초기화 변수
|
|
$$recordLotNum = ''; // 로트번호
|
|
$recordTotalShutterSurang = 0; // 스크린용 셔터 수량 누계 (col14)
|
|
$recordTotalShutterSurang_slat = 0; // 철재용 셔터 수량 누계 (col15)
|
|
$recordCombinedEList = []; // 해당 수주리스트의 combinedEList
|
|
$recordScreenWidths = []; // 스크린의 너비 배열
|
|
$recordScreenHeights = []; // 스크린의 높이 배열
|
|
$recordSlatWidths = []; // 철재의 너비 배열
|
|
$recordSlatHeights = []; // 철재의 높이 배열;
|
|
|
|
// JSON 데이터를 배열로 디코딩 (각 레코드의 기초 자료)
|
|
$eList_screenData = json_decode($eList_screen, true);
|
|
$eList_slatData = json_decode($eList_slat, true);
|
|
|
|
// 스크린 데이터 처리 (예: 셔터 수량: col14, 너비: col8, 높이: col9)
|
|
if (is_array($eList_screenData) && !empty($eList_screenData)) {
|
|
foreach ($eList_screenData as $item) {
|
|
$recordTotalShutterSurang += isset($item['col14']) ? (int)$item['col14'] : 0;
|
|
$recordScreenWidths[] = isset($item['col8']) ? intval($item['col8']) : 0;
|
|
$recordScreenHeights[] = isset($item['col9']) ? intval($item['col9']) : 0;
|
|
// 각 항목에 lotNum 추가
|
|
$item['lotNum'] = $lotNum;
|
|
}
|
|
|
|
$recordCombinedEList = array_merge($recordCombinedEList, $eList_screenData);
|
|
}
|
|
|
|
// 철재 데이터 처리 (예: 셔터 수량: col15, 너비: col8, 높이: col9)
|
|
if (is_array($eList_slatData) && !empty($eList_slatData)) {
|
|
foreach ($eList_slatData as $item) {
|
|
$recordTotalShutterSurang_slat += isset($item['col15']) ? (int)$item['col15'] : 0;
|
|
$recordSlatWidths[] = isset($item['col8']) ? intval($item['col8']) : 0;
|
|
$recordSlatHeights[] = isset($item['col9']) ? intval($item['col9']) : 0;
|
|
// 각 항목에 lotNum 추가
|
|
$item['lotNum'] = $lotNum;
|
|
}
|
|
$recordCombinedEList = array_merge($recordCombinedEList, $eList_slatData);
|
|
}
|
|
|
|
// 해당 수주리스트의 총 lotVolumn (스크린, 철재 중 값 있는쪽)
|
|
$recordLotVolumn = ($recordTotalShutterSurang > 0)
|
|
? $recordTotalShutterSurang
|
|
: $recordTotalShutterSurang_slat;
|
|
|
|
// 수량누적
|
|
$lotVolumn += $recordLotVolumn ;
|
|
// _row.php 또는 DB의 데이터로부터 해당 수주리스트의 lotNum을 가져온다고 가정 (예: $lotNum)
|
|
// 만약 $lotNum이 없으면, 임시값 또는 그룹코드값 사용 가능
|
|
$recordLotNum = $lotNum ?? $groupCodeVal;
|
|
|
|
// 수주리스트 별 데이터를 배열에 저장 (lotNum을 key로 함)
|
|
$recordData = [
|
|
'lotNum' => $recordLotNum,
|
|
'totalShutterSurang' => $recordTotalShutterSurang + $recordTotalShutterSurang_slat,
|
|
'lotVolumn' => $recordLotVolumn,
|
|
'combinedEList' => $recordCombinedEList,
|
|
'combinedScreenWidth' => $recordScreenWidths,
|
|
'combinedScreenHeight' => $recordScreenHeights,
|
|
'combinedSlatWidth' => $recordSlatWidths,
|
|
'combinedSlatHeight' => $recordSlatHeights
|
|
];
|
|
|
|
// 저장할 데이터 배열에 현재 수주리스트 데이터 추가 (lotNum이 key)
|
|
$lotData[$recordLotNum] = $recordData;
|
|
}
|
|
|
|
$selectedLotNum = $_REQUEST['lotNum'] ?? '';
|
|
if ($selectedLotNum && isset($lotData[$selectedLotNum])) {
|
|
$selectedRecord = $lotData[$selectedLotNum];
|
|
} else {
|
|
$selectedRecord = reset($lotData); // 첫 번째 수주리스트 데이터 선택
|
|
}
|
|
|
|
// 제품 코드에 따른 상품명 및 사이즈 설정 (선택된 수주리스트 데이터 사용)
|
|
$prodName = ""; // 상품명을 저장할 변수
|
|
if ($prodCode == 'KSS01' || $prodCode == 'KSE01') {
|
|
$prodName = '국민방화 스크린 셔터';
|
|
$arrayWidth = $selectedRecord['combinedScreenWidth'][$page-1] ?? 0;
|
|
$arrayHeight = $selectedRecord['combinedScreenHeight'][$page-1] ?? 0;
|
|
} elseif ($prodCode == 'KWE01') {
|
|
$prodName = '국민방화 스크린 플러스 셔터';
|
|
$arrayWidth = $selectedRecord['combinedScreenWidth'][$page-1] ?? 0;
|
|
$arrayHeight = $selectedRecord['combinedScreenHeight'][$page-1] ?? 0;
|
|
} elseif ($prodCode == 'KD-SL60' || $prodCode == 'KTE01' || $prodCode == 'KQTS01') {
|
|
if ($prodCode == 'KQTS01') {
|
|
$prodName = '국민방화 투시형 스틸 셔터';
|
|
} else {
|
|
$prodName = '국민방화 스틸 셔터';
|
|
}
|
|
$arrayWidth = $selectedRecord['combinedSlatWidth'][$page-1] ?? 0;
|
|
$arrayHeight = $selectedRecord['combinedSlatHeight'][$page-1] ?? 0;
|
|
} else {
|
|
$prodName = "유효하지 않은 제품 코드입니다.";
|
|
}
|
|
|
|
$pageWidth = $arrayWidth;
|
|
$pageHeight = $arrayHeight;
|
|
|
|
|
|
} // end if(empty($lotData))
|
|
|
|
// echo '<pre>';
|
|
// print_r($lotData);
|
|
// echo '</pre>';
|
|
|
|
// 최종 통합 데이터($lotData)를 JSON 파일로 저장 (가독성을 위해 JSON_PRETTY_PRINT 사용)
|
|
// file_put_contents($combinedJsonFilePath, json_encode($lotData, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
|
|
|
|
// -------------------------------------------------------------------
|
|
// 이후, 현재 화면에서 사용할 수주리스트(품질관리서)를 결정합니다.
|
|
// 예를 들어, 요청 시 특정 lotNum이 전달되었으면 해당 수주리스트를 사용하고,
|
|
// 그렇지 않으면 전체 중 첫번째 데이터를 선택합니다.
|
|
|
|
// 로트번호 배열 문자열로 만들기
|
|
$lotNumString = implode(',', $lotNumArray);
|
|
?>
|
|
|
|
|
|
<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="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 : '' ?>" class="inputValue" >
|
|
<input type="hidden" id="warrantyNum" name="warrantyNum" value="<?= isset($warrantyNum) ? $warrantyNum : '' ?>" class="inputValue" >
|
|
<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 ?>" class="inputValue" >
|
|
<input type="hidden" id="ACIaskDate" name="ACIaskDate" value="<?= isset($ACIaskDate) ? $ACIaskDate : null ?>" class="inputValue" >
|
|
<input type="hidden" id="groupListCode" name="groupListCode" value="<?= isset($groupListCode) ? $groupListCode : null ?>" class="inputValue" >
|
|
<input type="hidden" id="lotNumString" name="lotNumString" value="<?= isset($lotNumString) ? $lotNumString : null ?>" class="inputValue" >
|
|
<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" >
|
|
|
|
<!-- 수신처 모달 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="groupCode" name="groupCode" value="<?=$groupCode?>">
|
|
</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 " 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 " style="border-collapse: collapse;">
|
|
<thead>
|
|
<tr>
|
|
<th colspan="10" 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 w40px"> 층수 </th>
|
|
<th rowspan="3" class="text-center align-middle w80px"> 부호 </th>
|
|
<th rowspan="3" class="text-center align-middle w120px"> 로트번호 </th>
|
|
<th colspan="5" class="text-center align-middle w200px"> 오픈사이즈 </th>
|
|
<th rowspan="3" class="text-center align-middle w200px"> 변경사유 </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 id="dataBody">
|
|
<!-- 테이블 행은 JavaScript에서 동적으로 생성됩니다. -->
|
|
</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 () {
|
|
|
|
$(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에 추가
|
|
|
|
showMsgModal(2); // 파일저장중
|
|
|
|
// AJAX 요청
|
|
ajaxRequest = $.ajax({
|
|
enctype: 'multipart/form-data',
|
|
processData: false,
|
|
contentType: false,
|
|
cache: false,
|
|
timeout: 600000,
|
|
url: "insert_QCgroupList.php",
|
|
type: "post",
|
|
data: datasource,
|
|
dataType: "json",
|
|
success: function (data) {
|
|
console.log('서버 저장 후 받은 data ', 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 () {
|
|
|
|
// PHP에서 전달한 최종 JSON 객체 (수주리스트 데이터 keyed by lotNum)
|
|
var lotData = <?= json_encode($lotData ?: (object)[]) ?>;
|
|
console.log('전체 수주리스트 데이터:', lotData);
|
|
|
|
var JsonCreation = $("#jsonCreation").val();
|
|
|
|
// 테이블 행을 동적으로 생성할 <tbody> 요소 선택
|
|
var tbody = $("#dataBody");
|
|
tbody.empty();
|
|
|
|
if(JsonCreation == 'new') {
|
|
|
|
// 전체 행에 대해 고유 ID 생성을 위한 글로벌 인덱스
|
|
var globalRowIndex = 0;
|
|
|
|
// lotData의 모든 키를 순회하여 각 수주리스트를 화면에 표시
|
|
let counter = 0;
|
|
Object.keys(lotData).forEach(function(lotNum) {
|
|
var record = lotData[lotNum];
|
|
// console.log(lotNum);
|
|
|
|
// 만약 이전에 같은 로트번호의 제목 행이 추가되지 않았다면 제목 행 추가
|
|
// (lotData의 키는 이미 유일하므로 사실상 단 한 번씩만 실행됨)
|
|
if (record.combinedEList && record.combinedEList.length > 0) {
|
|
// var titleRow = $("<tr></tr>");
|
|
// var titleCell = $('<td colspan="9" class="text-center bg-light font-weight-bold"></td>')
|
|
// .text("Lot: " + lotNum);
|
|
// titleRow.append(titleCell);
|
|
// tbody.append(titleRow);
|
|
}
|
|
|
|
// 로트번호 저장
|
|
|
|
if (record.combinedEList && Array.isArray(record.combinedEList)) {
|
|
record.combinedEList.forEach(function (row) {
|
|
counter ++ ;
|
|
var tr = $("<tr></tr>");
|
|
|
|
// 컬럼 1: col1 (읽기 전용)
|
|
var td1 = $('<td class="text-center"></td>');
|
|
var input1 = $('<input type="text" class="form-control text-center inputValue noborder-input" readonly>');
|
|
input1.attr({ id: 'col1_' + globalRowIndex, name: 'col1_' + globalRowIndex })
|
|
.val(counter || '');
|
|
td1.append(input1);
|
|
tr.append(td1);
|
|
|
|
// 컬럼 2: col2
|
|
var td2 = $('<td class="text-center"></td>');
|
|
var input2 = $('<input type="text" class="form-control text-center inputValue noborder-input">');
|
|
input2.attr({ id: 'col2_' + globalRowIndex, name: 'col2_' + globalRowIndex })
|
|
.val(row.col2 || '');
|
|
td2.append(input2);
|
|
tr.append(td2);
|
|
|
|
// 컬럼 3: col3
|
|
var td3 = $('<td class="text-center"></td>');
|
|
var input3 = $('<input type="text" class="form-control text-center inputValue noborder-input">');
|
|
input3.attr({ id: 'col3_' + globalRowIndex, name: 'col3_' + globalRowIndex })
|
|
.val(row.col3 || '');
|
|
td3.append(input3);
|
|
tr.append(td3);
|
|
|
|
// 컬럼 4: col4 로트번호
|
|
var td4 = $('<td class="text-center"></td>');
|
|
var input4 = $('<input type="text" class="form-control text-center inputValue noborder-input">');
|
|
input4.attr({ id: 'col4_' + globalRowIndex, name: 'col4_' + globalRowIndex })
|
|
.val(lotNum || '');
|
|
td4.append(input4);
|
|
tr.append(td4);
|
|
|
|
// 컬럼 5: beforeWidth (col8)
|
|
var td5 = $('<td class="text-center"></td>');
|
|
var input5 = $('<input type="text" class="form-control text-center beforeWidth noborder-input">');
|
|
input5.attr({ id: 'col8_' + globalRowIndex, name: 'col8_' + globalRowIndex })
|
|
.val(row.col8 || '');
|
|
td5.append(input5);
|
|
tr.append(td5);
|
|
|
|
// 컬럼 6: beforeHeight (col9)
|
|
var td6 = $('<td class="text-center"></td>');
|
|
var input6 = $('<input type="text" class="form-control text-center beforeHeight noborder-input">');
|
|
input6.attr({ id: 'col9_' + globalRowIndex, name: 'col9_' + globalRowIndex })
|
|
.val(row.col9 || '');
|
|
td6.append(input6);
|
|
tr.append(td6);
|
|
|
|
// 컬럼 7: afterWidth (예, col8 동일)
|
|
var td7 = $('<td class="text-center"></td>');
|
|
var input7 = $('<input type="text" class="form-control text-center afterWidth noborder-input">');
|
|
input7.attr({ id: 'col8_plus_' + globalRowIndex, name: 'col8_plus_' + globalRowIndex })
|
|
.val(row.col8 || '');
|
|
td7.append(input7);
|
|
tr.append(td7);
|
|
|
|
// 컬럼 8: afterHeight (예, col 동일)
|
|
var td8 = $('<td class="text-center"></td>');
|
|
var input8 = $('<input type="text" class="form-control text-center afterHeight noborder-input">');
|
|
input8.attr({ id: 'col9_plus_' + globalRowIndex, name: 'col9_plus_' + globalRowIndex })
|
|
.val(row.col9 || '');
|
|
td8.append(input8);
|
|
tr.append(td8);
|
|
|
|
// 컬럼 9: exceptCheck (체크박스)
|
|
var td9 = $('<td class="text-center"></td>');
|
|
var checkbox = $('<input type="checkbox" class="exceptCheck" value="1">');
|
|
checkbox.attr({ id: 'exceptCheck' + globalRowIndex, name: 'exceptCheck' + globalRowIndex });
|
|
if (row.exceptCheck === '1' || row.exceptCheck === 1) {
|
|
checkbox.prop('checked', true);
|
|
}
|
|
td9.append(checkbox);
|
|
tr.append(td9);
|
|
|
|
// 컬럼 10: recordComent
|
|
var td10 = $('<td class="text-center"></td>');
|
|
var input10 = $('<input type="text" class="form-control text-center recordComent noborder-input">');
|
|
input10.attr({ id: 'changeComent_' + globalRowIndex, name: 'changeComent_' + globalRowIndex })
|
|
.val(row.recordComent || '');
|
|
td10.append(input10);
|
|
tr.append(td10);
|
|
|
|
tbody.append(tr);
|
|
globalRowIndex++;
|
|
});
|
|
}
|
|
});
|
|
} // end of Jsoncreation 일때
|
|
else { // 기존 자료가 있을때
|
|
|
|
Object.keys(lotData).forEach((key) => {
|
|
const classData = lotData[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}번째 요소가 입력 가능하지 않음.`);
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
var numRows = (lotData.beforeWidth && Array.isArray(lotData.beforeWidth)) ? lotData.beforeWidth.length : 0;
|
|
|
|
|
|
// 유틸리티 함수: inputValue 배열에서 특정 필드(id 접미사와 행 인덱스에 해당하는)를 찾아 반환
|
|
function getInputValue(field, rowIndex) {
|
|
var arr = lotData.inputValue || [];
|
|
for (var j = 0; j < arr.length; j++) {
|
|
if (arr[j].id === field + "_" + rowIndex) {
|
|
return arr[j].value;
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
|
|
for (var i = 0; i < numRows; i++) {
|
|
var tr = $("<tr></tr>");
|
|
|
|
// 컬럼 1: col1 (읽기 전용; 없으면 행 번호)
|
|
var td1 = $('<td class="text-center"></td>');
|
|
var input1 = $('<input type="text" class="form-control text-center inputValue noborder-input" readonly>');
|
|
input1.attr({ id: 'col1_' + i, name: 'col1_' + i })
|
|
.val(getInputValue("col1", i) || (i+1));
|
|
td1.append(input1);
|
|
tr.append(td1);
|
|
|
|
// 컬럼 2: col2
|
|
var td2 = $('<td class="text-center"></td>');
|
|
var input2 = $('<input type="text" class="form-control text-center inputValue noborder-input">');
|
|
input2.attr({ id: 'col2_' + i, name: 'col2_' + i })
|
|
.val(getInputValue("col2", i));
|
|
td2.append(input2);
|
|
tr.append(td2);
|
|
|
|
// 컬럼 3: col3
|
|
var td3 = $('<td class="text-center"></td>');
|
|
var input3 = $('<input type="text" class="form-control text-center inputValue noborder-input">');
|
|
input3.attr({ id: 'col3_' + i, name: 'col3_' + i })
|
|
.val(getInputValue("col3", i));
|
|
td3.append(input3);
|
|
tr.append(td3);
|
|
|
|
// 컬럼 4: col4 (lotNum)
|
|
var td4 = $('<td class="text-center"></td>');
|
|
var input4 = $('<input type="text" class="form-control text-center inputValue noborder-input">');
|
|
input4.attr({ id: 'col4_' + i, name: 'col4_' + i })
|
|
.val(getInputValue("col4", i));
|
|
td4.append(input4);
|
|
tr.append(td4);
|
|
|
|
// 컬럼 5: beforeWidth (from lotData.beforeWidth)
|
|
var td5 = $('<td class="text-center"></td>');
|
|
var input5 = $('<input type="text" class="form-control text-center beforeWidth noborder-input">');
|
|
input5.attr({ id: 'col8_' + i, name: 'col8_' + i })
|
|
.val(lotData.beforeWidth && lotData.beforeWidth[i] ? lotData.beforeWidth[i].value : '');
|
|
td5.append(input5);
|
|
tr.append(td5);
|
|
|
|
// 컬럼 6: beforeHeight (from lotData.beforeHeight)
|
|
var td6 = $('<td class="text-center"></td>');
|
|
var input6 = $('<input type="text" class="form-control text-center beforeHeight noborder-input">');
|
|
input6.attr({ id: 'col9_' + i, name: 'col9_' + i })
|
|
.val(lotData.beforeHeight && lotData.beforeHeight[i] ? lotData.beforeHeight[i].value : '');
|
|
td6.append(input6);
|
|
tr.append(td6);
|
|
|
|
// 컬럼 7: afterWidth (from lotData.afterWidth)
|
|
var td7 = $('<td class="text-center"></td>');
|
|
var input7 = $('<input type="text" class="form-control text-center afterWidth noborder-input">');
|
|
input7.attr({ id: 'col8_plus_' + i, name: 'col8_plus_' + i })
|
|
.val(lotData.afterWidth && lotData.afterWidth[i] ? lotData.afterWidth[i].value : '');
|
|
td7.append(input7);
|
|
tr.append(td7);
|
|
|
|
// 컬럼 8: afterHeight (from lotData.afterHeight)
|
|
var td8 = $('<td class="text-center"></td>');
|
|
var input8 = $('<input type="text" class="form-control text-center afterHeight noborder-input">');
|
|
input8.attr({ id: 'col9_plus_' + i, name: 'col9_plus_' + i })
|
|
.val(lotData.afterHeight && lotData.afterHeight[i] ? lotData.afterHeight[i].value : '');
|
|
td8.append(input8);
|
|
tr.append(td8);
|
|
|
|
// 컬럼 9: exceptCheck (from lotData.exceptCheck)
|
|
var td9 = $('<td class="text-center"></td>');
|
|
var checkbox = $('<input type="checkbox" class="exceptCheck" value="1">');
|
|
checkbox.attr({ id: 'exceptCheck' + i, name: 'exceptCheck' + i });
|
|
if (lotData.exceptCheck && lotData.exceptCheck[i] && (lotData.exceptCheck[i] === "1" || lotData.exceptCheck[i] === 1)) {
|
|
checkbox.prop('checked', true);
|
|
}
|
|
td9.append(checkbox);
|
|
tr.append(td9);
|
|
|
|
// 컬럼 10: recordComent (from lotData.recordComent)
|
|
var td10 = $('<td class="text-center"></td>');
|
|
var input10 = $('<input type="text" class="form-control text-center recordComent noborder-input">');
|
|
input10.attr({ id: 'changeComent_' + i, name: 'changeComent_' + i })
|
|
.val(lotData.recordComent && lotData.recordComent[i] ? lotData.recordComent[i].value : '');
|
|
td10.append(input10);
|
|
tr.append(td10);
|
|
|
|
tbody.append(tr);
|
|
}
|
|
|
|
|
|
} // end of Jsoncreation 아닐때
|
|
|
|
});
|
|
|
|
// 초기화작업
|
|
$(document).ready(function () {
|
|
$('.initialBtn').on('click', function () {
|
|
console.log('groupCode', $('#groupCode').val() );
|
|
Swal.fire({
|
|
title: '초기화',
|
|
text: "모든 데이터를 초기화하시겠습니까? (JSON 파일이 삭제됩니다)",
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonColor: '#3085d6',
|
|
cancelButtonColor: '#d33',
|
|
confirmButtonText: '예, 초기화합니다',
|
|
cancelButtonText: '취소'
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
$.ajax({
|
|
url: '/output/delete_json.php', // JSON 삭제를 위한 PHP 스크립트 경로
|
|
type: 'POST',
|
|
data: {
|
|
groupCode: $('#groupCode').val() // 필요 시 전송
|
|
},
|
|
success: function (response) {
|
|
console.log(response);
|
|
Swal.fire({
|
|
title: '초기화 완료',
|
|
text: "JSON 파일이 삭제되었습니다.",
|
|
icon: 'success',
|
|
confirmButtonText: '확인'
|
|
}).then(() => {
|
|
location.reload();
|
|
});
|
|
},
|
|
error: function (jqxhr, status, error) {
|
|
Swal.fire({
|
|
title: '오류',
|
|
text: "JSON 파일 삭제 중 오류가 발생했습니다.",
|
|
icon: 'error',
|
|
confirmButtonText: '확인'
|
|
});
|
|
console.log("AJAX Error: ", status, error);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
});
|
|
});
|
|
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|