- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경 - DB 연결 하드코딩 → .env 기반으로 변경 - MySQL strict mode DATE 오류 수정
1107 lines
38 KiB
PHP
1107 lines
38 KiB
PHP
<?php
|
||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||
|
||
if (!isset($_SESSION["level"]) || $_SESSION["level"] > 5) {
|
||
sleep(1);
|
||
header("Location:" . $WebSite . "login/login_form.php");
|
||
exit;
|
||
}
|
||
include $_SERVER['DOCUMENT_ROOT'] . '/load_header.php';
|
||
$title_message = '절곡 재고생산/작업일지/중간검사성적서';
|
||
?>
|
||
|
||
<link href="css/style.css" rel="stylesheet">
|
||
<title> <?=$title_message?> </title>
|
||
<style>
|
||
#specailTable th, #specailTable td {
|
||
padding: 3px!important;
|
||
}
|
||
#specailTable2 th, #specailTable2 td {
|
||
padding: 3px!important;
|
||
}
|
||
.specailTable th, .specailTable td {
|
||
padding: 2px!important;
|
||
}
|
||
</style>
|
||
|
||
</head>
|
||
|
||
<body>
|
||
<?php
|
||
$header = isset($_REQUEST['header']) ? $_REQUEST['header'] : '';
|
||
|
||
if ($header === 'header')
|
||
require_once($_SERVER['DOCUMENT_ROOT'] . '/myheader.php');
|
||
|
||
function checkNull($strtmp) {
|
||
return ($strtmp !== null && trim($strtmp) !== '');
|
||
}
|
||
|
||
// 필터링 값 가져오기
|
||
$search = isset($_REQUEST['search']) ? $_REQUEST['search'] : '';
|
||
$prodNameSelect = isset($_REQUEST['prodNameSelect']) ? $_REQUEST['prodNameSelect'] : '';
|
||
$specNameSelect = isset($_REQUEST['specNameSelect']) ? $_REQUEST['specNameSelect'] : '';
|
||
$slengthNameSelect = isset($_REQUEST['slengthNameSelect']) ? $_REQUEST['slengthNameSelect'] : '';
|
||
$mode = isset($_REQUEST["mode"]) ? $_REQUEST["mode"] : '';
|
||
|
||
$tablename = 'lot';
|
||
|
||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||
$pdo = db_connect();
|
||
|
||
$order = " ORDER BY reg_date DESC ";
|
||
|
||
// 기본 SQL 쿼리
|
||
$sql = "SELECT * FROM " . $DB . "." . $tablename . " WHERE is_deleted IS NULL ";
|
||
|
||
// 필터 조건을 동적으로 추가
|
||
$whereClause = [];
|
||
|
||
if (checkNull($search)) {
|
||
$whereClause[] = "search_tag LIKE '%$search%'";
|
||
}
|
||
|
||
if (checkNull($prodNameSelect)) {
|
||
$whereClause[] = "prod = '$prodNameSelect'";
|
||
}
|
||
|
||
if (checkNull($specNameSelect)) {
|
||
$whereClause[] = "spec = '$specNameSelect'";
|
||
}
|
||
|
||
if (checkNull($slengthNameSelect)) {
|
||
$whereClause[] = "slength = '$slengthNameSelect'";
|
||
}
|
||
|
||
// 추가된 where 조건이 있을 경우 SQL 쿼리에 반영
|
||
if (!empty($whereClause)) {
|
||
$sql .= " AND " . implode(' AND ', $whereClause);
|
||
}
|
||
|
||
$sql .= $order;
|
||
|
||
try {
|
||
$stmh = $pdo->query($sql);
|
||
$total_row = $stmh->rowCount();
|
||
|
||
// 품목명을 매핑하는 배열
|
||
$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'
|
||
];
|
||
|
||
|
||
?>
|
||
|
||
<form id="board_form" name="board_form" method="post" enctype="multipart/form-data">
|
||
<input type="hidden" id="mode" name="mode" value="<?=$mode?>">
|
||
<input type="hidden" id="num" name="num">
|
||
<input type="hidden" id="tablename" name="tablename" value="<?=$tablename?>">
|
||
<input type="hidden" id="header" name="header" value="<?=$header?>">
|
||
|
||
<?php include $_SERVER['DOCUMENT_ROOT'] . '/lot/modal.php'; ?>
|
||
|
||
<!-- 모달 2: myModal -->
|
||
<div id="myModal" class="modal" tabindex="-1" data-bs-backdrop="static">
|
||
<div class="modal-content" style="width:800px; z-index: 1050;"> <!-- z-index로 순서 조정 -->
|
||
<div class="modal-header">
|
||
<span class="modal-title">절곡품 생산 LOT </span>
|
||
<span class="close">×</span>
|
||
</div>
|
||
<div class="modal-body">
|
||
<div class="custom-card"></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<div class="container-fluid">
|
||
<div class="card justify-content-center text-center mt-1 mb-5">
|
||
<div class="card-header">
|
||
<div class="d-flex justify-content-center align-items-center">
|
||
<span class="text-center fs-5"> <?=$title_message?> </span>
|
||
<button type="button" class="btn btn-dark btn-sm mx-2" onclick='location.reload();' > <i class="bi bi-arrow-clockwise"></i> </button>
|
||
</div>
|
||
</div>
|
||
<div class="card-body">
|
||
<?php include $_SERVER['DOCUMENT_ROOT'] . '/lot/lotTable.php'; ?>
|
||
|
||
<div class="container mt-2 mb-4">
|
||
<div class="d-flex justify-content-center align-items-center">
|
||
▷ <?= $total_row ?>
|
||
|
||
<!-- 품목명 select box -->
|
||
<div class="inputWrap30">
|
||
<select id="prodNameSelect" name="prodNameSelect" class="form-select w-auto mx-1" style="font-size:0.7rem; height:32px;" >
|
||
<option value="">품목명 선택</option>
|
||
<?php foreach($prodNames as $key => $value) { ?>
|
||
<option value="<?= $key ?>" <?= ($prodNameSelect == $key) ? 'selected' : '' ?>><?= $value ?></option>
|
||
<?php } ?>
|
||
</select>
|
||
</div>
|
||
|
||
|
||
<!-- 종류명 select box -->
|
||
<div class="inputWrap30">
|
||
<select id="specNameSelect" name="specNameSelect" class="form-select w-auto mx-1" style="font-size:0.7rem; height:32px;" >
|
||
<option value="">종류명 선택</option>
|
||
<?php foreach($specNames as $key => $value) { ?>
|
||
<option value="<?= $key ?>" <?= ($specNameSelect == $key) ? 'selected' : '' ?>><?= $value ?></option>
|
||
<?php } ?>
|
||
</select>
|
||
</div>
|
||
|
||
|
||
<!-- 모양&길이 select box -->
|
||
<div class="inputWrap30">
|
||
<select id="slengthNameSelect" name="slengthNameSelect" class="form-select w-auto mx-1" style="font-size:0.7rem; height:32px;" >
|
||
<option value="">모양&길이 선택</option>
|
||
<?php foreach($slengthNames as $key => $value) { ?>
|
||
<option value="<?= $key ?>" <?= ($slengthNameSelect == $key) ? 'selected' : '' ?>><?= $value ?></option>
|
||
<?php } ?>
|
||
</select>
|
||
</div>
|
||
|
||
|
||
<!-- 기존 검색 input -->
|
||
<div class="inputWrap30">
|
||
<input type="text" id="search" class="form-control text-start" style="width:150px;" name="search" value="<?= $search ?>" autocomplete="off" onKeyPress="if (event.keyCode==13){ enter(); }">
|
||
<button class="btnClear"></button>
|
||
</div>
|
||
|
||
<button class="btn btn-outline-dark btn-sm" type="button" id="searchBtn"> <i class="bi bi-search"></i> </button>
|
||
|
||
<button id="newBtn" type="button" class="btn btn-dark btn-sm me-2"> <i class="bi bi-pencil-square"></i> 신규 </button>
|
||
<?php if($user_name=='개발자') { ?>
|
||
<button id="uploadBtn" type="button" class="btn btn-dark btn-sm me-2"> <i class="bi bi-box-arrow-up"></i> 업로드 </button>
|
||
<?php } ?>
|
||
</div>
|
||
|
||
<style>
|
||
#specailTable th, #specailTable td {
|
||
padding: 3px!important;
|
||
}
|
||
#specailTable2 th, #specailTable2 td {
|
||
padding: 3px!important;
|
||
}
|
||
</style>
|
||
<div class="row d-flex justify-content-center align-items-center">
|
||
<table class="table table-hover" id="myTable">
|
||
<thead class="table-primary">
|
||
<th class="text-center" style="width:50px;" >번호</th>
|
||
<th class="text-center" style="width:100px;" >등록일</th>
|
||
<th class="text-center" style="width:100px;" >원자재 LOT</th>
|
||
<th class="text-center" style="width:100px;" >원단 LOT</th>
|
||
<th class="text-center" style="width:120px;" >생산 LOT</th>
|
||
<th class="text-center" style="width:150px;" >중간검사성적서</th>
|
||
<th class="text-center" style="width:180px;" >품목명</th>
|
||
<th class="text-center" style="width:120px;" >종류</th>
|
||
<th class="text-center" style="width:150px;" >모양&길이</th>
|
||
<th class="text-center" style="width:50px;" >수량</th>
|
||
<th class="text-center" style="width:80px;" >작성</th>
|
||
<th class="text-center" style="width:150px;" >비고</th>
|
||
</thead>
|
||
<tbody>
|
||
<?php
|
||
$start_num = $total_row;
|
||
|
||
|
||
while($row = $stmh->fetch(PDO::FETCH_ASSOC)) {
|
||
include '_row.php';
|
||
|
||
// 품목명, 종류, 모양&길이에 대한 친절한 표시를 준비
|
||
$prodDisplay = isset($prodNames[$prod]) ? "{$prod}({$prodNames[$prod]})" : $prod;
|
||
$specDisplay = isset($specNames[$spec]) ? "{$spec}({$specNames[$spec]})" : $spec;
|
||
$slengthDisplay = isset($slengthNames[$slength]) ? "{$slength}({$slengthNames[$slength]})" : $slength;
|
||
?>
|
||
<tr>
|
||
<td class="text-center" onclick="loadForm('update', '<?=$num?>');"> <?= $start_num ?></td>
|
||
<td class="text-center" onclick="loadForm('update', '<?=$num?>');"> <?= $reg_date ?></td>
|
||
<td class="text-center text-primary" onclick="loadForm('update', '<?=$num?>');"> <?= $rawLot ?></td>
|
||
<td class="text-center text-primary" onclick="loadForm('update', '<?=$num?>');"> <?= $fabric_lot ?></td>
|
||
<td class="text-center fw-bold text-success" onclick="loadForm('update', '<?=$num?>');"> <?= $lot_number ?></td>
|
||
<td class="text-center text-danger" onclick="loadFormSheet('update', '<?=$num?>');"><i class="bi bi-file-earmark-text"></i></td>
|
||
<td class="text-center" onclick="loadForm('update', '<?=$num?>');"> <?= $prodDisplay ?></td>
|
||
<td class="text-center" onclick="loadForm('update', '<?=$num?>');"> <?= $specDisplay ?></td>
|
||
<td class="text-center" onclick="loadForm('update', '<?=$num?>');"> <?= $slengthDisplay ?></td>
|
||
<td class="text-center" onclick="loadForm('update', '<?=$num?>');"> <?= $surang ?></td>
|
||
<td class="text-center" onclick="loadForm('update', '<?=$num?>');"> <?= $author ?></td>
|
||
<td class="text-start" onclick="loadForm('update', '<?=$num?>');"> <?= $remark ?></td>
|
||
</tr>
|
||
<?php
|
||
$start_num--;
|
||
}
|
||
} catch (PDOException $Exception) {
|
||
print "오류: ".$Exception->getMessage();
|
||
}
|
||
?>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
|
||
<script>
|
||
|
||
var loader = document.getElementById('loadingOverlay');
|
||
if(loader)
|
||
loader.style.display = 'none';
|
||
|
||
var dataTable; // DataTables 인스턴스 전역 변수
|
||
var bendinglotPageNumber; // 현재 페이지 번호 저장을 위한 전역 변수
|
||
|
||
$(document).ready(function() {
|
||
// DataTables 초기 설정
|
||
dataTable = $('#myTable').DataTable({
|
||
"paging": true,
|
||
"ordering": true,
|
||
"searching": false,
|
||
"pageLength": 100,
|
||
"lengthMenu": [100, 200, 500, 1000],
|
||
"language": {
|
||
"lengthMenu": "Show _MENU_ entries"
|
||
},
|
||
"order": [[1, 'desc']] // 출고예정기준 내림정렬
|
||
});
|
||
|
||
// 페이지 번호 복원 (초기 로드 시)
|
||
var savedPageNumber = getCookie('bendinglotPageNumber');
|
||
if (savedPageNumber) {
|
||
dataTable.page(parseInt(savedPageNumber) - 1).draw(false);
|
||
}
|
||
|
||
// 페이지 변경 이벤트 리스너
|
||
dataTable.on('page.dt', function() {
|
||
var bendinglotPageNumber = dataTable.page.info().page + 1;
|
||
setCookie('bendinglotPageNumber', bendinglotPageNumber, 10); // 쿠키에 페이지 번호 저장
|
||
});
|
||
|
||
// 페이지 길이 셀렉트 박스 변경 이벤트 처리
|
||
$('#myTable_length select').on('change', function() {
|
||
var selectedValue = $(this).val();
|
||
dataTable.page.len(selectedValue).draw(); // 페이지 길이 변경 (DataTable 파괴 및 재초기화 없이)
|
||
|
||
// 변경 후 현재 페이지 번호 복원
|
||
savedPageNumber = getCookie('bendinglotPageNumber');
|
||
if (savedPageNumber) {
|
||
dataTable.page(parseInt(savedPageNumber) - 1).draw(false);
|
||
}
|
||
});
|
||
|
||
});
|
||
|
||
function restorePageNumber() {
|
||
var savedPageNumber = getCookie('bendinglotPageNumber');
|
||
// if (savedPageNumber) {
|
||
// dataTable.page(parseInt(savedPageNumber) - 1).draw('page');
|
||
// }
|
||
location.reload(true);
|
||
}
|
||
|
||
|
||
$(document).ready(function() {
|
||
|
||
$("#newBtn").on("click", function() {
|
||
loadForm('insert');
|
||
});
|
||
});
|
||
|
||
var selectedRow;
|
||
|
||
function loadForm(mode, num = null) {
|
||
if (num == null) {
|
||
$("#mode").val('insert');
|
||
} else {
|
||
$("#mode").val('modify');
|
||
$("#num").val(num);
|
||
}
|
||
|
||
$.ajax({
|
||
type: "POST",
|
||
url: "fetch_modal.php",
|
||
data: { mode: mode, num: num },
|
||
dataType: "html",
|
||
success: function(response) {
|
||
$(".modal-body .custom-card").html(response);
|
||
$("#myModal").show();
|
||
|
||
// 품목별 선택 가능한 종류 목록 설정
|
||
const options = {
|
||
'G': ['I'], // 연기차단재 - 화이바원단
|
||
'B': ['S', 'E'], // 하단마감재(스크린) - SUS, EGI
|
||
'T': ['S', 'E'], // 하단마감재(철재) - SUS, EGI
|
||
'L': ['A'], // L - Bar - 스크린용
|
||
'R': ['S', 'D', 'C', 'M', 'E'], // 가이드레일 - SUS, D형, C형, 본체, EGI
|
||
'S': ['S', 'D', 'C', 'M', 'E', 'U'], // 가이드레일 - SUS, D형, C형, 본체
|
||
'C': ['B', 'L', 'P', 'F'] // 케이스 - 후면코너부, 린텔부, 점검구, 전면부
|
||
};
|
||
|
||
// 품목명 매핑
|
||
const prodCodeMap = {
|
||
'G': 'G', // 연기차단재
|
||
'B': 'B', // 하단마감재(스크린)
|
||
'T': 'T', // 하단마감재(철재)
|
||
'L': 'L', // L - Bar
|
||
'R': 'R', // 가이드레일(벽면형)
|
||
'S': 'S', // 가이드레일(측면형)
|
||
'C': 'C' // 케이스
|
||
};
|
||
|
||
// 종류명을 매핑하는 배열 (화면에 표시될 한글명)
|
||
const specNames = {
|
||
'I': '화이바원단',
|
||
'S': 'SUS(마감)',
|
||
'U': 'SUS(마감)2',
|
||
'E': 'EGI(마감)',
|
||
'A': '스크린용', // 스크린용
|
||
'D': 'D형',
|
||
'C': 'C형',
|
||
'M': '본체',
|
||
'B': '후면코너부',
|
||
'L': '린텔부',
|
||
'P': '점검구',
|
||
'F': '전면부'
|
||
};
|
||
|
||
// 종류 코드 매핑 (LOT 번호에 사용할 코드)
|
||
const specCodeMap = {
|
||
'I': 'I', // 화이바원단
|
||
'S': 'S', // SUS(마감)
|
||
'U': 'U', // SUS(마감)2
|
||
'E': 'E', // EGI(마감)
|
||
'A': 'A', // 스크린용
|
||
'D': 'D', // D형
|
||
'C': 'C', // C형
|
||
'M': 'M', // 본체
|
||
'B': 'B', // 후면코너부
|
||
'L': 'L', // 린텔부
|
||
'P': 'P', // 점검구
|
||
'F': 'F' // 전면부
|
||
};
|
||
// 모양&길이를 매핑하는 배열
|
||
const slengthOptions = {
|
||
'연기차단재': [
|
||
{ value: '53', text: 'W50 × 3000' },
|
||
{ value: '54', text: 'W50 × 4000' },
|
||
{ value: '83', text: 'W80 × 3000' },
|
||
{ value: '84', text: 'W80 × 4000' }
|
||
],
|
||
'기타': [
|
||
{ value: '12', text: '1219' },
|
||
{ value: '24', text: '2438' },
|
||
{ value: '30', text: '3000' },
|
||
{ value: '35', text: '3500' },
|
||
{ value: '40', text: '4000' },
|
||
{ value: '42', text: '4200' },
|
||
{ value: '43', text: '4300' }
|
||
]
|
||
};
|
||
|
||
const prodSelect = document.getElementById('prod');
|
||
const specSelect = document.getElementById('spec');
|
||
const slengthSelect = document.getElementById('slength');
|
||
const lotNumberInput = document.getElementById('lot_number');
|
||
const regDate = document.getElementById('reg_date').value;
|
||
|
||
// 날짜 코드를 생성하는 함수
|
||
function getDateCode(dateString) {
|
||
const date = new Date(dateString);
|
||
if (isNaN(date.getTime())) return ''; // 유효하지 않은 날짜 처리
|
||
|
||
const year = date.getFullYear().toString().slice(-1); // 연도의 마지막 숫자
|
||
const month = date.getMonth() + 1; // 월
|
||
const day = date.getDate(); // 일
|
||
|
||
const monthCode = month >= 10 ? String.fromCharCode(55 + month) : month.toString(); // 월을 A, B, C로 변환
|
||
|
||
return `${year}${monthCode}${day.toString().padStart(2, '0')}`;
|
||
}
|
||
|
||
// LOT 번호 업데이트 함수
|
||
function updateLotNumber() {
|
||
const selectedProd = prodSelect.value;
|
||
const selectedSpec = specSelect.value;
|
||
const selectedSlength = slengthSelect.value;
|
||
|
||
const prodCode = prodCodeMap[selectedProd] || '';
|
||
const specCode = specCodeMap[selectedSpec] || '';
|
||
const slengthCode = selectedProd === 'G'
|
||
? slengthOptions['연기차단재'].find(option => option.value === selectedSlength)?.value
|
||
: slengthOptions['기타'].find(option => option.value === selectedSlength)?.value;
|
||
const dateCode = getDateCode(regDate);
|
||
|
||
if (prodCode && specCode && slengthCode && dateCode) {
|
||
lotNumberInput.value = `${prodCode}${specCode}${dateCode}-${slengthCode}`;
|
||
} else {
|
||
lotNumberInput.value = '';
|
||
}
|
||
}
|
||
|
||
// 품목 변경 시
|
||
$(document).on('change', '#prod', function() {
|
||
const selectedProd = this.value;
|
||
const specOptions = options[selectedProd] || [];
|
||
|
||
// 종류 select의 옵션 초기화
|
||
specSelect.innerHTML = '<option value="" disabled>종류 선택</option>';
|
||
|
||
// 종류 select에 해당하는 품목의 옵션 추가 (화면에 한글 표시)
|
||
specOptions.forEach(function(spec) {
|
||
const optionText = specNames[spec] || '종류 없음'; // 한글명 표시
|
||
specSelect.innerHTML += '<option value="' + spec + '">' + optionText + '</option>';
|
||
});
|
||
|
||
// 모양&길이 select 초기화 및 옵션 추가
|
||
const slengthOptionsToAdd = (selectedProd === 'G') ? slengthOptions['연기차단재'] : slengthOptions['기타'];
|
||
slengthSelect.innerHTML = '<option value="" disabled>모양&길이 선택</option>';
|
||
slengthOptionsToAdd.forEach(function(option) {
|
||
slengthSelect.innerHTML += '<option value="' + option.value + '">' + option.text + '</option>';
|
||
});
|
||
|
||
updateLotNumber(); // LOT 번호 업데이트
|
||
});
|
||
|
||
|
||
// 종류 변경 시 LOT 번호 업데이트
|
||
$(document).on('change', '#spec', function() {
|
||
updateLotNumber();
|
||
});
|
||
|
||
// 모양 & 길이 선택 시 LOT 번호 업데이트
|
||
$(document).on('change', '#slength', function() {
|
||
updateLotNumber();
|
||
});
|
||
|
||
// 날짜 코드를 생성하는 함수
|
||
function getDateCode(dateString) {
|
||
const date = new Date(dateString);
|
||
if (isNaN(date.getTime())) return ''; // 날짜가 유효하지 않으면 빈 값 반환
|
||
|
||
const year = date.getFullYear().toString().slice(-1); // 연도의 마지막 숫자
|
||
const month = date.getMonth() + 1; // 월 (0부터 시작하므로 1을 더함)
|
||
const day = date.getDate(); // 일
|
||
|
||
// 월을 A, B, C로 변환 (10월=A, 11월=B, 12월=C)
|
||
const monthCode = month >= 10 ? String.fromCharCode(55 + month) : month.toString();
|
||
|
||
// 4자리 날짜 코드 (년도 마지막 숫자 + 월 코드 + 일)
|
||
return `${year}${monthCode}${day.toString().padStart(2, '0')}`;
|
||
}
|
||
|
||
|
||
// 품목 및 종류에 따른 재질 정보
|
||
const materialMap = {
|
||
'G': { 'I': '화이바원단' },
|
||
'B': { 'S': 'SUS 1.2T', 'E': 'EGI 1.55T' },
|
||
'L': { 'A': 'EGI 1.55T' },
|
||
'R': { 'S': 'SUS 1.2T', 'D': 'EGI 1.55T', 'C': 'EGI 1.55T', 'M': 'EGI 1.55T', 'E': 'EGI 1.55T' },
|
||
'S': { 'S': 'SUS 1.2T', 'U': 'SUS 1.2T', 'D': 'EGI 1.55T', 'C': 'EGI 1.55T', 'M': 'EGI 1.55T', 'E': 'EGI 1.55T' },
|
||
'C': { 'B': 'EGI 1.55T', 'L': 'EGI 1.55T', 'P': 'EGI 1.55T', 'F': 'EGI 1.55T' }
|
||
};
|
||
|
||
// 품목과 종류가 선택될 때 재질을 결정하는 함수
|
||
function updateMaterial() {
|
||
const prod = $('#prod').val(); // 품목 선택 값
|
||
const spec = $('#spec').val(); // 종류 선택 값
|
||
|
||
// 재질 결정
|
||
if (materialMap[prod] && materialMap[prod][spec]) {
|
||
const material = materialMap[prod][spec];
|
||
$('#rawLot').attr('data-searchRaw', material); // 재질을 data-searchRaw에 추가
|
||
console.log('재질: ' + material);
|
||
} else {
|
||
$('#rawLot').attr('data-searchRaw', ''); // 해당 조합이 없으면 빈 값
|
||
console.log('재질 정보 없음');
|
||
}
|
||
}
|
||
|
||
// 품목과 종류가 변경될 때마다 재질 업데이트
|
||
$('#prod, #spec').on('change', function() {
|
||
updateMaterial();
|
||
});
|
||
|
||
updateMaterial();
|
||
|
||
|
||
// 모달을 호출할 때 tr 요소를 저장하는 변수
|
||
|
||
$(document).on('click', '.lotnumInput', function() {
|
||
|
||
selectedRow = $(this).closest('tr'); // 클릭된 행(tr)을 저장
|
||
|
||
const prod =$('select[name="prod"]').val(); // 해당 행에서 'prod'의 선택값
|
||
const spec =$('select[name="spec"]').val(); // 해당 행에서 'spec'의 선택값
|
||
|
||
console.log("선택된 품목:", prod);
|
||
console.log("선택된 종류:", spec);
|
||
|
||
// 재질을 결정하는 함수 호출
|
||
const material = getMaterial(prod, spec);
|
||
|
||
// 결정된 재질을 #rawLot input 요소의 data-searchRaw 속성에 추가
|
||
$('#rawLot').attr('data-searchRaw', material);
|
||
|
||
// console.log('raw Material', material);
|
||
|
||
$.ajax({
|
||
type: 'POST',
|
||
url: 'fetch_lot.php',
|
||
data: { item_name: material },
|
||
dataType: 'html',
|
||
success: function(data) {
|
||
$('#lotModal .modal-body').html(data); // 모달 바디에 데이터 로드
|
||
setTimeout(function() {
|
||
$('#lotModal').modal('show'); // 모달 띄우기
|
||
}, 500);
|
||
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.error("AJAX Request Failed:", status, error);
|
||
console.error("Response:", xhr.responseText);
|
||
}
|
||
});
|
||
|
||
});
|
||
|
||
|
||
|
||
$(document).on('click', '.lotnumInput_fabric', function() {
|
||
|
||
selectedRow = $(this).closest('tr'); // 클릭된 행(tr)을 저장
|
||
|
||
// 재질을 결정하는 함수 호출
|
||
const material = '화이바원단';
|
||
|
||
$.ajax({
|
||
type: 'POST',
|
||
url: 'fetch_lot_fabric.php',
|
||
data: { item_name: material },
|
||
dataType: 'html',
|
||
success: function(data) {
|
||
$('#lotModal_fabric .modal-body').html(data); // 모달 바디에 데이터 로드
|
||
setTimeout(function() {
|
||
$('#lotModal_fabric').modal('show'); // 모달 띄우기
|
||
}, 500);
|
||
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.error("AJAX Request Failed:", status, error);
|
||
console.error("Response:", xhr.responseText);
|
||
}
|
||
});
|
||
|
||
});
|
||
|
||
|
||
$("#closeBtn").on("click", function() {
|
||
$("#myModal").hide();
|
||
});
|
||
|
||
let isSaving = false;
|
||
|
||
$("#saveBtn").on("click", function() {
|
||
if (isSaving) return;
|
||
isSaving = true;
|
||
|
||
var header = $("#header").val();
|
||
var formData = $("#board_form").serialize(); // 파일전송은 안된다. serialize의 단점
|
||
|
||
$.ajax({
|
||
url: "insert.php",
|
||
type: "post",
|
||
data: formData,
|
||
success: function(response) {
|
||
Toastify({
|
||
text: "저장완료",
|
||
duration: 3000,
|
||
close: true,
|
||
gravity: "top",
|
||
position: "center",
|
||
backgroundColor: "#4fbe87",
|
||
}).showToast();
|
||
setTimeout(function() {
|
||
$("#myModal").hide();
|
||
location.reload();
|
||
isSaving = false;
|
||
}, 1000);
|
||
|
||
|
||
},
|
||
error: function(jqxhr, status, error) {
|
||
console.log(jqxhr, status, error);
|
||
isSaving = false;
|
||
}
|
||
});
|
||
});
|
||
|
||
$("#deleteBtn").on("click", function() {
|
||
var level = '<?= $_SESSION["level"] ?>';
|
||
|
||
if (level !== '1') {
|
||
Swal.fire({
|
||
title: '삭제불가',
|
||
text: "관리자만 삭제 가능합니다.",
|
||
icon: 'error',
|
||
confirmButtonText: '확인'
|
||
});
|
||
return;
|
||
}
|
||
|
||
Swal.fire({
|
||
title: '자료 삭제',
|
||
text: "삭제는 신중! 정말 삭제하시겠습니까?",
|
||
icon: 'warning',
|
||
showCancelButton: true,
|
||
confirmButtonColor: '#3085d6',
|
||
cancelButtonColor: '#d33',
|
||
confirmButtonText: '삭제',
|
||
cancelButtonText: '취소'
|
||
}).then((result) => {
|
||
if (result.isConfirmed) {
|
||
$("#mode").val('delete');
|
||
var formData = $("#board_form").serialize();
|
||
|
||
$.ajax({
|
||
url: "insert.php",
|
||
type: "post",
|
||
data: formData,
|
||
success: function(response) {
|
||
Toastify({
|
||
text: "파일 삭제완료",
|
||
duration: 2000,
|
||
close: true,
|
||
gravity: "top",
|
||
position: "center",
|
||
style: {
|
||
background: "linear-gradient(to right, #00b09b, #96c93d)"
|
||
},
|
||
}).showToast();
|
||
|
||
$("#myModal").hide();
|
||
location.reload();
|
||
},
|
||
error: function(jqxhr, status, error) {
|
||
console.log(jqxhr, status, error);
|
||
}
|
||
});
|
||
}
|
||
});
|
||
});
|
||
},
|
||
error: function(jqxhr, status, error) {
|
||
console.log("AJAX Error: ", status, error);
|
||
}
|
||
});
|
||
}
|
||
|
||
|
||
function loadFormSheet(mode, num = null) {
|
||
if (num == null) {
|
||
$("#mode").val('insert');
|
||
} else {
|
||
$("#mode").val('modify');
|
||
$("#num").val(num);
|
||
}
|
||
|
||
// 클릭된 행을 저장
|
||
selectedRow = $(`tr[data-num="${num}"]`);
|
||
|
||
var url = "write_sheet.php?num=" + num ;
|
||
customPopup(url, '성적서', 800, 900);
|
||
}
|
||
|
||
// 모달에서 선택한 로트 번호를 적용
|
||
function selectLotNumber(lotNumber) {
|
||
if (selectedRow) {
|
||
selectedRow.find('input.lotnumInput').val(lotNumber); // 선택된 로트 번호 적용
|
||
$('#lotModal').modal('hide');
|
||
} else {
|
||
console.error('selectedRow is undefined or null.');
|
||
}
|
||
}
|
||
|
||
// 모달에서 선택한 로트 번호를 적용
|
||
function selectLotNumber_fabric(lotNumber) {
|
||
if (selectedRow) {
|
||
selectedRow.find('input.lotnumInput_fabric').val(lotNumber); // 선택된 로트 번호 적용
|
||
$('#lotModal_fabric').modal('hide');
|
||
} else {
|
||
console.error('selectedRow is undefined or null.');
|
||
}
|
||
}
|
||
|
||
$(document).on('click', '.nullBtn', function() {
|
||
selectLotNumber('');
|
||
});
|
||
|
||
$(document).on('click', '.cancelBtn', function() {
|
||
$('#lotModal').modal('hide');
|
||
});
|
||
|
||
$(document).on('click', '.nullBtn_fabric', function() {
|
||
selectLotNumber_fabric('');
|
||
});
|
||
|
||
$(document).on('click', '.cancelBtn_fabric', function() {
|
||
$('#lotModal_fabric').modal('hide');
|
||
});
|
||
|
||
$(document).on('click', '.lot-done-btn', function(e) {
|
||
// 이벤트 전파를 막아 모달이 닫히는 것을 방지
|
||
e.stopPropagation();
|
||
const num = $(this).data('num');
|
||
const tablename = $(this).data('tablename');
|
||
|
||
console.log('num', num);
|
||
console.log('tablename', tablename);
|
||
|
||
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').hasClass('show')) {
|
||
$('#lotModal').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: '확인'
|
||
});
|
||
}
|
||
});
|
||
}
|
||
});
|
||
});
|
||
|
||
$(document).on('click', '.lot-done-fabric-btn', function(e) {
|
||
// 이벤트 전파를 막아 모달이 닫히는 것을 방지
|
||
e.stopPropagation();
|
||
const num = $(this).data('num');
|
||
const tablename = $(this).data('tablename');
|
||
|
||
console.log('num', num);
|
||
console.log('tablename', tablename);
|
||
|
||
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_fabric').hasClass('show')) {
|
||
$('#lotModal_fabric').modal('hide');
|
||
}
|
||
|
||
reloadModalContent_fabric();
|
||
});
|
||
} 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_fabric() {
|
||
|
||
selectedRow = $(this).closest('tr'); // 클릭된 행(tr)을 저장
|
||
const material = '화이바원단';
|
||
|
||
$.ajax({
|
||
type: 'POST',
|
||
url: 'fetch_lot_fabric.php',
|
||
data: { item_name: material },
|
||
dataType: 'html',
|
||
success: function(data) {
|
||
$('#lotModal_fabric .modal-body').html(data); // 모달 바디에 데이터 로드
|
||
setTimeout(function() {
|
||
$('#lotModal_fabric').modal('show'); // 모달 띄우기
|
||
}, 500);
|
||
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.error("AJAX Request Failed:", status, error);
|
||
console.error("Response:", xhr.responseText);
|
||
}
|
||
});
|
||
}
|
||
|
||
// 모달 내용 새로고침 함수
|
||
function reloadModalContent() {
|
||
|
||
selectedRow = $(this).closest('tr'); // 클릭된 행(tr)을 저장
|
||
|
||
const prod =$('select[name="prod"]').val(); // 해당 행에서 'prod'의 선택값
|
||
const spec =$('select[name="spec"]').val(); // 해당 행에서 'spec'의 선택값
|
||
|
||
console.log("선택된 품목:", prod);
|
||
console.log("선택된 종류:", spec);
|
||
|
||
// 재질을 결정하는 함수 호출
|
||
const material = getMaterial(prod, spec);
|
||
|
||
// 결정된 재질을 #rawLot input 요소의 data-searchRaw 속성에 추가
|
||
$('#rawLot').attr('data-searchRaw', material);
|
||
|
||
console.log('raw Material', material);
|
||
|
||
$.ajax({
|
||
type: 'POST',
|
||
url: 'fetch_lot.php',
|
||
data: { item_name: material },
|
||
dataType: 'html',
|
||
success: function(data) {
|
||
$('#lotModal .modal-body').html(data); // 모달 바디에 데이터 로드
|
||
setTimeout(function() {
|
||
$('#lotModal').modal('show'); // 모달 띄우기
|
||
}, 500);
|
||
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.error("AJAX Request Failed:", status, error);
|
||
console.error("Response:", xhr.responseText);
|
||
}
|
||
});
|
||
}
|
||
|
||
// 품목과 종류에 따른 재질 결정 함수
|
||
function getMaterial(prod, spec) {
|
||
let material = '';
|
||
|
||
// prod 및 spec 값을 코드로 해석하여 재질 결정
|
||
if (prod === 'G' && spec === 'I') { // 연기차단재 + 화이버원단
|
||
material = '화이바원단';
|
||
} else if (prod === 'B' && spec === 'S' || prod === 'T' && spec === 'S' ) { // 하단마감재(스크린) + SUS
|
||
material = 'SUS 1.2T';
|
||
} else if (prod === 'B' && spec === 'E' || prod === 'T' && spec === 'E' ) { // 하단마감재(스크린) + EGI
|
||
material = 'EGI 1.55T';
|
||
} else if (prod === 'L' && spec === 'A') { // L - Bar + 스크린용
|
||
material = 'EGI 1.55T';
|
||
} else if ((prod === 'R' || prod === 'S') && (spec === 'S' || spec === 'U')) { // 가이드레일 + SUS 마감재
|
||
material = 'SUS 1.2T';
|
||
} else if ( (prod === 'R' || prod === 'S') && (spec === 'D' || spec === 'C' || spec === 'M' || spec === 'E')) { // 가이드레일 + D형, C형, 본체, EGI
|
||
material = 'EGI 1.55T';
|
||
} else if (prod === 'C' && (spec === 'B' || spec === 'L' || spec === 'P' || spec === 'F')) { // 케이스 + 후면코너부, 린텔부, 점검구, 전면부
|
||
material = 'EGI 1.55T';
|
||
}
|
||
|
||
return material;
|
||
}
|
||
|
||
|
||
$(document).ready(function(){
|
||
|
||
var modal = document.getElementById("myModal");
|
||
var span = document.getElementsByClassName("close")[0];
|
||
|
||
span.onclick = function() {
|
||
modal.style.display = "none";
|
||
}
|
||
|
||
$(".close").on("click", function() {
|
||
$("#myModal").hide();
|
||
});
|
||
|
||
$("#newBtn").on("click", function() {
|
||
loadForm('insert');
|
||
});
|
||
|
||
$("#searchBtn").on("click", function() {
|
||
$("#board_form").submit();
|
||
});
|
||
// upload
|
||
$("#uploadBtn").on("click", function() {
|
||
popupCenter('uploadgrid.php' , '업로드', 1800, 800);
|
||
});
|
||
|
||
});
|
||
|
||
function enter() {
|
||
$("#board_form").submit();
|
||
}
|
||
|
||
function inputNumberFormat(obj) {
|
||
obj.value = obj.value.replace(/[^0-9]/g, '');
|
||
let value = obj.value.replace(/,/g, '');
|
||
obj.value = value.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||
}
|
||
|
||
$(document).on("keypress", "input", function(event) {
|
||
return event.keyCode != 13;
|
||
});
|
||
|
||
$(document).ready(function(){
|
||
// 방문기록 남김
|
||
var title_message = '<?php echo $title_message ; ?>';
|
||
saveMenuLog(title_message);
|
||
});
|
||
|
||
//Lot No 부여법 (펼치고 접기)
|
||
$(document).ready(function() {
|
||
$("#bendTableToggle").on("click", function() {
|
||
var showBOMunitprice = getCookie("showBOMunitprice");
|
||
var bendTable = $("#item_Table");
|
||
if (showBOMunitprice === "show") {
|
||
bendTable.css("display", "none");
|
||
setCookie("showBOMunitprice", "hide", 10);
|
||
} else {
|
||
bendTable.css("display", "block");
|
||
setCookie("showBOMunitprice", "show", 10);
|
||
}
|
||
});
|
||
|
||
// Check the cookie value on page load and set the table visibility
|
||
var showBOMunitprice = getCookie("showBOMunitprice");
|
||
var bendTable = $("#item_Table");
|
||
if (showBOMunitprice === "show") {
|
||
bendTable.css("display", "block");
|
||
} else {
|
||
bendTable.css("display", "none");
|
||
}
|
||
});
|
||
|
||
$(document).on('shown.bs.modal', '#lotModal', function() {
|
||
$('#myModal').css('z-index', 1040); // 기존 모달 뒤로 보내기
|
||
$(this).css('z-index', 1050); // 새 모달을 맨 위로
|
||
});
|
||
|
||
$(document).on('hidden.bs.modal', '#lotModal', function() {
|
||
$('#myModal').css('z-index', 1050); // 기존 모달을 다시 위로
|
||
});
|
||
|
||
$(document).on('shown.bs.modal', '#lotModal_fabric', function() {
|
||
$('#myModal').css('z-index', 1040); // 기존 모달 뒤로 보내기
|
||
$(this).css('z-index', 1050); // 새 모달을 맨 위로
|
||
});
|
||
|
||
$(document).on('hidden.bs.modal', '#lotModal_fabric', function() {
|
||
$('#myModal').css('z-index', 1050); // 기존 모달을 다시 위로
|
||
});
|
||
|
||
</script>
|
||
|
||
</body>
|
||
</html>
|