- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경 - DB 연결 하드코딩 → .env 기반으로 변경 - MySQL strict mode DATE 오류 수정
856 lines
32 KiB
PHP
856 lines
32 KiB
PHP
<?php
|
|
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
|
$title_message = '조인트바-중간검사';
|
|
$tablename = 'output';
|
|
$itemTitle ='조인트바중간검사';
|
|
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">
|
|
</head>
|
|
<body>
|
|
|
|
<?php
|
|
// JavaScript에서 전달된 변수들 받기
|
|
$num = isset($_REQUEST['num']) ? $_REQUEST['num'] : '';
|
|
|
|
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
|
require_once($_SERVER['DOCUMENT_ROOT'] . "/estimate/fetch_unitprice.php");
|
|
$pdo = db_connect();
|
|
try {
|
|
$sql = "select * from {$DB}.{$tablename} where num = ? ";
|
|
$stmh = $pdo->prepare($sql);
|
|
$stmh->bindValue(1, $num, PDO::PARAM_STR);
|
|
$stmh->execute();
|
|
$count = $stmh->rowCount();
|
|
if ($count < 1) {
|
|
print "검색결과가 없습니다.<br>";
|
|
} else {
|
|
$row = $stmh->fetch(PDO::FETCH_ASSOC);
|
|
include "_row.php";
|
|
|
|
// output_extra 테이블에서 데이터 불러오기
|
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/output/load_output_extraTable.php';
|
|
}
|
|
} catch (PDOException $Exception) {
|
|
print "오류: " . $Exception->getMessage();
|
|
}
|
|
|
|
// JSON 문자열을 PHP 배열로 디코딩합니다.
|
|
//스크린발주서 읽기
|
|
$eList = json_decode($estimateSlatList, true);
|
|
|
|
// 행의 수는 배열의 크기와 동일하므로, count() 함수를 사용하여 구합니다.
|
|
$surang = count($eList);
|
|
|
|
// recordjointbar
|
|
$recordjointbar = isset($recordjointbar) ? json_decode($recordjointbar, true) : [];
|
|
|
|
// print_r($recordjointbar);
|
|
|
|
// JSON 데이터를 JavaScript 변수로 변환
|
|
echo "<script>";
|
|
echo "var recordjointbarData = " . json_encode($recordjointbar) . ";";
|
|
echo "</script>";
|
|
|
|
// 행의 수를 출력하거나 활용할 수 있습니다.
|
|
// echo "행의 수: " . $surang . "<br>";
|
|
|
|
$THscreenSu = $surang + 2 ;
|
|
|
|
$JointBartotal = 0; // 조인트바 합계
|
|
|
|
// 디코딩된 데이터가 배열인지 확인합니다.
|
|
if (!is_array($eList)) {
|
|
echo "데이터가 정상적이지 않습니다. 확인바랍니다.";
|
|
exit;
|
|
}
|
|
|
|
else {
|
|
foreach ($eList as $item) {
|
|
$prodcode = $item['col4'];
|
|
$items1 = ['KQTS01'];
|
|
$items2 = ['KTE01'];
|
|
|
|
// $prodcode가 $items1 배열에 있는 경우
|
|
if (in_array($prodcode, $items1)) {
|
|
$prodname = '국민방화투시형스틸셔터';
|
|
}
|
|
// $prodcode가 $items2 배열에 있는 경우
|
|
elseif (in_array($prodcode, $items2)) {
|
|
$prodname = '국민방화 스틸 셔터';
|
|
} else {
|
|
$prodname = 'Unknown'; // $prodcode가 어느 배열에도 없는 경우
|
|
}
|
|
|
|
// 조인트바 전체 수량 합계
|
|
// 데이터가 유효한지 확인
|
|
$JointBar = (int)$item['col76'] ;
|
|
$JointBartotal += $JointBar ;
|
|
|
|
}
|
|
}
|
|
|
|
$indateStr = date("m/d", strtotime($indate));
|
|
$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;
|
|
}
|
|
</style>
|
|
|
|
<div class="container mt-2">
|
|
<div class="d-flex align-items-center justify-content-end mt-1 m-2">
|
|
<button type="button" class="btn btn-dark btn-sm mx-3" onclick='location.reload();' title="새로고침"> <i class="bi bi-arrow-clockwise"></i> </button>
|
|
<button type="button" class="btn btn-danger btn-sm me-1 ms-1 initialBtn" > <i class="bi bi-trash3-fill"></i> 초기화 </button>
|
|
<button class="btn btn-dark btn-sm me-1 ms-1 saveData" > <i class="bi bi-floppy2-fill"></i> 서버 저장 </button>
|
|
<button class="btn btn-dark btn-sm me-1" onclick="generatePDF()"> PDF 저장 </button>
|
|
<!-- <button class="btn btn-dark btn-sm me-1" onclick="sendmail();"> <i class="bi bi-envelope-arrow-up"></i> 전송 </button> -->
|
|
<button type="button" class="btn btn-secondary btn-sm ms-5 " 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="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="recordjointbar" name="recordjointbar">
|
|
|
|
<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>
|
|
<br>
|
|
</div>
|
|
</div>
|
|
</th>
|
|
<th rowspan="3" class="text-center fw-bold" style="height:100px;">결 재</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;">판매/<?=$orderman?></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" style="border-collapse: collapse;">
|
|
<thead>
|
|
<tr>
|
|
<th class="text-center align-middle ">품명</th>
|
|
<th class="text-center">슬랫</th>
|
|
<th class="text-center align-middle blueBold">제품 LOT NO</th>
|
|
<th class="text-center fw-bold text-primary"><?=$lotNum?></th>
|
|
</tr>
|
|
<tr>
|
|
<th class="text-center align-middle "> 규격 </th>
|
|
<th class="text-center"> EGI 1.55T </th>
|
|
<th class="text-center align-middle lightgray">로트크기 </th>
|
|
<th colspan="1" class="text-center text-dark fw-bold"> <?=$JointBartotal ?> (EA) </th>
|
|
</tr>
|
|
<tr>
|
|
<th class="text-center align-middle ">발주처</th>
|
|
<th class="text-center"><?=$secondord?> </th>
|
|
<th class="text-center align-middle ">검사일자</th>
|
|
<th class="text-center"> <input type="date" id="inspectdate" name="inspectdate" class="form-control inputValue" value="" > </th>
|
|
</tr>
|
|
<tr>
|
|
<th class="text-center align-middle ">현장명</th>
|
|
<th class="text-center orangeBlueBold "><?=$outworkplace?> </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 class="text-center align-middle blueblackBold ">중간검사 <br> 기준서</td>
|
|
<td class="text-center align-middle"> <img src="../img/inspection/jointbar_inspection.jpg" alt="슬랫 중간검사" style="width:100%; height:auto;"> </td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="d-flex align-items-center justify-content-center ">
|
|
<table id="mainTable" class="table " style="border-collapse: collapse;" style="padding:0;">
|
|
<thead>
|
|
<tr>
|
|
<th rowspan="4" class="text-center align-middle"> <span id="allclick"> 일련<br>번호 </span> </th>
|
|
<th colspan="10" class="text-center align-middle blueblackBold"> 중간검사 </th>
|
|
<th rowspan="4" class="text-center align-middle">판정<br>(적/부)</th>
|
|
</tr>
|
|
<tr>
|
|
<th colspan="2" class="text-center align-middle blueblackBold"> 겉모양 </th>
|
|
<th colspan="8" class="text-center align-middle blueblackBold"> 치수(mm) </th>
|
|
</tr>
|
|
<tr>
|
|
<th rowspan="2" class="text-center align-middle blueblackBold"> 가공상태 </th>
|
|
<th rowspan="2" class="text-center align-middle blueblackBold"> 조립상태 </th>
|
|
<th colspan="2" class="text-center align-middle blueblackBold"> ① 높이 </th>
|
|
<th colspan="2" class="text-center align-middle blueblackBold"> ② 높이 </th>
|
|
<th colspan="2" class="text-center align-middle blueblackBold"> ③ 길이(엔드락제외) </th>
|
|
<th colspan="2" class="text-center align-middle blueblackBold"> ④ 간격 </th>
|
|
</tr>
|
|
<tr>
|
|
<th class="text-center align-middle blueblackBold"> 도면치수 </th>
|
|
<th class="text-center align-middle blueblackBold"> 측정값 </th>
|
|
<th class="text-center align-middle blueblackBold"> 기준치 </th>
|
|
<th class="text-center align-middle blueblackBold"> 측정값 </th>
|
|
<th class="text-center align-middle blueblackBold"> 기준치 </th>
|
|
<th class="text-center align-middle blueblackBold"> 측정값 </th>
|
|
<th class="text-center align-middle blueblackBold"> 기준치 </th>
|
|
<th class="text-center align-middle blueblackBold"> 측정값 </th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
// 데이터가 유효한지 확인
|
|
if (is_array($eList) && count($eList) > 0) {
|
|
foreach ($eList as $index => $row) {
|
|
if($index == 0) // 하나만 출력한다.
|
|
{
|
|
echo '<tr>';
|
|
|
|
// 세로 값을 가져옵니다 (col9가 F13에 해당)
|
|
$horizontal = isset($row['col10']) ? (int)$row['col10'] : 0; // 오픈사이즈 + 110 적용
|
|
$vertical = isset($row['col11']) ? (int)$row['col11'] : 0; // 오픈사이즈 + 350 적용
|
|
|
|
// 순번
|
|
echo '<td class="text-center">' . htmlspecialchars($row['col1']) . '</td>';
|
|
|
|
// 2, 3번째 요소: 양호/불량 체크박스
|
|
for ($i = 1; $i <= 2; $i++) {
|
|
echo '<td class="text-center">';
|
|
echo '<input type="checkbox" class="check-good changedClass " name="col' . $index . '_status_' . $i . '" value="양호"> 양호';
|
|
echo '<input type="checkbox" class="check-bad changedClass " name="col' . $index . '_status_' . $i . '" value="불량"> 불량';
|
|
echo '</td>';
|
|
}
|
|
|
|
// 4번째 요소: 높이
|
|
echo '<td class="text-center text-primary fw-bold">16.5 ± 1</td>';
|
|
|
|
// 5번째 요소: 가로 측정값 입력 필드
|
|
echo '<td class="text-center">';
|
|
echo '<input type="text" class="inputValue SpecialinputValue changedClass " name="col' . $index . '_input_1" value="" style="width:40px;">';
|
|
echo '</td>';
|
|
|
|
// 6번째 요소: 제작 사이즈 세로
|
|
echo '<td class="text-center text-primary fw-bold">14.5 ± 1</td>';
|
|
|
|
// 8번째 요소: 세로 측정값 입력 필드
|
|
echo '<td class="text-center">';
|
|
echo '<input type="text" class="inputValue SpecialinputValue changedClass " name="col' . $index . '_input_2" value="" style="width:40px;">';
|
|
echo '</td>';
|
|
|
|
|
|
echo '<td class="text-center text-primary fw-bold">300 ± 4</td>';
|
|
echo '<td class="text-center">';
|
|
echo '<input type="text" class="inputValue SpecialinputValue changedClass " name="col' . $index . '_input_3" value="" style="width:40px;">';
|
|
echo '</td>';
|
|
|
|
echo '<td class="text-center text-primary fw-bold"> 150 ± 4</td>';
|
|
|
|
echo '<td class="text-center">';
|
|
echo '<input type="text" class="inputValue SpecialinputValue changedClass " name="col' . $index . '_input_4" value="" style="width:40px;">';
|
|
echo '</td>';
|
|
|
|
// 11번째 요소: 적/부
|
|
echo '<td class="text-center align-middle judgement" rowspan="1"></td>';
|
|
|
|
echo '</tr>';
|
|
}
|
|
}
|
|
|
|
echo '<tr>';
|
|
echo '<td rowspan="3" colspan="11" class="text-start align-top "> [부적합 내용]
|
|
<br>
|
|
<input type="text" name="screen_false_comment" class="form-control noborder-input w600px text-start inputValue" >
|
|
</td>';
|
|
echo '<td class="text-center yellowredBold"> 종합판정 </td>';
|
|
echo '<tr>';
|
|
echo '</tr>';
|
|
echo '</tr>';
|
|
echo ' <tr>
|
|
<td colspan="1" rowspan="1" class="text-center align-middle">
|
|
<div class="text-center fw-bold mt-3 fs-1 ">
|
|
<input type="text" class="form-control fs-2 text-center inputValue noborder-input" style="height:50px;" id="resultJudgement" name="resultJudgement" autocomplete="off">
|
|
</div>
|
|
</td>
|
|
</tr> ';
|
|
echo '<tr>';
|
|
echo '<td colspan="11" class="text-start "> KDQP-01-005 </td>';
|
|
echo '<td class="text-end "> (주)경동기업 </td>';
|
|
echo '</tr>';
|
|
}
|
|
?>
|
|
</tbody>
|
|
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div> <!-- end of container -->
|
|
</form>
|
|
<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 $outworkplace; ?>';
|
|
var deadline = '<?php echo $indate; ?>';
|
|
var itemTitle = '<?php echo $itemTitle; ?>';
|
|
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' + itemTitle + '(' + 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($('#recordjointbar').val() || '[]');
|
|
const approvalIndex = formData.findIndex(item => item.approval);
|
|
|
|
if (approvalIndex !== -1) {
|
|
formData[approvalIndex].approval.approver.name = '';
|
|
formData[approvalIndex].approval.approver.date = '';
|
|
}
|
|
|
|
// JSON 문자열로 다시 저장
|
|
$('#recordjointbar').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 });
|
|
|
|
// 입고 LOT NO 정보 저장 (행별)
|
|
let inputValue = [];
|
|
$('.inputValue').each(function() {
|
|
inputValue.push($(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 데이터 설정
|
|
$('#recordjointbar').val(jsonString);
|
|
|
|
$("#overlay").show(); // 오버레이 표시
|
|
|
|
// 폼데이터 전송시 사용함 Get form
|
|
var form = $('#board_form')[0];
|
|
var datasource = new FormData(form);
|
|
|
|
showMsgModal(2); // 파일저장중
|
|
$.ajax({
|
|
enctype: 'multipart/form-data',
|
|
processData: false,
|
|
contentType: false,
|
|
cache: false,
|
|
timeout: 600000,
|
|
url: "insert_jointbar.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); ?>; // 오늘 날짜
|
|
const todayDate = <?= json_encode(date('Y-m-d')); ?>; // 오늘 날짜 (YYYY-MM-DD 형식)
|
|
|
|
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 );
|
|
$('#inspectdate').val(todayDate); // 검사일자 검사자 기록
|
|
}
|
|
// 승인 버튼은 관리자만 가능
|
|
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($('#recordjointbar').val() || '[]');
|
|
const approvalIndex = formData.findIndex(item => item.approval);
|
|
|
|
if (approvalIndex !== -1) {
|
|
formData[approvalIndex].approval = approvalData;
|
|
} else {
|
|
formData.push({ approval: approvalData });
|
|
}
|
|
|
|
$('#recordjointbar').val(JSON.stringify(formData));
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
if (recordjointbarData.length > 0) {
|
|
console.log(recordjointbarData);
|
|
|
|
// 결재 부분 정보 설정
|
|
const approval = recordjointbarData.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('');
|
|
}
|
|
}
|
|
|
|
// LOT NO 정보 설정
|
|
const inputValue = recordjointbarData.find(item => item.inputValue);
|
|
if (inputValue) {
|
|
$('.inputValue').each(function(index) {
|
|
$(this).val(inputValue.inputValue[index] || '');
|
|
});
|
|
}
|
|
|
|
// 체크박스 상태 설정 및 초기 판정
|
|
const checkboxData = recordjointbarData.find(item => item.checkboxData)?.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);
|
|
});
|
|
|
|
}
|
|
|
|
// 판정 업데이트 공통 함수
|
|
function updateJudgement($row) {
|
|
const $input1 = $row.find(`input[name^="col"][name$="_input_1"]`);
|
|
const $input2 = $row.find(`input[name^="col"][name$="_input_2"]`);
|
|
const $input3 = $row.find(`input[name^="col"][name$="_input_3"]`);
|
|
const $input4 = $row.find(`input[name^="col"][name$="_input_4"]`);
|
|
const $judgementCell = $row.find('.judgement');
|
|
|
|
const Value1 = 16.5;
|
|
const Value2 = 14.5;
|
|
const Value3 = 300;
|
|
const Value4 = 150;
|
|
|
|
|
|
const input1Value = parseFloat($input1.val());
|
|
const input2Value = parseFloat($input2.val());
|
|
const input3Value = parseFloat($input3.val());
|
|
const input4Value = parseFloat($input4.val());
|
|
const isValidInput1 = !isNaN(input1Value) && (input1Value >= Value1 - 1 && input1Value <= Value1 + 1);
|
|
const isValidInput2 = !isNaN(input2Value) && (input2Value >= Value2 - 1 && input2Value <= Value2 + 1);
|
|
const isValidInput3 = !isNaN(input3Value) && (input3Value >= Value3 - 4 && input3Value <= Value3 + 4);
|
|
const isValidInput4 = !isNaN(input4Value) && (input4Value >= Value4 - 4 && input4Value <= Value4 + 4);
|
|
|
|
// 모든 양호 체크박스가 체크되어 있는지 확인
|
|
let allGoodChecked = true;
|
|
$row.find('.check-good').each(function() {
|
|
if (!$(this).is(':checked')) {
|
|
allGoodChecked = false;
|
|
}
|
|
});
|
|
|
|
// 종합 판정: 모든 양호 체크박스가 선택되었고 입력값이 유효할 경우에만 '적'
|
|
if (allGoodChecked && isValidInput1 && isValidInput2 && isValidInput3 && isValidInput4 ) {
|
|
$judgementCell.text('적');
|
|
} else {
|
|
$judgementCell.text('부');
|
|
}
|
|
|
|
updateFinalJudgement(); // 최종 판정 업데이트
|
|
}
|
|
|
|
|
|
// 각 행의 양호/불량 체크박스를 토글하도록 설정
|
|
$('.changedClass').on('change', function() {
|
|
const $checkbox = $(this);
|
|
const $row = $checkbox.closest('tr');
|
|
const isGoodChecked = $checkbox.hasClass('check-good') && $checkbox.is(':checked');
|
|
const isBadChecked = $checkbox.hasClass('check-bad') && $checkbox.is(':checked');
|
|
|
|
if (isGoodChecked) {
|
|
$checkbox.closest('td').find('.check-bad').prop('checked', false);
|
|
} else if (isBadChecked) {
|
|
$checkbox.closest('td').find('.check-good').prop('checked', false);
|
|
}
|
|
|
|
updateJudgement($row); // 특정 행에 대해 판정 업데이트
|
|
});
|
|
|
|
// 테이블의 각 행을 순회하며 판정 업데이트 및 체크박스 처리를 적용
|
|
$('#mainTable tbody tr').each(function() {
|
|
const $row = $(this);
|
|
|
|
// 입력 값 변경 시 판정 업데이트
|
|
$row.find(`input[name^="col"][name$="_input_1"], input[name^="col"][name$="_input_2"], input[name^="col"][name$="_input_3"], input[name^="col"][name$="_input_4"], .changedClass`).on("input change", function() {
|
|
updateJudgement($row); // 특정 행에 대해 판정 업데이트
|
|
});
|
|
|
|
// 초기 로드 시 판정 업데이트
|
|
updateJudgement($row);
|
|
});
|
|
|
|
// 최종 종합 판정 업데이트 함수
|
|
function updateFinalJudgement() {
|
|
let allPass = true;
|
|
let allJudged = true;
|
|
|
|
$('#mainTable tbody tr .judgement').each(function() {
|
|
const judgementText = $(this).text();
|
|
|
|
if (judgementText === '') {
|
|
allJudged = false;
|
|
}
|
|
|
|
if (judgementText === '부') {
|
|
allPass = false;
|
|
$(this).css('background-color', '#f8d7da');
|
|
} else {
|
|
$(this).css('background-color', '');
|
|
}
|
|
});
|
|
|
|
if (allJudged) {
|
|
$('#resultJudgement').val(allPass ? '합격' : '불합격');
|
|
} else {
|
|
$('#resultJudgement').val('');
|
|
}
|
|
}
|
|
// 초기 로드 시 최종 판정 업데이트 실행
|
|
updateFinalJudgement();
|
|
});
|
|
|
|
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() {
|
|
// '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)과 같은 텍스트 및 ' ± 1' 제거 및 공백 제거
|
|
let cleanedText = adjacentText
|
|
.replace(/\(.*?\)\s*/, '') // 괄호 안 텍스트 제거 ' ± 1' 이런 형태의 숫자 앞에 문자가 붙은 숫자 예를들어, ± 1 , ± 4 등등
|
|
.replace(/ ± \d+/g, '') // ' ± 숫자' 형태 제거
|
|
.trim();
|
|
|
|
// 처리된 텍스트를 input 값으로 설정
|
|
$(this).val(cleanedText);
|
|
});
|
|
|
|
|
|
// 3. 강제로 input 요소의 input/change 이벤트 발생
|
|
$('.inputValue').each(function() {
|
|
$(this).trigger('input'); // 또는 'change' 이벤트
|
|
});
|
|
});
|
|
});
|
|
|
|
$(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) {
|
|
// recordjointbar 값을 빈 배열로 초기화
|
|
const initialData = JSON.stringify([]); // 빈 배열로 초기화
|
|
|
|
// recordjointbar hidden input에 초기화된 데이터 설정
|
|
$('#recordjointbar').val(initialData);
|
|
|
|
// 초기화된 데이터 저장 요청
|
|
$.ajax({
|
|
url: 'insert_jointbar.php', // 데이터를 저장할 PHP 파일 경로
|
|
type: 'POST',
|
|
data: {
|
|
num: $('#num').val() ,
|
|
tablename: $('#tablename').val() ,
|
|
recordjointbar: 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);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
});
|
|
});
|
|
|
|
// 팝업 창에서 데이터 저장 및 닫기 함수
|
|
function saveAndClose() {
|
|
const updatedData = {
|
|
resultJudgement: $("#resultJudgement").val(),
|
|
};
|
|
|
|
hideMsgModal();
|
|
// 부모 창에 데이터 업데이트 호출
|
|
// window.opener.closePopupAndUpdateRow(updatedData);
|
|
|
|
// 팝업 창 닫기
|
|
// window.close();
|
|
}
|
|
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|