- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경 - DB 연결 하드코딩 → .env 기반으로 변경 - MySQL strict mode DATE 오류 수정
977 lines
36 KiB
PHP
977 lines
36 KiB
PHP
<?php
|
|
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
|
$title_message = '철재스라트 비인정 작업일지';
|
|
$tablename = 'output';
|
|
$item ='철재스라트 비인정 작업일지';
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/load_header.php';
|
|
// 품질담당자 및 관리자인 경우 권한 부여
|
|
$QCadmin = false ;
|
|
if($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();
|
|
}
|
|
|
|
// 1) screen_unapprovedList 컬럼(JSON 문자열)을 PHP 배열로 디코딩
|
|
$SlatRecord = json_decode($slat_unapprovedList ?? '[]', true);
|
|
|
|
// 2) 실제로 사용할 컬럼만 뽑아서 새 배열에 재구성
|
|
$eList = [];
|
|
if (is_array($SlatRecord)) {
|
|
foreach ($SlatRecord as $item) {
|
|
$eList[] = [
|
|
// col1 → 품명(item_type)
|
|
'col1' => $item['item_type'] ?? '',
|
|
// col2 → 층부호(floors + text1)
|
|
'col2' => trim(($item['floors'] ?? '') . ' ' . ($item['text1'] ?? '')),
|
|
// col3 -> 재질
|
|
'col3' => $item['memo'] ?? '',
|
|
// col4 → 가로(cutwidth)
|
|
'col4' => $item['cutwidth'] ?? '',
|
|
// col4 → 세로(cutheight)
|
|
'col5' => $item['cutheight'] ?? '',
|
|
// col6 → 수량(number)
|
|
'col6' => $item['number'] ?? '',
|
|
];
|
|
}
|
|
}
|
|
|
|
// echo '<pre>';
|
|
// print_r($eList);
|
|
// echo '</pre>';
|
|
|
|
// 데이터베이스에서 recordslat 컬럼 값을 가져온 후 디코딩
|
|
$recordslat = isset($recordslat) ? json_decode($recordslat, true) : [];
|
|
|
|
// JSON 데이터를 JavaScript 변수로 변환
|
|
|
|
echo "<script>";
|
|
echo "var recorslatData = " . json_encode($recordslat) . ";";
|
|
echo "</script>";
|
|
|
|
$item_name = '슬랫코일';
|
|
|
|
// print_r($item_name);
|
|
|
|
// 행의 수는 배열의 크기와 동일하므로, count() 함수를 사용하여 구합니다.
|
|
$surang = count($eList);
|
|
|
|
// 행의 수를 출력하거나 활용할 수 있습니다.
|
|
// echo "행의 수: " . $surang . "<br>";
|
|
|
|
// 디코딩된 데이터가 배열인지 확인합니다.
|
|
if (!is_array($eList)) {
|
|
echo "데이터가 정상적이지 않습니다. 확인바랍니다.";
|
|
exit;
|
|
}
|
|
|
|
else {
|
|
$prodname = '국민방화 스틸 셔터';
|
|
}
|
|
|
|
$indateStr = date("m/d", strtotime($indate));
|
|
$todayStr = date("m/d");
|
|
|
|
?>
|
|
|
|
<?php include $_SERVER['DOCUMENT_ROOT'] . '/output/mymodal.php'; ?>
|
|
|
|
<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>
|
|
<?php if($QCadmin) { ?>
|
|
<button class="btn btn-primary btn-sm me-1 ms-1 approvalBtn" ><i class="bi bi-award-fill"></i> 품질 승인 </button>
|
|
<?php } ?>
|
|
<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 ms-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="recordslat" name="recordslat">
|
|
|
|
<div id="content-to-print">
|
|
<br>
|
|
<div class="container mt-3">
|
|
<div class="d-flex align-items-center justify-content-center m-1">
|
|
<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-1" > 작 </span>
|
|
<span class="text-dark ms-2 me-2 fs-1" > 업 </span>
|
|
<span class="text-dark ms-2 me-2 fs-1" > 일 </span>
|
|
<span class="text-dark ms-2 fs-1" > 지 </span>
|
|
</div>
|
|
<br>
|
|
<div class="d-flex align-items-center justify-content-center mt-2">
|
|
<span class="badge bg-success ms-2 fs-5" > 비인정 슬랫 생산부서 </span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</th>
|
|
<th rowspan="3" class="text-center fw-bold" style="height:100px;">결 재</th>
|
|
<th class="text-center p-1" style="width : 70px; height:22px; padding:2px;">작성</th>
|
|
<th class="text-center p-1" style="width : 70px; height:22px; padding:2px;">검토</th>
|
|
<th class="text-center p-1" style="width : 90px; height:22px; padding:2px;">승인</th>
|
|
</tr>
|
|
<tr style="height:40px;">
|
|
<th class="text-center"> <?=$orderman?> <br> <?=$indateStr ?></th>
|
|
<th class="text-center">
|
|
<div id="reviewDiv" style="display: none;">
|
|
<?=$user_name?> <br> <?=$todayStr ?>
|
|
</div>
|
|
</th>
|
|
<th class="text-center">
|
|
<div id="approvalDiv" style="display: none;">
|
|
<?=$user_name?> <br> <?=$todayStr ?>
|
|
</div>
|
|
</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 class="d-flex align-items-center justify-content-center m-1">
|
|
<table class="table table-bordered" style="border-collapse: collapse;">
|
|
<thead>
|
|
<tr>
|
|
<th colspan="2" class="text-center align-middle lightgray" style="width:33%;">신 청 업 체</th>
|
|
<th colspan="2" class="text-center align-middle lightgray" style="width:33%;">신 청 내 용</th>
|
|
</tr>
|
|
<tr>
|
|
<th class="text-center align-middle lightgray">발주일</th>
|
|
<th class="text-center"><?=specialDate($orderdate)?></th>
|
|
<th class="text-center align-middle lightgray">현 장 명</th>
|
|
<th class="text-center text-primary fw-bold"><?=$outworkplace?> </th>
|
|
</tr>
|
|
<tr>
|
|
<th class="text-center align-middle lightgray">업체명</th>
|
|
<th class="text-center">경동기업</th>
|
|
<th class="text-center align-middle lightgray">작업일자</th>
|
|
<th colspan="1" class="text-center text-primary fw-bold"> <span id="workdate"> </span> </th>
|
|
</tr>
|
|
<tr>
|
|
<th class="text-center align-middle lightgray">담당자</th>
|
|
<th class="text-center"><?=$orderman?></th>
|
|
<th class="text-center align-middle yellowBold">제품 LOT NO</th>
|
|
<th class="text-center fw-bold text-primary"><?=$lotNum?></th>
|
|
</tr>
|
|
<tr>
|
|
<th class="text-center align-middle lightgray">연락처</th>
|
|
<th class="text-center text-dark fw-bold"><?=$_SESSION['hp']?> </th>
|
|
<th class="text-center align-middle lightgray">생산담당자</th>
|
|
<th class="text-center">
|
|
<button type="button" id="editButton" class="btn btn-primary btn-sm">담당자 입력</button>
|
|
<div id="inputContainer" style="display: none;">
|
|
<input type="text" id="userNameInput" class="form-control d-inline-block noborder-input text-center" autocomplete="off" style="width: 150px;" value="<?=$user_name?>">
|
|
<button type="button" id="cancelButton" class="btn btn-outline-danger btn-sm"> <i class="bi bi-x"> </i> </button>
|
|
</div>
|
|
</th>
|
|
</tr>
|
|
|
|
<script>
|
|
$(document).ready(function() {
|
|
// '담당자 입력' 버튼 클릭 시 input 표시 및 버튼 숨김
|
|
$('#editButton').on('click', function() {
|
|
$('#editButton').hide();
|
|
$('#inputContainer').show();
|
|
$('#workdate').text('<?php echo $todayStr; ?>');
|
|
$('#reviewDiv').show();
|
|
|
|
});
|
|
|
|
// '취소' 버튼 클릭 시 원래 상태로 되돌림
|
|
$('#cancelButton').on('click', function() {
|
|
$('#inputContainer').hide();
|
|
$('#reviewDiv').hide();
|
|
$('#workdate').text('');
|
|
$('#editButton').show();
|
|
});
|
|
});
|
|
</script>
|
|
|
|
</thead>
|
|
|
|
</table>
|
|
</div>
|
|
|
|
|
|
<div class="row justify-content-start m-1 mt-2 ">
|
|
■ 작업내역
|
|
</div>
|
|
<div class="d-flex align-items-center justify-content-center m-1">
|
|
<table id="mainTable" class="table " style="border-collapse: collapse;">
|
|
<tbody>
|
|
<tr>
|
|
<td rowspan="2" class="text-center align-middle">일련<br>번호</td>
|
|
<td rowspan="2" class="text-center align-middle yellowblackBold">입고 LOT NO.</td>
|
|
<td rowspan="2" class="text-center align-middle yellowblackBold">방화유리 <br> 수량</td>
|
|
<td rowspan="2" class="text-center align-middle lightgray">품명</td>
|
|
<td colspan="3" class="text-center align-middle lightgray">제작사이즈(mm) - 미미제외 </td>
|
|
<td rowspan="2" class="text-center align-middle lightgray">조인트바 <br> 수량</td>
|
|
<td rowspan="2" class="text-center align-middle lightgray"> 코일<br> 사용량 </td>
|
|
<td rowspan="2" class="text-center align-middle lightgray">설치층/부호</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="text-center lightgray">가로</td>
|
|
<td class="text-center lightgray">세로</td>
|
|
<td class="text-center lightgray">매수(세로)</td>
|
|
</tr>
|
|
<?php
|
|
$row_count = 0;
|
|
$usedCoilTotal = 0; // 사용 코일 합계
|
|
$jointBarCalcTotal = 0; // 조인트바 계산 합계
|
|
|
|
// 데이터가 유효한지 확인
|
|
if (is_array($eList) && count($eList) > 0) {
|
|
foreach ($eList as $row) {
|
|
$row_count++;
|
|
|
|
// 1) 데이터 파싱
|
|
$horizontal = isset($row['col4']) ? (int)$row['col4'] : 0; // 제작사이즈 가로
|
|
$vertical = isset($row['col5']) ? (int)$row['col5'] : 0; // 제작사이즈 세로
|
|
$Qty = isset($row['col6']) ? (int)$row['col6'] : 0; // 셔터수량(조인트바 개수)
|
|
|
|
// 2) 슬랫 수량 계산
|
|
$slatCount = floor($vertical / 72 + 1);
|
|
|
|
// 3) 조인트바 계산공식 적용
|
|
$calcUnits = 2 + floor(($horizontal - 500) / 1000);
|
|
$jointBarCalc = $calcUnits * $Qty;
|
|
$jointBarCalcTotal += $jointBarCalc;
|
|
|
|
// 4) 사용 코일 계산 (기존 로직)
|
|
$usedCoil = (
|
|
($horizontal + 4) * $slatCount
|
|
+ (304 * 3 * $Qty)
|
|
) / 1000;
|
|
$usedCoil = round($usedCoil, 1);
|
|
$usedCoilTotal += $usedCoil;
|
|
|
|
// 5) 제품명 결정
|
|
$productName = ($row['col3'] === 'EGI 1.2T')
|
|
? '슬랫 <br> [EGI1.15T]'
|
|
: '슬랫 <br> [EGI1.55T]';
|
|
|
|
// 6) 테이블 행 출력
|
|
echo '<tr>';
|
|
// 순번
|
|
echo '<td class="text-center" data-bs-toggle="tooltip" data-bs-placement="top" title="전체적용 클릭">'
|
|
. $row_count .
|
|
'</td>';
|
|
// 로트번호 입력 필드
|
|
echo '<td class="text-center">
|
|
<div class="d-flex justify-content-center align-items-center">
|
|
<input type="text" name="lotnum[]" class="form-control lotnumInput noborder-input text-center"
|
|
placeholder="로트번호" autocomplete="off">
|
|
<div class="info-btn" data-lotnum="" data-bs-toggle="tooltip" data-bs-placement="top" title="성적서">
|
|
<i class="bi bi-info-circle-fill"></i>
|
|
</div>
|
|
</div>
|
|
</td>';
|
|
// 셔터수량
|
|
echo '<td class="text-center">' . htmlspecialchars($Qty) . '</td>';
|
|
// 제품명
|
|
echo '<td class="text-center">' . $productName . '</td>';
|
|
// 제작 사이즈: 가로, 세로
|
|
echo '<td class="text-center yellowredBold fw-bold">' . htmlspecialchars($horizontal) . '</td>';
|
|
echo '<td class="text-center yellowredBold fw-bold">' . htmlspecialchars($vertical) . '</td>';
|
|
// 슬랫 수량
|
|
echo '<td class="text-center fw-bold">' . $slatCount . '</td>';
|
|
// 조인트바 계산 결과
|
|
echo '<td class="text-center fw-bold">' . $jointBarCalc . '</td>';
|
|
// 사용 코일
|
|
echo '<td class="text-center fw-bold">' . $usedCoil . '</td>';
|
|
// 기타 표시 (예: col2/col3)
|
|
echo '<td class="text-center fw-bold">'
|
|
. htmlspecialchars($row['col2']) . '/' . htmlspecialchars($row['col3']) .
|
|
'</td>';
|
|
echo '</tr>';
|
|
}
|
|
|
|
// 합계 행
|
|
echo '<tr>';
|
|
echo '<td colspan="7" class="text-center fw-bold">합계</td>';
|
|
echo '<td class="text-center fw-bold">' . $jointBarCalcTotal . '</td>';
|
|
echo '<td class="text-center fw-bold">' . $usedCoilTotal . '</td>';
|
|
echo '<td class="text-center fw-bold"></td>';
|
|
echo '</tr>';
|
|
|
|
} else {
|
|
echo "<tr><td colspan='10' class='text-center'>데이터가 없습니다.</td></tr>";
|
|
}
|
|
?>
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<br>
|
|
<?php
|
|
|
|
// 별도의 테이블로 면적 통계 출력
|
|
echo '<div class="d-flex align-items-center justify-content-center m-1">';
|
|
echo '<table class="table" style="border-collapse: collapse;">';
|
|
echo '<tbody>';
|
|
|
|
echo '<tr>';
|
|
echo '<td class="text-center align-middle greenblackBold w120px">생산량 합계 (㎡) </td>';
|
|
echo '<td class="text-center w120px">' . $usedCoilTotal . '</td>';
|
|
echo '<td class="text-center align-middle greenblackBold w120px">조인트바 합계 </td>';
|
|
echo '<td class="text-center w120px">' . $jointBarCalcTotal . '</td>';
|
|
echo '</tr>';
|
|
echo '</tbody>';
|
|
echo '</table>';
|
|
echo '</div>';
|
|
?>
|
|
|
|
</tbody>
|
|
</table>
|
|
</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>
|
|
|
|
var ajaxRequest = null;
|
|
|
|
$(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 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();
|
|
}
|
|
|
|
// 모달을 호출할 때 tr 요소를 저장하는 변수
|
|
var selectedRow;
|
|
|
|
$(document).on('click', '.lotnumInput', function() {
|
|
var row = $(this).closest('tr');
|
|
selectedRow = row; // tr 요소 저장
|
|
|
|
// var itemName = row.find('input[name="item_name[]"]').val(); // 품목명 가져오기
|
|
const itemName = $("#item_name").val();
|
|
|
|
if (itemName) {
|
|
$.post('fetch_lot.php', { item_name: itemName })
|
|
.done(function(data) {
|
|
// alert(data);
|
|
$('#lotModal_slat .modal-body').html(data); // 모달 바디에 데이터 로드
|
|
setTimeout(function() {
|
|
$('#lotModal_slat').modal('show'); // 모달 띄우기
|
|
}, 500);
|
|
|
|
})
|
|
.fail(function(xhr, status, error) {
|
|
console.error("AJAX Request Failed:", status, error);
|
|
console.error("Response:", xhr.responseText);
|
|
});
|
|
} else {
|
|
alert('품목명을 입력해주세요.');
|
|
}
|
|
});
|
|
|
|
// 선택한 로트 번호를 적용하는 함수
|
|
function selectLotNumber(lotNumber) {
|
|
selectedRow.find('input.lotnumInput').val(lotNumber);
|
|
selectedRow.find('.info-btn').attr('data-lotnum', lotNumber); // 내부의 .info-btn 선택
|
|
$('#lotModal_slat').modal('hide');
|
|
}
|
|
|
|
$(document).on('click', '.nullBtn', function() {
|
|
selectLotNumber('');
|
|
});
|
|
|
|
$(document).on('click', '.cancelBtn', function() {
|
|
$('#lotModal_slat').modal('hide');
|
|
});
|
|
|
|
$(document).on('click', '.saveData', function() {
|
|
saveData();
|
|
});
|
|
|
|
|
|
$(document).on('click', '.lot-done-btn', function() {
|
|
const num = $(this).data('num');
|
|
const tablename = $(this).data('tablename');
|
|
|
|
console.log('num', num);
|
|
console.log('tablename', tablename);
|
|
|
|
// SweetAlert2를 사용한 확인 메시지
|
|
Swal.fire({
|
|
title: '로트 소진 처리',
|
|
text: '해당 로트를 소진 처리하시겠습니까?',
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonColor: '#3085d6',
|
|
cancelButtonColor: '#d33',
|
|
confirmButtonText: '예, 처리합니다',
|
|
cancelButtonText: '취소'
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
// 사용자가 '예'를 선택한 경우에만 AJAX 요청 수행
|
|
$.ajax({
|
|
url: '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(() => {
|
|
// 모달이 존재할 때만 닫기
|
|
if ($('#lotModal_slat').hasClass('show')) {
|
|
$('#lotModal_slat').modal('hide');
|
|
}
|
|
if ($('#lotModal_slat_wire').hasClass('show')) {
|
|
$('#lotModal_slat_wire').modal('hide');
|
|
}
|
|
|
|
reloadModalContent();
|
|
});
|
|
} else {
|
|
Swal.fire({
|
|
title: '오류',
|
|
text: '소진 처리 중 오류가 발생했습니다.',
|
|
icon: 'error',
|
|
confirmButtonText: '확인'
|
|
});
|
|
}
|
|
},
|
|
error: function(xhr, status, error) {
|
|
console.error('AJAX Error:', status, error);
|
|
Swal.fire({
|
|
title: 'AJAX 오류',
|
|
text: '요청 중 오류가 발생했습니다.',
|
|
icon: 'error',
|
|
confirmButtonText: '확인'
|
|
});
|
|
}
|
|
});
|
|
}
|
|
});
|
|
});
|
|
|
|
// 모달 내용 새로고침 함수
|
|
function reloadModalContent() {
|
|
const itemName = $("#item_name").val();
|
|
|
|
$.post('fetch_lot.php', { item_name: itemName })
|
|
.done(function(data) {
|
|
$('#lotModal_slat .modal-body').html(data); // 모달의 내용 업데이트
|
|
setTimeout(function() {
|
|
$('#lotModal_slat').modal('show'); // 모달 다시 표시
|
|
}, 500);
|
|
})
|
|
.fail(function(xhr, status, error) {
|
|
console.error("AJAX Request Failed:", status, error);
|
|
alert("모달 데이터를 로드하는 중 오류가 발생했습니다.");
|
|
});
|
|
}
|
|
|
|
|
|
$(document).on('click', '.approvalBtn', function() {
|
|
// 승인자의 이름과 오늘 날짜 가져오기
|
|
const userName = '<?=$user_name?>'; // PHP로부터 가져온 사용자 이름
|
|
const todayStr = '<?=$todayStr?>'; // PHP로부터 가져온 오늘 날짜
|
|
|
|
// 승인 정보를 approvalDiv에 표시
|
|
$('#approvalDiv').html(
|
|
userName + '<br>' + todayStr +
|
|
' <i class="bi bi-x-circle remove-approval" style="cursor: pointer;"></i>'
|
|
);
|
|
$('#approvalDiv').show();
|
|
|
|
// 결재 정보를 업데이트하여 저장 로직에 반영
|
|
updateApprovalData(userName, todayStr);
|
|
|
|
saveData();
|
|
});
|
|
|
|
// 결재 정보 업데이트 함수
|
|
function updateApprovalData(userName, date) {
|
|
// 저장 로직을 위해 결재 정보 업데이트
|
|
let approvalData = {
|
|
writer: {
|
|
name: $('#orderman').text().trim(),
|
|
date: '<?=$indateStr?>'
|
|
},
|
|
reviewer: {
|
|
name: $('#reviewDiv').is(':visible') ? '<?=$user_name?>' : '',
|
|
date: '<?=$todayStr?>'
|
|
},
|
|
approver: {
|
|
name: userName,
|
|
date: date
|
|
}
|
|
};
|
|
|
|
// 저장할 JSON 데이터 업데이트
|
|
let formData = JSON.parse($('#recordslat').val() || '[]');
|
|
const approvalIndex = formData.findIndex(item => item.approval);
|
|
|
|
if (approvalIndex !== -1) {
|
|
formData[approvalIndex].approval = approvalData;
|
|
} else {
|
|
formData.push({ approval: approvalData });
|
|
}
|
|
|
|
// JSON 문자열로 다시 저장
|
|
$('#recordslat').val(JSON.stringify(formData));
|
|
}
|
|
|
|
// 결재 취소 기능
|
|
$(document).on('click', '.remove-approval', function() {
|
|
// 결재 정보를 지우고 화면에서 숨김
|
|
$('#approvalDiv').html('').hide();
|
|
|
|
// JSON 데이터에서 결재자의 정보 제거
|
|
let formData = JSON.parse($('#recordslat').val() || '[]');
|
|
const approvalIndex = formData.findIndex(item => item.approval);
|
|
|
|
if (approvalIndex !== -1) {
|
|
formData[approvalIndex].approval.approver.name = '';
|
|
formData[approvalIndex].approval.approver.date = '';
|
|
}
|
|
|
|
// JSON 문자열로 다시 저장
|
|
$('#recordslat').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 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;
|
|
}
|
|
|
|
|
|
// 삽입/수정하는 모듈
|
|
function saveData() {
|
|
// json 형태로 form문에 저장하기
|
|
let formData = [];
|
|
|
|
// 결재 부분 정보 저장
|
|
let approvalData = {
|
|
writer: {
|
|
name: $('#orderman').text().trim(),
|
|
date: '<?=$indateStr?>'
|
|
},
|
|
reviewer: {
|
|
name: $('#reviewDiv').is(':visible') ? '<?=$user_name?>' : '',
|
|
date: '<?=$todayStr?>'
|
|
},
|
|
approver: {
|
|
name: $('#approvalDiv').is(':visible') ? '<?=$user_name?>' : '',
|
|
date: '<?=$todayStr?>'
|
|
}
|
|
|
|
};
|
|
formData.push({ approval: approvalData });
|
|
|
|
// 생산담당자 정보 저장
|
|
let productionManager = $('#userNameInput').val();
|
|
formData.push({ productionManager: productionManager });
|
|
|
|
// 입고 LOT NO 정보 저장 (행별)
|
|
let lotNums = [];
|
|
$('.lotnumInput').each(function() {
|
|
lotNums.push($(this).val());
|
|
});
|
|
formData.push({ lotNumbers: lotNums });
|
|
|
|
// 추가 정보 저장
|
|
formData.push({ num: $('#num').val() });
|
|
formData.push({ tablename: $('#tablename').val() });
|
|
formData.push({ update_log: $('#update_log').val() });
|
|
formData.push({ memo: $('#memo').val() });
|
|
|
|
// JSON 문자열로 변환
|
|
let jsonString = JSON.stringify(formData);
|
|
|
|
// 숨겨진 필드에 JSON 데이터 설정
|
|
$('#recordslat').val(jsonString);
|
|
|
|
$("#overlay").show(); // 오버레이 표시
|
|
$("button").prop("disabled", true); // 모든 버튼 비활성화
|
|
|
|
showMsgModal(2); // 파일저장중
|
|
|
|
// 폼데이터 전송시 사용함 Get form
|
|
var form = $('#board_form')[0];
|
|
var datasource = new FormData(form);
|
|
|
|
if ( (typeof ajaxRequest !== 'undefined' && ajaxRequest) || ajaxRequest!==null ) {
|
|
ajaxRequest.abort();
|
|
}
|
|
|
|
ajaxRequest = $.ajax({
|
|
enctype: 'multipart/form-data',
|
|
processData: false,
|
|
contentType: false,
|
|
cache: false,
|
|
timeout: 600000,
|
|
url: "insert_recordslat.php",
|
|
type: "post",
|
|
data: datasource,
|
|
dataType: "json",
|
|
success: function(data) {
|
|
console.log('after save ', data);
|
|
setTimeout(function() {
|
|
|
|
setTimeout(function() {
|
|
hideMsgModal();
|
|
Toastify({
|
|
text: "저장완료",
|
|
duration: 3000,
|
|
close: true,
|
|
gravity: "top",
|
|
position: "center",
|
|
style: {
|
|
background: "linear-gradient(to right, #00b09b, #96c93d)"
|
|
},
|
|
}).showToast();
|
|
|
|
$("#overlay").hide(); // 오버레이 숨김
|
|
}, 1000);
|
|
|
|
ajaxRequest = null;
|
|
|
|
}, 1000);
|
|
|
|
},
|
|
error: function(jqxhr, status, error) {
|
|
console.log(jqxhr, status, error);
|
|
alert("An error occurred: " + error);
|
|
}
|
|
});
|
|
}
|
|
|
|
// 초기값 불러오기
|
|
$(document).ready(function() {
|
|
if (recorslatData.length > 0) {
|
|
console.log('recorslatData :',recorslatData);
|
|
// 결재 부분 정보
|
|
const approval = recorslatData.find(item => item.approval);
|
|
if (approval) {
|
|
$('#orderman').text(approval.approval.writer.name || '');
|
|
$('#indateStr').text(approval.approval.writer.date || '');
|
|
$('#reviewDiv').show();
|
|
$('#reviewDiv').html(approval.approval.reviewer.name + '<br>' + approval.approval.reviewer.date);
|
|
|
|
// 승인 정보가 있을 때만 승인 정보를 표시하고 x 마크를 추가
|
|
if (approval.approval.approver.name && approval.approval.approver.date) {
|
|
$('#approvalDiv').show();
|
|
$('#approvalDiv').html(
|
|
approval.approval.approver.name + '<br>' + approval.approval.approver.date +
|
|
' <i class="bi bi-x-circle remove-approval" style="cursor: pointer;"></i>'
|
|
);
|
|
} else {
|
|
// 승인 정보가 없을 때는 공백으로 처리
|
|
$('#approvalDiv').hide().html('');
|
|
}
|
|
|
|
$('#workdate').text(approval.approval.writer.date);
|
|
}
|
|
|
|
|
|
// 생산담당자 정보
|
|
const productionManager = recorslatData.find(item => item.productionManager);
|
|
if (productionManager && productionManager.productionManager) {
|
|
$('#userNameInput').val(productionManager.productionManager).show();
|
|
$('#inputContainer').show(); // input 필드 컨테이너 표시
|
|
$('#editButton').hide(); // '생산자 입력' 버튼 숨김
|
|
} else {
|
|
$('#userNameInput').val('');
|
|
$('#inputContainer').hide();
|
|
$('#editButton').show();
|
|
}
|
|
|
|
// 입고 LOT NO 정보
|
|
const lotNumbers = recorslatData.find(item => item.lotNumbers);
|
|
if (lotNumbers) {
|
|
$('.lotnumInput').each(function(index) {
|
|
$(this).val(lotNumbers.lotNumbers[index] || '');
|
|
});
|
|
$('.info-btn').each(function(index) {
|
|
$(this).attr('data-lotnum', lotNumbers.lotNumbers[index] || '');
|
|
});
|
|
}
|
|
|
|
// 업데이트 로그가 있을 경우 표시
|
|
const updateLog = recorslatData.find(item => item.update_log);
|
|
if (updateLog) {
|
|
$('#update_log').val(updateLog.update_log || '');
|
|
}
|
|
|
|
// 메모가 있을 경우
|
|
const memo = recorslatData.find(item => item.memo);
|
|
if (memo) {
|
|
$('#memo').val(memo.memo || '사이즈 착오없이 부탁드립니다.');
|
|
}
|
|
}
|
|
});
|
|
|
|
// 첫번째 요소를 클릭하면 전체 로트번호 적용하기
|
|
$(document).ready(function() {
|
|
// id가 mainTable인 테이블의 첫 번째 td를 클릭했을 때 이벤트를 등록합니다.
|
|
$('#mainTable').on('click', 'td:first-child', function() {
|
|
// 클릭한 첫 번째 td의 형제인 두 번째 td 요소의 값을 가져옵니다.
|
|
var secondTdValue = $(this).siblings().find('input').val();
|
|
|
|
// id가 mainTable인 테이블에서 두 번째 td 요소에 해당 값을 적용합니다.
|
|
$('#mainTable tbody tr').each(function() {
|
|
$(this).find('td:nth-child(2) input').val(secondTdValue);
|
|
});
|
|
});
|
|
});
|
|
|
|
// 부트스트랩 툴팁
|
|
$(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).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) {
|
|
// recordslat 값을 빈 배열로 초기화
|
|
const initialData = JSON.stringify([]); // 빈 배열로 초기화
|
|
|
|
// recordslat hidden input에 초기화된 데이터 설정
|
|
$('#recordslat').val(initialData);
|
|
|
|
// 초기화된 데이터 저장 요청
|
|
$.ajax({
|
|
url: "insert_recordslat.php",
|
|
type: 'POST',
|
|
data: {
|
|
num: $('#num').val() ,
|
|
tablename: $('#tablename').val() ,
|
|
update_log: $('#update_log').val() ,
|
|
recordslat: 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 = {
|
|
// // rawLot: $("#rawLot").val(),
|
|
// // fabric_lot: $("#fabric_lot").val(),
|
|
// // lot_number: $("#lot_number").val(),
|
|
// resultJudgement: $("#resultJudgement").val(),
|
|
// // reg_date: $("#reg_date").val(),
|
|
// // prodDisplay: $("#prod").val(),
|
|
// // specDisplay: $("#spec").val(),
|
|
// // slengthDisplay: $("#slength").val(),
|
|
// // surang: $("#surang").val(),
|
|
// // author: $("#author").val(),
|
|
// // remark: $("#remark").val()
|
|
// };
|
|
|
|
// // 부모 창에 데이터 업데이트 호출
|
|
// window.opener.closePopupAndUpdateRow(updatedData);
|
|
|
|
// 팝업 창 닫기
|
|
// window.close();
|
|
}
|
|
|
|
ajaxRequest1 = null;
|
|
|
|
$(document).ready(function () {
|
|
|
|
$(document).on('click', '.info-btn, .info-wire-btn', function () {
|
|
var lotnum = $(this).data('lotnum');
|
|
console.log('lotnum :', lotnum);
|
|
if (!lotnum) {
|
|
Swal.fire('알림', '로트번호를 입력하세요.', 'warning');
|
|
return;
|
|
}
|
|
|
|
// AJAX 요청을 통해 데이터 가져오기
|
|
if (ajaxRequest1 !== null) {
|
|
ajaxRequest1.abort();
|
|
}
|
|
|
|
ajaxRequest1 = $.ajax({
|
|
url: 'fetch_certificate.php', // 성적서를 가져오는 서버 파일
|
|
type: 'POST',
|
|
data: { lotnum: lotnum },
|
|
dataType: 'json',
|
|
success: function (response) {
|
|
console.log(response);
|
|
if (response.success) {
|
|
// 성적서 데이터를 화면에 표시
|
|
// $('#certificateModal .modal-body').html(response.data);
|
|
// $('#certificateModal').modal('show');
|
|
var num = response.num;
|
|
var itemname = response.itemname;
|
|
var spec = response.specification;
|
|
var remarks = response.remarks;
|
|
|
|
// 클릭 이벤트 전파 방지
|
|
event.stopPropagation();
|
|
|
|
// viewBoardInstock 함수 호출
|
|
viewBoardInstock(num, itemname, spec, remarks);
|
|
|
|
} else {
|
|
Swal.fire('오류', '성적서를 가져올 수 없습니다.', 'error');
|
|
}
|
|
ajaxRequest1 = null;
|
|
},
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
|
console.error('AJAX Error:', textStatus, errorThrown);
|
|
console.error('Response Text:', jqXHR.responseText);
|
|
Swal.fire('오류', '서버 요청에 실패했습니다. <br> ' + textStatus + ': ' + errorThrown, 'error');
|
|
},
|
|
});
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|
|
<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/instock/common/viewJS.php'; ?> <!--공통 JS -->
|
|
</body>
|
|
</html>
|