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

1662 lines
56 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
$title_message = '절곡품 재고생산 작업일지 및 중간검사성적서';
$tablename = 'lot';
$item ='절곡품재고_중간검사성적서';
include $_SERVER['DOCUMENT_ROOT'] . '/load_header.php';
// 출고담당자관리자 명단
$QCadmin = false ;
if($user_name=='이세희' || $user_name=='개발자' || $user_name=='함신옥' || $user_name=='이경호' || $user_name=='노완호' )
$QCadmin = true ;
?>
<title> <?=$title_message?> </title>
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/sheet.css">
</head>
<body>
<?php
// JavaScript에서 전달된 변수들 받기
$num = isset($_REQUEST['num']) ? $_REQUEST['num'] : '';
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";
// $korean = number_to_korean($totalprice);
}
} catch (PDOException $Exception) {
print "오류: " . $Exception->getMessage();
}
// 제품 코드, 종류 코드, 날짜 코드, 모양&길이 코드의 의미를 매핑한 배열
$prodNames = [
'R' => '가이드레일(벽면형)',
'S' => '가이드레일(측면형)',
'G' => '연기차단재',
'B' => '하단마감재(스크린)',
'T' => '하단마감재(철재)',
'L' => 'L - Bar',
'C' => '케이스'
];
$specNames = [
'I' => '화이바원단',
'S' => 'SUS(마감)',
'U' => 'SUS(마감)2',
'E' => 'EGI(마감)',
'A' => '스크린용',
'D' => 'D형',
'C' => 'C형',
'M' => '본체',
'T' => '본체(철재)',
'B' => '후면코너부',
'L' => '린텔부',
'P' => '점검구',
'F' => '전면부'
];
$slengthNames = [
'53' => 'W50 × 3000',
'54' => 'W50 × 4000',
'83' => 'W80 × 3000',
'84' => 'W80 × 4000',
'12' => '1219',
'24' => '2438',
'30' => '3000',
'35' => '3500',
'40' => '4000',
'41' => '4150',
'42' => '4200',
'43' => '4300'
];
// 1. 제품 코드 추출 (첫 번째 글자)
$prodCode = substr($lot_number, 0, 1);
$prodName = isset($prodNames[$prodCode]) ? $prodNames[$prodCode] : "Unknown";
// 2. 종류 코드 추출 (두 번째 글자)
$specCode = substr($lot_number, 1, 1);
$specName = isset($specNames[$specCode]) ? $specNames[$specCode] : "Unknown";
// 앞자리 두문자로 소재 추정
$materialRaw = $prodCode . $specCode ;
// 3. 날짜 코드 추출 (세 번째부터 다섯 번째 문자)
$dateCode = substr($lot_number, 2, 4);
// 연도, 월, 일을 추출하여 해석
$yearCode = substr($dateCode, 0, 1);
$monthCode = substr($dateCode, 1, 1);
$dayCode = substr($dateCode, 2, 2);
// 연도와 월 코드 해석
$year = 2020 + intval($yearCode); // 예: 4 -> 2024
$month = is_numeric($monthCode) ? intval($monthCode) : ord($monthCode) - 55; // A = 10, B = 11, C = 12
$day = intval($dayCode);
$date = "{$year}년 {$month}월 {$day}일";
// 4. 모양&길이 코드 추출 (하이픈 이후 코드)
$slengthCode = substr($lot_number, -2);
$slength = isset($slengthNames[$slengthCode]) ? $slengthNames[$slengthCode] : "Unknown";
$formattedNumberCode = null;
// 연기차단재 표현에 대한 처리부분
// $slength가 숫자만으로 구성된 경우와 아닌 경우를 검사
if (is_numeric($slength)) {
// 숫자일 경우 number_format을 적용하여 출력
$formattedNumber = $slength;
} else {
// 숫자가 아닐 경우, 텍스트와 숫자 부분을 분리하여 처리
preg_match('/\d+$/', $slength, $matches); // 마지막 숫자 추출
$numericValue = isset($matches[0]) ? (int)$matches[0] : null;
// 텍스트 형식 그대로 출력할 변수
$displayText = $slength;
// 숫자 부분만 포맷팅할 변수
$formattedNumber = is_numeric($numericValue) ? $numericValue : '';
}
// 결과 출력
$result = [
"제품 코드" => "$prodCode: $prodName",
"종류 코드" => "$specCode: $specName",
"날짜 코드" => "$dateCode: $date",
"모양&길이 코드" => "$formattedNumberCode: $formattedNumber"
];
// print_r($result);
switch ($materialRaw) {
case 'CF':
case 'CP':
case 'CL':
case 'CB':
case 'LA':
case 'RM':
case 'RT':
case 'RC':
case 'RD':
case 'ST':
case 'SC':
case 'SD':
case 'GI':
case 'BE':
case 'TE':
case 'SM':
$material = 'EGI 1.55T';
$code ="E155";
break;
case 'RS':
case 'SS':
case 'SU':
case 'BS':
case 'TS':
$material = 'SUS 1.2T';
$code ="S12";
break;
}
$subSpec = '';
//재질 설정
switch ($materialRaw) {
case 'CF':
case 'CP':
case 'CL':
case 'CB':
case 'LA':
case 'RM':
case 'RT':
case 'RC':
case 'RD':
case 'ST':
case 'SC':
case 'SD':
case 'GI':
case 'BE':
case 'TE':
case 'SM':
$subSpec = '(W576)';
break;
case 'RS':
case 'SS':
case 'SU':
case 'BS':
case 'TS':
$material = 'SUS 1.2T';
break;
}
//이미지 이름 설정
switch ($materialRaw) {
case 'CF':
case 'CP':
case 'CL':
case 'CB':
$imgName = 'CF';
break;
case 'RM':
case 'RC':
case 'RD':
case 'RS':
$imgName = 'RM';
break;
case 'RT':
$imgName = 'RT';
break;
case 'SM':
case 'SC':
case 'SD':
case 'SS':
case 'SU':
$imgName = 'SM';
break;
case 'ST':
$imgName = 'ST';
break;
case 'LA':
$imgName = 'LA';
break;
case 'GI':
$imgName = 'GI';
break;
case 'BE':
case 'BS':
$imgName = 'BS';
break;
case 'TE':
case 'TS':
$imgName = 'TS';
break;
}
//품명명별 배열설정
switch ($materialRaw) {
case 'CF':
$data = [
[
'KDPS' => 'KDPS-20',
'품명' => $prodName . '-' . $specName,
'길이' => [
['도면치수' => $formattedNumber, '측정값' => null]
],
'너비' => [
['도면치수' => 'N/A', '측정값' => 'N/A']
],
'간격' => [
['POINT' => '①', '도면치수' => 380, '측정값' => null]
],
'판정' => null, // 적합 여부 (적/부)
]
];
break;
case 'CP':
$data = [
[
'KDPS' => 'KDPS-20',
'품명' => $prodName . '-' . $specName,
'길이' => [
['도면치수' => $formattedNumber, '측정값' => null]
],
'너비' => [
['도면치수' => 'N/A', '측정값' => 'N/A']
],
'간격' => [
['POINT' => '③', '도면치수' => 240, '측정값' => null]
],
'판정' => null, // 적합 여부 (적/부)
]
];
break;
case 'CL':
$data = [
[
'KDPS' => 'KDPS-20',
'품명' => $prodName . '-' . $specName,
'길이' => [
['도면치수' => $formattedNumber, '측정값' => null]
],
'너비' => [
['도면치수' => 'N/A', '측정값' => 'N/A']
],
'간격' => [
['POINT' => '②', '도면치수' => 50, '측정값' => null]
],
'판정' => null, // 적합 여부 (적/부)
]
];
break;
case 'CB':
$data = [
[
'KDPS' => 'KDPS-20',
'품명' => $prodName . '-' . $specName,
'길이' => [
['도면치수' => $formattedNumber, '측정값' => null]
],
'너비' => [
['도면치수' => 'N/A', '측정값' => 'N/A']
],
'간격' => [
['POINT' => '④', '도면치수' => 50, '측정값' => null]
],
'판정' => null, // 적합 여부 (적/부)
]
];
break;
case 'RM':
$data = [
[
'KDPS' => 'KDPS-12',
'품명' => $prodName . '-' . $specName,
'길이' => [
['도면치수' => $formattedNumber, '측정값' => null]
],
'너비' => [
['도면치수' => 'N/A', '측정값' => 'N/A']
],
'간격' => [
['POINT' => '②', '도면치수' => 80, '측정값' => null],
],
'판정' => null, // 적합 여부 (적/부)
]
];
break;
case 'RC':
$data = [
[
'KDPS' => 'KDPS-12',
'품명' => $prodName . '-' . $specName,
'길이' => [
['도면치수' => $formattedNumber, '측정값' => null]
],
'너비' => [
['도면치수' => 'N/A', '측정값' => 'N/A']
],
'간격' => [
['POINT' => '③', '도면치수' => 45, '측정값' => null],
],
'판정' => null, // 적합 여부 (적/부)
]
];
break;
case 'RD':
$data = [
[
'KDPS' => '',
'품명' => $prodName . '-' . $specName,
'길이' => [
['도면치수' => $formattedNumber, '측정값' => null]
],
'너비' => [
['도면치수' => 'N/A', '측정값' => 'N/A']
],
'간격' => [
['POINT' => '④', '도면치수' => 40, '측정값' => null],
],
'판정' => null, // 적합 여부 (적/부)
]
];
break;
case 'RS':
$data = [
[
'KDPS' => '',
'품명' => $prodName . '-' . $specName,
'길이' => [
['도면치수' => $formattedNumber ]
],
'너비' => [
['도면치수' => 'N/A', '측정값' => 'N/A']
],
'간격' => [
['POINT' => '(1)', '도면치수' => 30, '측정값' => null]
]
]
];
break;
case 'ST':
$data = [
[
'KDPS' => 'KDPS-26',
'품명' => $prodName . '-' . $specName,
'길이' => [
['도면치수' => $formattedNumber, '측정값' => null]
],
'너비' => [
['도면치수' => 'N/A', '측정값' => 'N/A']
],
'간격' => [
['POINT' => '①', '도면치수' => 30, '측정값' => null],
['POINT' => '②', '도면치수' => 78, '측정값' => null],
// ['POINT' => '③', '도면치수' => 45, '측정값' => null],
// ['POINT' => '④', '도면치수' => 40, '측정값' => null],
// ['POINT' => '⑤', '도면치수' => 34, '측정값' => '없음']
],
'판정' => null, // 적합 여부 (적/부)
]
];
break;
case 'RT':
$data = [
[
'KDPS' => 'KDPS-25',
'품명' => $prodName . '-' . $specName,
'길이' => [
['도면치수' => $formattedNumber, '측정값' => null]
],
'너비' => [
['도면치수' => 'N/A', '측정값' => 'N/A']
],
'간격' => [
['POINT' => '①', '도면치수' => 30, '측정값' => null],
['POINT' => '②', '도면치수' => 78, '측정값' => null],
// ['POINT' => '③', '도면치수' => 45, '측정값' => null],
// ['POINT' => '④', '도면치수' => 40, '측정값' => null],
// ['POINT' => '⑤', '도면치수' => 34, '측정값' => '없음']
],
'판정' => null, // 적합 여부 (적/부)
]
];
break;
case 'SM':
$data = [
[
'KDPS' => 'KDPS-28',
'품명' => $prodName . '-' . $specName,
'길이' => [
['도면치수' => $formattedNumber, '측정값' => null]
],
'너비' => [
['도면치수' => 'N/A', '측정값' => 'N/A']
],
'간격' => [
['POINT' => '④', '도면치수' => 35, '측정값' => null],
// ['POINT' => '②', '도면치수' => 80, '측정값' => null],
// ['POINT' => '③', '도면치수' => 45, '측정값' => null],
// ['POINT' => '④', '도면치수' => 40, '측정값' => null],
// ['POINT' => '⑤', '도면치수' => 34, '측정값' => '없음']
],
'판정' => null, // 적합 여부 (적/부)
]
];
break;
case 'SC':
$data = [
[
'KDPS' => 'KDPS-28',
'품명' => $prodName . '-' . $specName,
'길이' => [
['도면치수' => $formattedNumber, '측정값' => null]
],
'너비' => [
['도면치수' => 'N/A', '측정값' => 'N/A']
],
'간격' => [
['POINT' => '⑤', '도면치수' => 95, '측정값' => null],
// ['POINT' => '②', '도면치수' => 80, '측정값' => null],
// ['POINT' => '③', '도면치수' => 45, '측정값' => null],
// ['POINT' => '④', '도면치수' => 40, '측정값' => null],
// ['POINT' => '⑤', '도면치수' => 34, '측정값' => '없음']
],
'판정' => null, // 적합 여부 (적/부)
]
];
break;
case 'SD':
$data = [
[
'KDPS' => 'KDPS-28',
'품명' => $prodName . '-' . $specName,
'길이' => [
['도면치수' => $formattedNumber, '측정값' => null]
],
'너비' => [
['도면치수' => 'N/A', '측정값' => 'N/A']
],
'간격' => [
['POINT' => '⑥', '도면치수' => 90, '측정값' => null],
// ['POINT' => '②', '도면치수' => 80, '측정값' => null],
// ['POINT' => '③', '도면치수' => 45, '측정값' => null],
// ['POINT' => '④', '도면치수' => 40, '측정값' => null],
// ['POINT' => '⑤', '도면치수' => 34, '측정값' => '없음']
],
'판정' => null, // 적합 여부 (적/부)
]
];
break;
case 'SS':
$data = [
[
'KDPS' => 'KDPS-28',
'품명' => $prodName . '-' . $specName,
'길이' => [
['도면치수' => $formattedNumber ]
],
'너비' => [
['도면치수' => 'N/A', '측정값' => 'N/A']
],
'간격' => [
['POINT' => '(1)', '도면치수' => 30, '측정값' => null]
]
]
];
case 'SU':
$data = [
[
'KDPS' => 'KDPS-28',
'품명' => $prodName . '-' . $specName,
'길이' => [
['도면치수' => $formattedNumber ]
],
'너비' => [
['도면치수' => 'N/A', '측정값' => 'N/A']
],
'간격' => [
['POINT' => '(2)', '도면치수' => 70, '측정값' => null]
]
]
];
break;
case 'LA':
$data = [
[
'KDPS' => 'KDPS-24',
'품명' => $prodName . '-' . $specName,
'길이' => [
['도면치수' => $formattedNumber, '측정값' => null]
],
'너비' => [
['도면치수' => 'N/A', '측정값' => 'N/A']
],
'간격' => [
['POINT' => '(1)', '도면치수' => 17, '측정값' => null],
['POINT' => '(2)', '도면치수' => 600, '측정값' => null],
],
'판정' => null, // 적합 여부 (적/부)
]
];
break;
case 'GI':
$data = [
[
'KDPS' => 'KDPS-22',
'품명' => $prodName . '-' . $specName,
'길이' => [
['도면치수' => $formattedNumber, '측정값' => null]
],
'너비' => [
['도면치수' => 50, '측정값' => null ]
],
'간격' => [
['POINT' => '②', '도면치수' => 12, '측정값' => null],
// ['POINT' => '②', '도면치수' => 600, '측정값' => null],
// ['POINT' => '③', '도면치수' => 45, '측정값' => null],
// ['POINT' => '④', '도면치수' => 40, '측정값' => null],
// ['POINT' => '⑤', '도면치수' => 34, '측정값' => '없음']
],
'판정' => null, // 적합 여부 (적/부)
]
];
// 끝 두 문자 추출
$lastTwoChars = substr($lot_number, -2);
if ($lastTwoChars == '83') {
// 조건이 일치하면 '너비'의 '도면치수' 값을 80으로 변경
$data[0]['너비'][0]['도면치수'] = 80;
}
break;
case 'BE':
case 'BS':
$data = [
[
'KDPS' => 'KDPS-17',
'품명' => $prodName . '-' . $specName,
'길이' => [
['도면치수' => $formattedNumber, '측정값' => null]
],
'너비' => [
['도면치수' => 'N/A', '측정값' => 'N/A']
],
'간격' => [
['POINT' => '(1)', '도면치수' => 60, '측정값' => null],
// ['POINT' => '②', '도면치수' => 80, '측정값' => null],
// ['POINT' => '③', '도면치수' => 45, '측정값' => null],
// ['POINT' => '④', '도면치수' => 40, '측정값' => null],
// ['POINT' => '⑤', '도면치수' => 34, '측정값' => '없음']
],
'판정' => null, // 적합 여부 (적/부)
]
];
break;
case 'TE':
case 'TS':
$data = [
[
'KDPS' => 'KDPS-29',
'품명' => $prodName . '-' . $specName,
'길이' => [
['도면치수' => $formattedNumber, '측정값' => null]
],
'너비' => [
['도면치수' => 'N/A', '측정값' => 'N/A']
],
'간격' => [
['POINT' => '(1)', '도면치수' => 60, '측정값' => null],
// ['POINT' => '②', '도면치수' => 80, '측정값' => null],
// ['POINT' => '③', '도면치수' => 45, '측정값' => null],
// ['POINT' => '④', '도면치수' => 40, '측정값' => null],
// ['POINT' => '⑤', '도면치수' => 34, '측정값' => '없음']
],
'판정' => null, // 적합 여부 (적/부)
]
];
break;
}
// 결과 확인
// echo "<pre>";
// print_r($result);
// echo "</pre>";
$author = isset($author) ? $author : $user_name ; // 작성자
$recordsheet = isset($recordsheet) ? json_decode($recordsheet, true) : [];
// print_r($recordsheet);
// JSON 데이터를 JavaScript 변수로 변환
echo "<script>";
echo "var recordsheetData = " . json_encode($recordsheet) . ";";
echo "</script>";
$indateStr = date("m/d", strtotime($reg_date));
$todayStr = date("m/d");
$inspectdate = date("Y-m-d");
?>
<style>
/* 기본 스타일 설정 */
input[type="checkbox"] {
transform: scale(1.0); /* 크기 확대 */
margin: 3px; /* 여백 추가 */
}
#inspectionTable table, th, td {
font-size: 11px!important;
padding:2!important;
}
.blueBoldBackground {
background-color: #e0f7f1!important; /* 옅은 파란색 배경 */
font-weight: bold; /* 굵은 텍스트 */
}
</style>
<div class="container mt-2">
<div class="modal fade" id="lotModal_bending" tabindex="-1" aria-labelledby="lotModalLabel" aria-hidden="true">
<div class="modal-dialog modal-full">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="lotModalLabel">원자재 로트번호</h5>
<button type="button" class="btn-close cancelBtn" aria-label="Close"></button>
</div>
<div class="modal-body">
<ul class="nav nav-tabs" id="lotTabs" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="material-tab" data-bs-toggle="tab" data-bs-target="#material" type="button" role="tab" aria-controls="material" aria-selected="false">원자재</button>
</li>
</ul>
<div class="tab-content" id="lotTabContent">
<div class="tab-pane fade show active" id="material" role="tabpanel" aria-labelledby="material-tab">
<!-- 원자재 로트번호 목록 -->
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary btn-sm nullBtn_bending">공백 삽입</button>
<button type="button" class="btn btn-secondary btn-sm cancelBtn">취소</button>
</div>
</div>
</div>
</div>
<div class="d-flex align-items-center justify-content-end mt-1 m-1">
<button type="button" class="btn btn-danger btn-sm me-1 ms-1 initialBtn" > <i class="bi bi-trash3-fill"></i> 초기화 </button>
<button type="button" class="btn btn-dark btn-sm me-1 ms-1 saveData" > <i class="bi bi-save"> </i> 서버 저장 </button>
<button type="button" class="btn btn-dark btn-sm me-1" onclick="generatePDF()"> PDF 저장 </button>
<button type="button" class="btn btn-secondary btn-sm" onclick="self.close();"> <i class="bi bi-x-lg"></i> 닫기 </button>&nbsp;
</div>
</div>
<form id="board_form" name="board_form" method="post" enctype="multipart/form-data" onkeydown="return captureReturnKey(event)" >
<input type="hidden" id="mode" name="mode" value="<?= isset($mode) ? $mode : '' ?>">
<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="tablename" name="tablename" value="<?= isset($tablename) ? $tablename : '' ?>">
<input type="hidden" id="item_name" name="item_name" value="<?= isset($item_name) ? $item_name : '' ?>">
<input type="hidden" id="recordsheet" name="recordsheet">
<div id="content-to-print">
<br>
<div class="container mt-3">
<div class="row">
<div class="d-flex align-items-center justify-content-center">
<table class="table " style="border-collapse: collapse;">
<thead>
<tr>
<th rowspan="3" class="text-center" style="width:70%;">
<div class="row">
<div class="col-sm-2">
<img src="../img/kdlogo.png" alt="경동기업" class="me-1" style="width:100%; 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-2" > 절곡품 재고생산 작업일지 </span>
</div>
<div class="d-flex align-items-center justify-content-center m-1">
<span class="text-dark ms-2 me-2 fs-5" > 중간검사성적서</span>
</div>
<br>
</div>
</div>
</th>
<th rowspan="3" class="text-center fw-bold" style="width:30px; height:100px;">결 <br> <br> 재</th>
<th class="text-center p-1 clickable" style="width : 70px; height:22px; padding:2px; cursor:pointer;" id="writer">작성</th>
<th class="text-center p-1 clickable" style="width : 70px; height:22px; padding:2px; cursor:pointer;" id="reviewer">검토</th>
<th class="text-center p-1 clickable approval-only" style="width : 90px; height:22px; padding:2px; cursor:pointer;" id="approver">승인</th>
</tr>
<tr style="height:40px;">
<th class="text-center" id="writerDisplay"></th>
<th class="text-center" id="reviewerDisplay"></th>
<th class="text-center" id="approvalDisplay"></th>
</tr>
<tr>
<th class="text-center" style="height:22px; padding:2px;">판매/<?=$author?></th>
<th class="text-center" style="height:22px; padding:2px;">생산</th>
<th class="text-center text-primary fw-bold" style="height:22px; padding:2px;">품질</th>
</tr>
</thead>
</table>
</div>
</div>
<div class="row">
<div class="d-flex align-items-center justify-content-center">
<table class="table table-bordered mainTable" style="border-collapse: collapse;">
<thead>
<tr>
<th class="text-center align-middle ">품명</th>
<th class="text-center " colspan="3" > <?=$prodName?> - <?=$specName?></th>
<th class="text-center align-middle blueBoldBackground">생산 LOT NO</th>
<th class="text-center fw-bold blueBoldBackground text-primary"><?=$lot_number?></th>
</tr>
<tr>
<th class="text-center align-middle "> 규격 </th>
<th class="text-center" colspan="3" > <?=$material?> <?=$subSpec?> </th>
<th class="text-center align-middle ">로트크기 </th>
<th colspan="1" class="text-center text-dark fw-bold"> <?=$surang ?> &nbsp; &nbsp; EA </th>
</tr>
<tr>
<th class="text-center align-middle ">길이</th>
<th colspan="3" class="text-center text-dark fw-bold">
<?= is_numeric($slength) ? number_format($slength) : $slength; ?>
</th>
<th class="text-center align-middle ">검사일자</th>
<th class="text-center"> <input type="date" id="inspectdate" name="inspectdate" class="form-control inputValue" value="<?= isset($inspectdate) ? $inspectdate : '' ?>" > </th>
</tr>
<tr>
<th class="text-center align-middle yellowBold"> 입고 LOT NO </th>
<?php
// echo '<th class="text-center w160px yellowblackBold"><input type="text" class="form-control text-center noborder-input lotnumInput inputValue" data-itemname="' . $code . '" data-usesurang="' . $surang . '" name="lotnum_side[]" /></th>';
// 연기차단재는 원자재와 원단번호가 나와야 한다.
if($imgName !== 'GI') {
echo '<th class="text-center w160px yellowblackBold" colspan="3" > ' . $rawLot . '</th>';
}
else
{
echo '<th class="text-center yellowblackBold" colspan="1" > ' . $rawLot . '</th>';
echo '<th class="text-center yellowblackBold" colspan="1" > ' . '원단' . '</th>';
echo '<th class="text-center yellowblackBold" colspan="1" > ' . $fabric_lot . '</th>';
}
?>
<th class="text-center align-middle ">검사자</th>
<th class="text-center" > <input type="text" class="form-control text-center inputValue noborder-input" id="reviewer_sub" name="reviewer_sub" > </th>
</tr>
</thead>
</table>
</div>
</div>
<div class="row">
<div class="d-flex align-items-center justify-content-center">
<table class="table " style="border-collapse: collapse;">
<tbody>
<tr>
<td rowspan="2" class="text-center align-middle orangeBlackBold ">중간 검사 <br> 기준서 <br> <?=htmlspecialchars($data[0]['KDPS']) ?> </td>
<td rowspan="2" class="text-center align-middle "> <?=$prodName?> <br> <?=$specName?> </td>
<td class="text-center align-middle"> <img src="../img/bendinggoods/<?=$imgName?>.jpg" alt="중간검사성적서" style="width:auto; height:auto;"> </td>
</tr>
<tr>
<td class="text-center align-middle"> <img src="../img/inspection/bending_inspection1.jpg" alt="중간검사" style="width:90%; height:auto;"> </td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="d-flex align-items-center justify-content-center ">
<table class="table mainTable" style="border-collapse: collapse;" style="padding:0;">
<thead>
<tr>
<th rowspan="4" class="text-center align-middle"> <span id="allclick"> NO </span> </th>
<th rowspan="4" class="text-center align-middle">품명</th>
<th colspan="8" class="text-center align-middle orangeBlackBold"> 중간검사 DATA</th>
<th rowspan="4" class="text-center align-middle">판정 <br> (적/부) </th>
</tr>
<tr>
<th colspan="1" class="text-center align-middle orangeBlackBold"> 겉모양 </th>
<th colspan="7" class="text-center align-middle orangeBlackBold"> 치수(mm) </th>
</tr>
<tr>
<th rowspan="2" class="text-center align-middle orangeBlackBold"> 절곡상태 </th>
<th colspan="2" class="text-center align-middle orangeBlackBold"> 길이 </th>
<th colspan="2" class="text-center align-middle orangeBlackBold"> 너비 </th>
<th colspan="3" class="text-center align-middle orangeBlackBold"> 간격 </th>
</tr>
<tr>
<th class="text-center align-middle orangeBlackBold"> 도면치수 </th>
<th class="text-center align-middle orangeBlackBold"> 측정값 </th>
<th class="text-center align-middle orangeBlackBold"> 도면치수 </th>
<th class="text-center align-middle orangeBlackBold"> 측정값 </th>
<th class="text-center align-middle orangeBlackBold"> POINT </th>
<th class="text-center align-middle orangeBlackBold"> 도면치수 </th>
<th class="text-center align-middle orangeBlackBold"> 측정값 </th>
</tr>
</thead>
<tbody>
<?php
foreach ($data as $index => $item) {
$rowspan = count($item['간격']); // 간격 항목의 개수를 기준으로 rowspan 설정
// 첫 번째 행 출력
echo '<tr class="gap-row">'; // 각 간격 행에만 gap-row 클래스 적용
echo '<td rowspan="' . $rowspan . '" class="text-center">' . ($index + 1) . '</td>';
echo '<td rowspan="' . $rowspan . '" class="text-center">' . htmlspecialchars($item['품명']) . '</td>';
// 양호/불량 체크박스 (rowspan 적용)
echo '<td rowspan="' . $rowspan . '" class="text-center">';
echo '<label>';
echo '<input type="checkbox" class="check-good" name="col1_status_' . $index . '_good" value="양호"> 양호';
echo '</label>';
echo '<label>';
echo '<input type="checkbox" class="check-bad" name="col1_status_' . $index . '_bad" value="불량"> 불량';
echo '</label>';
echo '</td>';
// 길이 데이터 (rowspan 적용)
echo '<td rowspan="' . $rowspan . '" class="text-center lengthdwg fw-bold text-primary ">' . htmlspecialchars($item['길이'][0]['도면치수']) . '</td>';
echo '<td rowspan="' . $rowspan . '" class="text-center">';
echo '<input type="text" name="lengthMeasurement[]" class="form-control noborder-input text-center inputValue SpecialinputValue" >';
echo '</td>';
// 너비 데이터 (rowspan 적용)
echo '<td rowspan="' . $rowspan . '" class="text-center widthdwg fw-bold text-primary ">' . htmlspecialchars($item['너비'][0]['도면치수']) . '</td>';
echo '<td rowspan="' . $rowspan . '" class="text-center">';
echo '<input type="text" name="widthMeasurement[]" class="form-control noborder-input text-center inputValue SpecialinputValue" value="' . htmlspecialchars($item['너비'][0]['측정값']) . '">';
echo '</td>';
// 첫 번째 간격 데이터 출력 (첫 행에 표시)
echo '<td class="text-center">' . htmlspecialchars($item['간격'][0]['POINT']) . '</td>';
echo '<td class="text-center fw-bold text-primary gapdwg"> ' . htmlspecialchars($item['간격'][0]['도면치수']) . '</td>';
echo '<td class="text-center">';
echo '<input type="text" name="gapMeasurement[]" class="form-control noborder-input text-center inputValue SpecialinputValue" >';
echo '</td>';
// 판정 셀 (rowspan 적용)
echo '<td rowspan="' . $rowspan . '" class="text-center align-middle judgement"></td>';
echo '</tr>';
// 나머지 간격 데이터 출력
for ($i = 1; $i < count($item['간격']); $i++) {
echo '<tr class="gap-row">'; // 각 간격 행에 gap-row 클래스 적용
echo '<td class="text-center">' . htmlspecialchars($item['간격'][$i]['POINT']) . '</td>';
echo '<td class="text-center fw-bold text-primary gapdwg"> ' . htmlspecialchars($item['간격'][$i]['도면치수']) . '</td>';
echo '<td class="text-center">';
echo '<input type="text" name="gapMeasurement[]" class="form-control noborder-input text-center inputValue SpecialinputValue" >';
echo '</td>';
echo '</tr>';
}
// 부적합 내용란
echo '</tbody>';
echo '<tfoot>';
echo '<tr>';
echo '<td colspan="9" rowspan="4" class="text-start align-top fs-6"> [부적합 내용] <br>';
echo ' <input type="text" name="bending_false_comment" class="form-control inputValue noborder-input text-start" value=""> ';
echo '</td>';
echo '<td colspan="2" rowspan="2" class="text-center yellowredBold fs-6"> 종합판정 <br>';
echo '<input type="text" class="form-control fs-3 text-center inputValue noborder-input" style="height:40px;" id="resultJudgement" name="resultJudgement" value="">';
echo '</td>';
echo '</tr>';
}
echo '</tfoot>';
echo '</table>';
?>
</div>
</div>
</div>
</form>
</div> <!-- end of container -->
<div class="container mb-5 mt-2">
<div class="d-flex align-items-center justify-content-center mb-5">
</div>
</div>
<!-- 페이지로딩 -->
<script>
$(document).ready(function(){
var loader = document.getElementById('loadingOverlay');
if(loader)
loader.style.display = 'none';
});
function generatePDF() {
var workplace = '<?php echo $specCode; ?>';
var deadline = '<?php echo $indateStr; ?>';
var deadlineDate = new Date(deadline);
var formattedDate = "(" + String(deadlineDate.getFullYear()).slice(-2) + "." + ("0" + (deadlineDate.getMonth() + 1)).slice(-2) + "." + ("0" + deadlineDate.getDate()).slice(-2) + ")";
var result = 'KD절곡품_중간검사성적서(' + workplace +')' + formattedDate + '.pdf';
var element = document.getElementById('content-to-print');
var opt = {
margin: [10, 3, 12, 3], // Top, right, bottom, left margins
filename: result,
image: { type: 'jpeg', quality: 0.98 },
html2canvas: { scale: 1 },
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' },
pagebreak: { mode: [''] }
};
html2pdf().from(element).set(opt).save();
}
$(document).on('click', '.saveData', function() {
saveData();
});
// 결재 취소 기능
$(document).on('click', '.remove-approval', function() {
// 승인자 정보를 지우고 화면에서 숨김
$('#approvalDisplay').html('').hide();
// JSON 데이터에서 승인자의 정보 제거
let formData = JSON.parse($('#recordsheet').val() || '[]');
const approvalIndex = formData.findIndex(item => item.approval);
if (approvalIndex !== -1) {
formData[approvalIndex].approval.approver.name = '';
formData[approvalIndex].approval.approver.date = '';
}
// JSON 문자열로 다시 저장
$('#recordsheet').val(JSON.stringify(formData));
Toastify({
text: "승인 정보가 삭제되었습니다.",
duration: 2000,
close: true,
gravity: "top",
position: "center",
style: {
background: "linear-gradient(to right, #ff5f6d, #ffc371)"
},
}).showToast();
saveData();
});
function saveData() {
// 결재 부분 정보 저장
let approvalData = {
writer: {
name: $('#writerDisplay').html().split('<br>')[0] || '',
date: $('#writerDisplay').html().split('<br>')[1] || ''
},
reviewer: {
name: $('#reviewerDisplay').html().split('<br>')[0] || '',
date: $('#reviewerDisplay').html().split('<br>')[1] || ''
},
approver: {
name: $('#approvalDisplay').clone().children('i').remove().end().html().split('<br>')[0] || '',
date: $('#approvalDisplay').clone().children('i').remove().end().html().split('<br>')[1] || ''
}
};
let formData = [];
formData.push({ approval: approvalData });
// Class 'inputValue' 값 저장
let inputValue = {};
$('.inputValue').each(function() {
let inputName = $(this).attr('name');
// 배열 형식의 이름인지 확인 (예: gapMeasurement[])
if (inputName.endsWith('[]')) {
inputName = inputName.slice(0, -2); // '[]' 부분 제거하여 이름만 추출
if (!inputValue[inputName]) {
inputValue[inputName] = []; // 배열이 없으면 초기화
}
inputValue[inputName].push($(this).val()); // 배열에 값 추가
} else {
inputValue[inputName] = $(this).val();
}
});
formData.push({ inputValue: inputValue });
// 추가 정보 저장
formData.push({ num: $('#num').val() });
formData.push({ tablename: $('#tablename').val() });
formData.push({ update_log: $('#update_log').val() });
// 체크박스 상태 저장
let checkboxData = [];
$('.mainTable tbody tr').each(function(index) {
let rowCheckboxes = {
good: [],
bad: [],
judgement: $(this).find('.judgement').text()
};
$(this).find('.check-good').each(function() {
rowCheckboxes.good.push($(this).prop('checked'));
});
$(this).find('.check-bad').each(function() {
rowCheckboxes.bad.push($(this).prop('checked'));
});
checkboxData.push(rowCheckboxes);
});
formData.push({ checkboxData: checkboxData });
// JSON 문자열로 변환
let jsonString = JSON.stringify(formData);
// 숨겨진 필드에 JSON 데이터 설정
$('#recordsheet').val(jsonString);
// console.log(jsonString);
$("#overlay").show(); // 오버레이 표시
showMsgModal(2); // 파일저장중
// 폼데이터 전송시 사용함 Get form
var form = $('#board_form')[0];
var datasource = new FormData(form);
$.ajax({
enctype: 'multipart/form-data',
processData: false,
contentType: false,
cache: false,
timeout: 600000,
url: "insert_sheet.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);
}
});
}
// 부트스트랩 툴팁
$(document).ready(function() {
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl);
});
});
// 결재부분 클릭처리
$(document).on('click', '.clickable', function() {
const isQCadmin = <?= json_encode($QCadmin); ?>; // 관리자인 경우 true
const userName = <?= json_encode($user_name); ?>; // 현재 사용자 이름
const todayStr = <?= json_encode($todayStr); ?>; // 오늘 날짜
let targetId = $(this).attr('id') + 'Display';
// 작성과 검토는 누구나 가능
if ($(this).attr('id') === 'writer' ) {
$('#' + targetId).html(userName + '<br>' + todayStr);
}
else if ($(this).attr('id') === 'reviewer') {
$('#' + targetId).html(userName + '<br>' + todayStr);
$('#reviewer_sub').val(userName );
}
// 승인 버튼은 관리자만 가능
else if ($(this).attr('id') === 'approver') {
if (!isQCadmin) {
alert('승인 권한이 없습니다.');
return;
}
// 승인자의 이름과 오늘 날짜 표시
$('#approvalDisplay').html(
userName + '<br>' + todayStr +
' <i class="bi bi-x-circle remove-approval" style="cursor: pointer;"></i>'
);
$('#approvalDisplay').show();
// 결재 정보를 업데이트하여 저장 로직에 반영
updateApprovalData(userName, todayStr);
saveData(); // 저장까지 실행하기
}
});
// 결재 정보 업데이트 함수
function updateApprovalData(userName, date) {
let approvalData = {
writer: {
name: $('#writerDisplay').text().split('<br>')[0] || '',
date: $('#writerDisplay').text().split('<br>')[1] || ''
},
reviewer: {
name: $('#reviewerDisplay').text().split('<br>')[0] || '',
date: $('#reviewerDisplay').text().split('<br>')[1] || ''
},
approver: {
name: $('#approvalDisplay').text().split('<br>')[0] || '',
date: $('#approvalDisplay').text().split('<br>')[1] || ''
}
};
let formData = JSON.parse($('#recordsheet').val() || '[]');
const approvalIndex = formData.findIndex(item => item.approval);
if (approvalIndex !== -1) {
formData[approvalIndex].approval = approvalData;
} else {
formData.push({ approval: approvalData });
}
$('#recordsheet').val(JSON.stringify(formData));
}
function captureReturnKey(e) {
if(e.keyCode==13 && e.srcElement.type != 'textarea')
return false;
}
function recaptureReturnKey(e) {
if(e.keyCode==13 && e.srcElement.type != 'textarea')
return false;
}
// 로트번호 가져오기
$(document).ready(function() {
var selectedItemName = ''; // itemName을 저장할 변수
var selectedusesurang = ''; // itemName을 저장할 변수
// lotnumInput 클릭 시 itemName을 저장
$(document).on('click', '.lotnumInput', function() {
var row = $(this).closest('tr');
selectedRow = row; // tr 요소 저장
selectedItemName = $(this).data('itemname'); // itemName 저장
selectedusesurang = $(this).data('usesurang'); // usesurang 저장
if (selectedItemName) {
// 기본적으로 '생산품' 탭을 로드
loadLotData('product', selectedItemName, selectedusesurang);
setTimeout(function() {
$('#lotModal_bending').modal('show');
}, 1000);
} else {
alert('품목명을 입력해주세요.');
}
});
// 탭 전환 시 itemName과 함께 데이터 로드
$('#product-tab').on('shown.bs.tab', function() {
if (selectedItemName) {
loadLotData('product', selectedItemName, selectedusesurang);
}
});
$('#material-tab').on('shown.bs.tab', function() {
if (selectedItemName) {
loadLotData('material', selectedItemName, selectedusesurang);
}
});
// 모달을 열 때 기본적으로 '생산품' 탭을 로드
$('#lotModal_bending').on('shown.bs.modal', function() {
if (selectedItemName) {
loadLotData('product', selectedItemName, selectedusesurang);
}
});
});
// 로트번호 데이터를 불러오는 함수
function loadLotData(type, itemName, usesurang) {
$.post('fetch_rawlot.php', { lot_type: type, item_name: itemName, usesurang : usesurang })
.done(function(data) {
$('#material').html(data); // 원자재 탭에 데이터 로드
})
.fail(function(xhr, status, error) {
console.error("AJAX Request Failed:", status, error);
alert("로트 데이터를 불러오는 중 오류가 발생했습니다.");
});
}
// 선택한 로트 번호를 적용하는 함수
function selectLotNumber_prod(lotNumber) {
selectedRow.find('input.lotnumInput').val(lotNumber);
$('#lotModal_bending').modal('hide');
}
// 절곡로트번호 공백 삽입
$(document).on('click', '.nullBtn_bending', function() {
selectLotNumber_prod('');
});
// 원자재 로트번호 선택
function selectLotNumber(lotNumber) {
selectedRow.find('input.lotnumInput').val(lotNumber);
$('#lotModal_bending').modal('hide');
}
// 원자재 로트번호 선택공백 삽입
$(document).on('click', '.nullBtn', function() {
selectLotNumber('');
});
$(document).on('click', '.cancelBtn', function() {
$('#lotModal_bending').modal('hide');
});
$(document).on('click', '.lot-done-btn', function() {
const num = $(this).data('num');
const tablename = $(this).data('tablename');
const rawitemname = $(this).data('rawitemname');
const lottype = $(this).data('lottype');
const usesurang = $(this).closest('tr').find('.usesurang').text(); // 사용 수량을 가져옴
const currentRow = $(this).closest('tr'); // 현재 tr 요소 저장
Swal.fire({
title: '로트 소진 처리',
text: '해당 로트를 소진 처리하시겠습니까?',
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: '예, 처리합니다',
cancelButtonText: '취소'
}).then((result) => {
if (result.isConfirmed) {
$.ajax({
url: '/output/update_lotdone.php',
type: 'POST',
data: {
num: num,
tablename: tablename,
mode: 'update',
lotDone: '소진'
},
dataType: 'json',
success: function(response) {
console.log(response);
if (response && response.success) {
Swal.fire({
title: '처리 완료',
text: '소진 처리되었습니다.',
icon: 'success',
confirmButtonText: '확인'
}).then(() => {
// 해당 tr 요소 제거
currentRow.remove();
});
} else {
Swal.fire({
title: '오류',
text: '소진 처리 중 오류가 발생했습니다.',
icon: 'error',
confirmButtonText: '확인'
});
}
},
error: function(xhr, status, error) {
Swal.fire({
title: 'AJAX 오류',
text: '요청 중 오류가 발생했습니다.',
icon: 'error',
confirmButtonText: '확인'
});
}
});
}
});
});
// 최초프로그램 로딩부터 동적 로직 구현
$(document).ready(function() {
if (recordsheetData.length > 0) {
console.log(recordsheetData);
// 결재 부분 정보 설정
const approval = recordsheetData.find(item => item.approval);
if (approval) {
$('#writerDisplay').html((approval.approval.writer.name || '') + '<br>' + (approval.approval.writer.date || ''));
$('#reviewerDisplay').html((approval.approval.reviewer.name || '') + '<br>' + (approval.approval.reviewer.date || ''));
if (approval.approval.approver.name && approval.approval.approver.date) {
$('#approvalDisplay').show();
$('#approvalDisplay').html(
approval.approval.approver.name + '<br>' + approval.approval.approver.date +
' <i class="bi bi-x-circle remove-approval" style="cursor: pointer;"></i>'
);
} else {
$('#approvalDisplay').hide().html('');
}
}
// input 정보 설정 (배열로 저장된 input 처리)
const inputValues = recordsheetData.find(item => item.inputValue);
if (inputValues) {
// 각 input 요소에 대해 값 설정
$('.inputValue').each(function() {
let inputName = $(this).attr('name').replace('[]', '');
// 배열 형식일 경우 각 요소를 올바르게 배치
if (Array.isArray(inputValues.inputValue[inputName])) {
const values = inputValues.inputValue[inputName];
// 이름이 같은 모든 요소에 값을 순서대로 할당
$(`input[name="${inputName}[]"]`).each(function(index) {
$(this).val(values[index] || '');
});
} else {
// 단일 값일 경우 바로 설정
$(this).val(inputValues.inputValue[inputName] || '');
}
});
}
// 체크박스 상태 설정 및 초기 판정
const checkboxData = recordsheetData.find(item => item.checkboxData)?.checkboxData || [];
if (checkboxData) {
$('.mainTable tbody tr').each(function(index) {
const rowCheckboxData = checkboxData[index] || { good: [], bad: [], judgement: "" };
const $row = $(this);
// 각 행의 체크박스 설정
$row.find('.check-good').each(function(goodIndex) {
$(this).prop('checked', rowCheckboxData.good[goodIndex] || false);
});
$row.find('.check-bad').each(function(badIndex) {
$(this).prop('checked', rowCheckboxData.bad[badIndex] || false);
});
// 판정 설정
$row.find('.judgement').text(rowCheckboxData.judgement);
});
}
// 초기 판정 수행
$('.mainTable tbody tr').each(function() {
updateJudgement($(this));
});
updateFinalJudgement(); // 최종 판정 업데이트
}
// 판정 업데이트 함수
function updateJudgement($row) {
const lengthTolerance = 4;
const gapTolerance = 2;
// OK/NG 체크박스 상태 검사
let allGood = true;
let anyBad = false;
// 절곡상태 체크박스 확인
const goodChecks = $row.find('.check-good');
const badChecks = $row.find('.check-bad');
// OK 체크박스 검사
console.log("검사 중인 행의 OK 체크박스 상태 확인:");
goodChecks.each(function() {
if (!$(this).is(':checked')) {
allGood = false;
}
});
// NG 체크박스 검사
console.log("검사 중인 행의 NG 체크박스 상태 확인:");
badChecks.each(function() {
if ($(this).is(':checked')) {
anyBad = true;
}
});
console.log("OK 상태(allGood):", allGood);
console.log("NG 상태(anyBad):", anyBad);
// 길이 도면치수와 측정값 비교
const lengthDrawingValue = parseFloat($row.find('.lengthdwg').text()) || 0;
const lengthMeasuredValue = parseFloat($row.find('input[name="lengthMeasurement[]"]').val()) || 0;
const isLengthValid = Math.abs(lengthMeasuredValue - lengthDrawingValue) <= lengthTolerance;
console.log("길이 도면치수:", lengthDrawingValue, "측정값:", lengthMeasuredValue, "길이 적합 여부:", isLengthValid);
var isWidthValid = true;
// 너비 도면치수와 측정값 비교 (N/A면 무시)
const widthDrawingValue = $row.find('.widthdwg').text();
if (widthDrawingValue !== 'N/A') {
const widthMeasuredValue = $row.find('input[name="widthMeasurement[]"]').val();
isWidthValid = widthDrawingValue !== 'N/A' ? Math.abs(parseFloat(widthMeasuredValue) - parseFloat(widthDrawingValue)) <= lengthTolerance : true;
console.log("너비 도면치수:", widthDrawingValue, "측정값:", widthMeasuredValue, "너비 적합 여부:", isWidthValid);
}
else
{
console.log("너비 N/A");
}
// 간격 도면치수와 측정값 비교
let isAllGapValid = true;
$row.closest('tbody').find('.gap-row').each(function(index) {
const gapDrawingValue = parseFloat($(this).find('.gapdwg').text()) || 0;
const gapMeasuredValue = parseFloat($(this).find('input[name="gapMeasurement[]"]').val()) || 0;
const isGapValid = Math.abs(gapMeasuredValue - gapDrawingValue) <= gapTolerance;
if (!isGapValid) {
isAllGapValid = false;
}
console.log(` - 간격 ${index + 1}: 도면치수 = ${gapDrawingValue}, 측정값 = ${gapMeasuredValue}, 적합 여부 = ${isGapValid}`);
});
console.log("모든 간격 적합 여부:", isAllGapValid);
// 전체 행 판정: 모든 조건이 만족해야 '적'
const isRowValid = allGood && !anyBad && isLengthValid && isWidthValid && isAllGapValid;
$row.find('.judgement').text(isRowValid ? '적' : '부');
return isRowValid;
}
// 종합판정 업데이트 함수
function updateFinalJudgement() {
let isAllRowsValid = true;
// 모든 `judgement` 요소를 확인
$('.mainTable .judgement').each(function() {
if ($(this).text().trim() !== '적') {
isAllRowsValid = false;
return false; // 하나라도 '적'이 아니면 루프 중단
}
});
// 종합판정 결과 설정
$('#resultJudgement').val(isAllRowsValid ? '합격' : '불합격');
}
// 체크박스 토글 설정 및 변경 시 판정 업데이트
$('.mainTable').on('change', '.check-good, .check-bad', function() {
const $row = $(this).closest('tr');
// '양호'와 '불량' 체크박스 토글
if ($(this).hasClass('check-good') && $(this).is(':checked')) {
$row.find('.check-bad').prop('checked', false);
} else if ($(this).hasClass('check-bad') && $(this).is(':checked')) {
$row.find('.check-good').prop('checked', false);
}
updateJudgement($row);
updateFinalJudgement();
});
// 측정값 변경 시 판정 업데이트
$('.mainTable').on('input change', 'input[name="lengthMeasurement[]"], input[name="widthMeasurement[]"], input[name="gapMeasurement[]"]', function() {
const $row = $(this).closest('tr');
updateJudgement($row);
updateFinalJudgement();
});
// 초기화
updateFinalJudgement();
});
// 팝업 창에서 데이터 저장 및 닫기 함수
function saveAndClose() {
const updatedData = {
// rawLot: $("#rawLot").val(),
// fabric_lot: $("#fabric_lot").val(),
// lot_number: $("#lot_number").val(),
resultJudgement: $("#resultJudgement").val()
};
hideMsgModal();
// 부모 창에 데이터 업데이트 호출
// window.opener.closePopupAndUpdateRow(updatedData);
// 팝업 창 닫기
// window.close();
}
$(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) {
// recordsheet 값을 빈 배열로 초기화
const initialData = JSON.stringify([]); // 빈 배열로 초기화
// recordsheet hidden input에 초기화된 데이터 설정
$('#recordsheet').val(initialData);
// 초기화된 데이터 저장 요청
$.ajax({
url: 'insert_sheet.php', // 데이터를 저장할 PHP 파일 경로
type: 'POST',
data: {
num: $('#num').val() ,
tablename: $('#tablename').val() ,
update_log: $('#update_log').val() ,
recordsheet: initialData },
success: function(response) {
Swal.fire({
title: '초기화 완료',
text: "모든 데이터가 초기화되었습니다.",
icon: 'success',
confirmButtonText: '확인'
}).then(() => {
saveAndClose();
// 페이지 새로고침
location.reload();
});
},
error: function(jqxhr, status, error) {
Swal.fire({
title: '오류',
text: "초기화 중 오류가 발생했습니다.",
icon: 'error',
confirmButtonText: '확인'
});
console.log("AJAX Error: ", status, error);
}
});
}
});
});
});
$(document).ready(function() {
// 'allclick' ID를 가진 요소를 클릭했을 때 실행
$('#allclick').on('click', function() {
// 1. 모든 체크박스를 체크 상태로 설정
$('.check-good').prop('checked', true);
$('.check-bad').prop('checked', false);
// 2. input 요소 근처의 텍스트를 읽어서 input 값에 넣기
$('input.SpecialinputValue').each(function() {
// input 요소의 부모(td)의 이전 형제(td)에서 텍스트 읽기
let adjacentText = $(this).closest('td').prev().text().trim();
// (1)과 같은 텍스트 제거 및 공백 제거
let cleanedText = adjacentText.replace(/\(.*?\)\s*/, '').trim();
// 처리된 텍스트를 input 값으로 설정
$(this).val(cleanedText);
});
// 3. 강제로 input 요소의 input/change 이벤트 발생
$('input[name="lengthMeasurement[]"], input[name="widthMeasurement[]"], input[name="gapMeasurement[]"]').each(function() {
$(this).trigger('input'); // 또는 'change' 이벤트
});
});
});
</script>
</body>
</html>