Files
sam-kd/output/write_form_script_sub.php

768 lines
24 KiB
PHP
Raw Permalink Normal View History

<script>
const authorities = <?php echo json_encode($authorities, JSON_UNESCAPED_UNICODE); ?>;
// console.log(authorities); // 배열 출력
function inputNumbers(input) {
input.value = input.value.replace(/[^0-9.]/g, '');
}
function isZeroOrEmpty(value) {
return value === '0' || value === '';
}
</script>
<script>
function captureReturnKey(e) {
if(e.keyCode==13 && e.srcElement.type != 'textarea')
return false;
}
$(document).ready(function() {
$('#receiver').on('keypress', function(event) {
if (event.keyCode === 13) { // 엔터키의 코드는 13입니다.
callreceiver();
}
});
$(document).on('click', '.fetch_outworkplaceBtn', function() {
call_outworkplace();
});
$('#outworkplace').on('keypress', function(event) {
if (event.keyCode === 13) { // 엔터키의 코드는 13입니다.
call_outworkplace();
}
});
});
ajaxRequest_write = null;
// 현장명 검색 처리
function call_outworkplace() {
var search = $('#outworkplace').val(); // 검색어를 가져옴
// console.log("Search term:", search); // 전달되는 값 확인
// AJAX 요청을 통해 데이터 가져오기
if (ajaxRequest_write !== null) {
ajaxRequest_write.abort();
}
ajaxRequest_write = $.ajax({
url: 'fetch_outworkplace.php',
type: 'POST',
data: { search: search },
dataType: 'json',
success: function(data) {
// console.log("Response data:", data); // 서버로부터의 응답을 콘솔에 출력
var tbody = $('.ModalBody');
tbody.empty(); // 기존 데이터를 지움
if (Array.isArray(data) && data.length > 0) {
data.forEach(function(row, index) {
var tr = $('<tr onclick="fetchoutworkplace(\'' + row.outworkplace + '\',\'' + row.receiver + '\',\'' + row.outputplace + '\', \'' + row.phone + '\');">').append(
$('<td>').addClass('text-center').text(index + 1),
$('<td>').addClass('text-start').html( row.outworkplace ),
$('<td>').addClass('text-start').html( row.receiver ),
$('<td>').addClass('text-start').html( row.outputplace ),
$('<td>').addClass('text-start').html( row.phone )
);
tbody.append(tr);
});
} else if (data.length === 0) {
var tr = $('<tr>').append(
$('<td>').attr('colspan', '5').addClass('text-center').text('No data available')
);
tbody.append(tr);
} else {
console.error('Unexpected data format:', data);
var tr = $('<tr>').append(
$('<td>').attr('colspan', '5').addClass('text-center').text('Error loading data')
);
tbody.append(tr);
}
$('#outworkplaceModal').modal('show'); // 모달 띄우기
},
error: function(jqXHR, textStatus, errorThrown) {
console.error('AJAX request failed:', textStatus, errorThrown);
var tbody = $('#ModalBody');
var tr = $('<tr>').append(
$('<td>').attr('colspan', '5').addClass('text-center').text('Error loading data')
);
tbody.append(tr);
}
});
}
function intovaltel(phone, receiver)
// 수신처 전화번호, 주소 화면에 넣어주기
{
$("#phone").val(phone);
$("#receiver").val(receiver);
$("#telModal").modal("hide");
}
function fetchoutworkplace(outworkplace, receiver, outputplace, phone )
// 현장명, 수신처, 수신처 주소, 전화번호 화면에 넣어주기
{
$("#phone").val(phone);
$("#receiver").val(receiver);
$("#outworkplace").val(outworkplace);
$("#outputplace").val(outputplace);
$("#outworkplaceModal").modal("hide");
}
function intovaltel(phone, receiver)
// 수신처 전화번호, 주소 화면에 넣어주기
{
$("#phone").val(phone);
$("#receiver").val(receiver);
$("#telModal").modal("hide");
}
</script>
<script>
// 페이지 로딩
$(document).ready(function(){
var loader = document.getElementById('loadingOverlay');
loader.style.display = 'none';
});
</script>
<script>
var mode = '<?php echo $mode; ?>';
var ajaxRequest_write = null;
</script>
<script>
// 수주내역의 후반부 자바스크립트
$(document).ready(function() {
// 서버에서 전달된 eList_screen 데이터
let eList_screen = <?php echo json_encode($eList_screen ?? []); ?>;
let eList_slat = <?php echo json_encode($eList_slat ?? []); ?>;
var etcList = <?php echo json_encode($etcList ?? []); ?>;
var mode = '<?php echo $mode; ?>' ;
// 장비리스트에 대한 JSON이 배열인지 아닌지 여부를 확인하는 방법
if (typeof etcList === 'string') {
try {
etcList = JSON.parse(etcList);
} catch (e) {
console.error('JSON 파싱 오류:', e);
etcList = [];
}
}
if (Array.isArray(etcList)) {
console.log('etcList is an array:', etcList);
} else {
console.log('etcList is not an array, resetting to empty array');
etcList = [];
}
etcList.forEach(function(rowData, index) {
$.ajax({
url: 'fetch_etc.php', // PHP 파일 경로 수정 필요
type: 'POST',
dataType: 'json',
success: function(response) {
itemData = response;
addRow_etc($('#etcListBody'), rowData);
},
error: function() {
alert('데이터를 불러오는데 실패했습니다.');
}
});
});
// eList_screen이 객체나 배열 형태라면 바로 사용
if (typeof eList_screen === 'object' && eList_screen !== null) {
console.log('eList_screen 객체로 전달됨');
} else if (typeof eList_screen === 'string') {
// 문자열로 전달된 경우만 JSON.parse로 파싱
try {
eList_screen = JSON.parse(eList_screen);
document.getElementById('eList_screen').value = JSON.stringify(eList_screen);
} catch (e) {
console.error('JSON 파싱 오류:', e);
eList_screen = [];
}
}
// 데이터가 배열이 아니거나 비어있을 경우를 처리
if (!Array.isArray(eList_screen) || eList_screen.length === 0) {
console.log('eList_screen 유효한 데이터가 없습니다.');
if (mode === 'view')
$("#screenWindow").hide(); // 스크린 견적서 불러오기 등 작업일지 등등 감추기
}
// eList_slat이 객체나 배열 형태라면 바로 사용
if (typeof eList_slat === 'object' && eList_slat !== null) {
console.log('eList_slat 객체로 전달됨');
} else if (typeof eList_slat === 'string') {
// 문자열로 전달된 경우만 JSON.parse로 파싱
try {
eList_slat = JSON.parse(eList_slat);
document.getElementById('eList_slat').value = JSON.stringify(eList_slat);
} catch (e) {
console.error('JSON 파싱 오류:', e);
eList_slat = [];
}
}
// 데이터가 배열이 아니거나 비어있을 경우를 처리
if (!Array.isArray(eList_slat) || eList_slat.length === 0) {
console.log('eList_slat 유효한 데이터가 없습니다.');
if (mode === 'view')
$("#slatWindow").hide(); // 스라트 견적서 불러오기 등 작업일지 등등 감추기
}
});
function inputNumberFormat(input) {
input.value = input.value.replace(/\D/g, '').replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
function adjustTextareaHeight(textarea) {
textarea.style.height = 'auto';
textarea.style.height = (textarea.scrollHeight) + 'px';
}
$(document).ready(function() {
var $comment = $('#comment');
if ($comment.length) {
adjustTextareaHeight($comment[0]); // 초기 높이 조정
$comment.on('input', function() {
adjustTextareaHeight(this);
});
}
var $updatecomment = $('#updatecomment');
if ($updatecomment.length) {
adjustTextareaHeight($updatecomment[0]); // 초기 높이 조정
$updatecomment.on('input', function() {
adjustTextareaHeight(this);
});
}
});
$(document).ready(function() {
// Log 파일보기
$("#showlogBtn").click( function() {
var num = '<?php echo $num; ?>'
// table 이름을 넣어야 함
var workitem = 'output' ;
// 버튼 비활성화
var btn = $(this);
popupCenter("../Showlog.php?num=" + num + "&workitem=" + workitem , '로그기록', 500, 500);
btn.prop('disabled', false);
});
});
// 모달창 닫기
$(document).on('click', '.Modalclose', function(e) {
$("#telModal").modal("hide");
$("#outworkplaceModal").modal("hide");
$("#loadEstimateModal").modal("hide");
$("#loadEstimateModal_slat").modal("hide");
});
$(document).ready(function() {
var modeValue = $('#mode').val();
var screenSuValue = $('#screen_su').val();
var slatSuValue = $('#slat_su').val();
if (modeValue === 'view' && (!screenSuValue || parseInt(screenSuValue) <= 0)) {
$('#screen_order').hide();
}
if (modeValue === 'view' && (!slatSuValue || parseInt(slatSuValue) <= 0)) {
$('#slat_order').hide();
}
});
// 숫자만 입력 가능하도록 inputNumber 함수
$(document).on('input', '.inputNumber', function() {
this.value = this.value.replace(/[^0-9]/g, '');
});
var itemData = {};
function phonebookBtn(searchfield)
{
var search = $("#" + searchfield).val();
href = '../phonebook/list.php?search=' + search ;
popupCenter(href, '전화번호 검색', 1600, 800);
}
</script>
<!-- mode == 'view' 조회 화면일때 사용금지 시키는 구문 -->
<script>
// 스크린 발주서 보기 버튼 클릭 시
$(document).on('click', '#loadOrderBtn', function() {
var num = $("#num").val();
// URL에 변수를 추가
var url = '/output/viewOrder.php?num=' + num ;
// 팝업 호출
customPopup(url, '발주서', 800, 900);
});
// 스크린작업일지 버튼 클릭 시
$(document).on('click', '#loadScreenWorkBtn', function() {
var num = $("#num").val();
// URL에 변수를 추가
var url = '/output/viewScreenWork.php?num=' + num ;
// 팝업 호출
customPopup(url, '스크린작업일지', 800, 900);
});
// 스크린 절곡 작업일지 버튼 클릭 시
$(document).on('click', '#loadBendingWorkBtn', function() {
var num = $("#num").val();
// URL에 변수를 추가
var url = '/output/viewBendingWork.php?num=' + num ;
// 팝업 호출
customPopup(url, '절곡작업일지', 800, 900);
});
// 스크린 출고증 버튼 클릭 시
$(document).on('click', '#loadOutputWorkBtn', function() {
var num = $("#num").val();
// URL에 변수를 추가
var url = '/output/viewOutput.php?num=' + num ;
// 팝업 호출
customPopup(url, '출고증', 800, 900);
});
// 스크린 납품확인서 버튼 클릭 시
$(document).on('click', '#loadConfirmBtn', function() {
var num = $("#num").val();
// URL에 변수를 추가
var url = '/output/viewConfirm.php?num=' + num ;
// 팝업 호출
customPopup(url, '납품확인서', 800, 900);
});
// 스크린-중간검사 버튼 클릭 시
$(document).on('click', '#loadmidInspectScreenBtn', function() {
var num = $("#num").val();
var outDate = $("#outdate").val(); // 출고일
var orderDate = $("#orderdate").val(); // orderdate 값
var prodCode = $("#prodCode").val(); // prodCode 값
var warrantyNum = $("#warrantyNum").val();// warrantyNum 값
var delivery = $("input[name='delivery']:checked").val(); // 선택된 배송옵션 값
var outworkplace = $("#outworkplace").val(); // outworkplace 값
var outputplace = $("#outputplace").val(); // 수신처주소
var lotNum = $("#lotNum").val(); // 로트번호
// URL에 변수를 추가
var url = '/output/viewMidInspectScreen.php?num=' + num
+ '&outdate=' + encodeURIComponent(outDate)
+ '&orderdate=' + encodeURIComponent(orderDate)
+ '&prodCode=' + encodeURIComponent(prodCode)
+ '&warrantyNum=' + encodeURIComponent(warrantyNum)
+ '&delivery=' + encodeURIComponent(delivery)
+ '&outputplace=' + encodeURIComponent(outputplace)
+ '&outworkplace=' + encodeURIComponent(outworkplace)
+ '&lotNum=' + encodeURIComponent(lotNum);
// 팝업 호출
customPopup(url, '스크린-중간검사', 800, 900);
});
// 스크린 절곡-중간검사 버튼 클릭 시
$(document).on('click', '#loadmidInspectBendingBtn', function() {
var num = $("#num").val();
// URL에 변수를 추가
var url = '/output/viewMidInspectBending.php?num=' + num ;
// 팝업 호출
customPopup(url, '절곡-중간검사', 800, 900);
});
// 스크린 인정검사
$(document).on('click', '#screenACIBtn', function() {
var num = $("#num").val();
// URL에 변수를 추가
var url = '/output/write_ACI.php?num=' + num ;
// 팝업 호출
customPopup(url, '인정검사', 800, 900);
});
// 자동방화셔터 품질관리서
$(document).on('click', '#QCcertificateBtn', function() {
var num = $("#num").val();
// alert('개발중입니다.');
var prodCode = $("#prodCode").val(); // prodCode 값
var tablename = $("#tablename").val();
url = "view_QCcertificate.php?num=" + num + "&tablename=" + tablename;
customPopup(url, '자동방화셔터 품질관리서', 800, 900);
});
// 품질
$(document).on('click', '#requestBtn', function() {
var num = $("#num").val();
// alert('개발중입니다.');
var prodCode = $("#prodCode").val(); // prodCode 값
var tablename = $("#tablename").val();
// prodcode에 따라 URL 설정
if (prodCode.startsWith('KS') || prodCode.startsWith('KW')) {
url = "view_requestACI.php?num=" + num + "&tablename=" + tablename;
} else {
url = "view_requestACI.php?num=" + num + "&tablename=" + tablename;
}
customPopup(url, '제품 인정검사 요청', 800, 900);
});
// 철재스라트 발주서 보기 버튼 클릭 시
$(document).on('click', '#loadOrderBtn_slat', function() {
var num = $("#num").val();
// URL에 변수를 추가
var url = '/output/viewOrder_slat.php?num=' + num ;
// 팝업 호출
customPopup(url, '철재스라트 발주서', 800, 900);
});
// 철재스라트작업일지 버튼 클릭 시
$(document).on('click', '#loadSlatWorkBtn', function() {
var num = $("#num").val();
// URL에 변수를 추가
var url = '/output/viewSlatWork.php?num=' + num ;
// 팝업 호출
customPopup(url, '철재스라트 작업일지', 800, 900);
});
// 철재스라트 절곡 작업일지 버튼 클릭 시
$(document).on('click', '#loadBendingWorkBtn_slat', function() {
var num = $("#num").val();
// URL에 변수를 추가
var url = '/output/viewBendingWork_slat.php?num=' + num ;
// 팝업 호출
customPopup(url, '철재스라트 절곡작업일지', 800, 900);
});
// 철재스라트 출고증 버튼 클릭 시
$(document).on('click', '#loadOutputWorkBtn_slat', function() {
var num = $("#num").val();
// URL에 변수를 추가
var url = '/output/viewOutput_slat.php?num=' + num ;
// 팝업 호출
customPopup(url, '철재스라트 출고증', 800, 900);
});
// 철재스라트 납품확인서 버튼 클릭 시
$(document).on('click', '#loadConfirmBtn_slat', function() {
var num = $("#num").val();
// URL에 변수를 추가
var url = '/output/viewConfirm_slat.php?num=' + num ;
// 팝업 호출
customPopup(url, '철재스라트 납품확인서', 800, 900);
});
// 철재스라트-중간검사 버튼 클릭 시
$(document).on('click', '#loadmidInspectSlatBtn', function() {
var num = $("#num").val();
// URL에 변수를 추가
var url = '/output/viewMidInspectSlat.php?num=' + num ;
// 팝업 호출
customPopup(url, '철재스라트-중간검사', 800, 900);
});
// 조인트바-중간검사 버튼 클릭 시
$(document).on('click', '#loadmidInspectJointbarBtn', function() {
var num = $("#num").val();
var outDate = $("#outdate").val(); // 출고일
var orderDate = $("#orderdate").val(); // orderdate 값
var prodCode = $("#prodCode").val(); // prodCode 값
var warrantyNum = $("#warrantyNum").val();// warrantyNum 값
var delivery = $("input[name='delivery']:checked").val(); // 선택된 배송옵션 값
var outworkplace = $("#outworkplace").val(); // outworkplace 값
var outputplace = $("#outputplace").val(); // 수신처주소
var lotNum = $("#lotNum").val(); // 로트번호
// URL에 변수를 추가
var url = '/output/viewinspectionJointbar.php?num=' + num
+ '&outdate=' + encodeURIComponent(outDate)
+ '&orderdate=' + encodeURIComponent(orderDate)
+ '&prodCode=' + encodeURIComponent(prodCode)
+ '&warrantyNum=' + encodeURIComponent(warrantyNum)
+ '&delivery=' + encodeURIComponent(delivery)
+ '&outputplace=' + encodeURIComponent(outputplace)
+ '&outworkplace=' + encodeURIComponent(outworkplace)
+ '&lotNum=' + encodeURIComponent(lotNum);
// 팝업 호출
customPopup(url, '조인트바-중간검사', 800, 900);
});
// 철재스라트 절곡-중간검사 버튼 클릭 시
$(document).on('click', '#loadmidInspectBendingBtn_slat', function() {
var num = $("#num").val();
// URL에 변수를 추가
var url = '/output/viewMidInspectBending_slat.php?num=' + num ;
// 팝업 호출
customPopup(url, '철재스라트 절곡-중간검사', 800, 900);
});
// 철재스라트 인정검사
$(document).on('click', '#slatACIBtn', function() {
var num = $("#num").val();
// URL에 변수를 추가
var url = '/output/write_ACI_slat.php?num=' + num ;
// 팝업 호출
customPopup(url, '인정검사', 800, 900);
});
// 쿠키 값 가져오는 함수
function getCookie(name) {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i].trim();
if (cookie.startsWith(name + '=')) {
return cookie.substring(name.length + 1);
}
}
return null;
}
// 쿠키 저장 함수
function setCookie(name, value, days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "expires=" + date.toUTCString();
document.cookie = name + "=" + value + ";" + expires + ";path=/";
}
// 공통 함수: View 토글 및 쿠키 설정
function toggleView(viewId, cookieName) {
var view = getCookie(cookieName);
var listContainer = $("#" + viewId);
if (view === "show") {
listContainer.css("display", "none");
setCookie(cookieName, "hide", 10);
} else {
listContainer.css("display", "block");
setCookie(cookieName, "show", 10);
}
}
// 공통 함수: 페이지 로드 시 쿠키를 기반으로 각 요소의 표시 상태 설정
function initializeView(viewId, cookieName) {
var view = getCookie(cookieName);
var listContainer = $("#" + viewId);
if (view === "show") {
listContainer.css("display", "block");
} else {
listContainer.css("display", "none");
}
}
// searchWarrantyNumber 함수 정의
function searchWarrantyNumber(searchCode) {
// 제품명과 인정번호 데이터를 객체로 정의합니다.
const productData = {
"KD-SL60": "NVS22-0902-1",
"KTE01": "FDS-NVS23-0117-1",
"KSS01": "FDS-OTS23-0117-2",
"KSE01": "FDS-OTS23-0117-3",
"KWE01": "FDS-OTS23-0117-4",
"KQTS01": "FDS-NVS23-1226-3"
};
// 입력된 제품명에 해당하는 인정번호를 반환
return productData[searchCode] || "해당 제품명이 없습니다.";
}
$(document).ready(function(){
$('#prodCode').on('change', function() {
var prodCode = $(this).val(); // 선택된 제품코드
var pairCode = $(this).find(':selected').data('pair'); // 대응하는 인정제품 코드
if (prodCode && pairCode) {
// 로트번호 자동생성 체크박스가 체크되어 있는지 확인
var lotNum = 'KD-' + pairCode ;
$('#lotNum').val(lotNum); // lotNum 필드 업데이트
} else {
$('#lotNum').val(''); // 제품코드가 선택되지 않은 경우 필드 초기화
}
// console.log('호출 prodCode' + $("#prodCode").val());
});
});
$(document).ready(function() {
// 견적선택에서 전체 선택 또는 해제 동작 구현
$('#selectAllEstimates').on('change', function() {
var isChecked = $(this).is(':checked');
// 전체 체크박스 선택 또는 해제
$('.estimate-checkbox').prop('checked', isChecked);
});
// 모달창이 열릴 때 이미 선택된 상태 유지
$('#selectEstimateModal').on('show.bs.modal', function() {
$('#selectAllEstimates').prop('checked', false); // 모달이 열릴 때 전체 선택을 초기화
});
$(document).on('click', '.saveData', function() {
saveData();
});
// 삽입/수정하는 모듈
function saveData() {
$("button").prop("disabled", true); // 모든 버튼 비활성화
// 폼데이터 전송시 사용함 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_ACImemo.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: 2000,
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);
}
});
}
// 다른 필요한 초기화 코드
});
<!-- mode == 'view' 조회 화면일때 사용금지 시키는 구문 -->
$(document).ready(function() {
var mode = '<?php echo $mode; ?>' ;
// 마지막에 넣어줘야 전체를 적용할 수 있다.
if (mode === 'view')
disableView();
});
function disableView() {
$('input, textarea ').prop('readonly', true); // Disable all input, textarea, and select elements
$('input[type=hidden]').prop('readonly', false);
// checkbox와 radio는 클릭 불가능하게 하고 시각적 강조
$('input[type="checkbox"], input[type="radio"]').each(function() {
$(this).addClass('readonly-checkbox readonly-radio');
});
// 파일 입력 비활성화
$('input[type=file]').prop('disabled', true);
$('.fetch_receiverBtn').prop('disabled', true); // 수신자 버튼 비활성화
$('.viewNoBtn').prop('disabled', true); //버튼 비활성화
$('.searchplace').prop('disabled', true); // 수신자 버튼 비활성화
$('.searchsecondord').prop('disabled', true); // 수신자 버튼 비활성화
$('input[name="ACImemo"]').prop('readonly', false);
// 레이블 텍스트 크게 설정
$('label').css('font-size', '1.5em');
// select 속성 readonly 효과 내기
$('select[data-readonly="true"]').on('mousedown', function(event) {
event.preventDefault();
});
// checkbox 속성 readonly 효과 내기
$('input[type="checkbox"][data-readonly="true"]').on('click', function(event) {
event.preventDefault();
});
}
</script>
<?php include $_SERVER['DOCUMENT_ROOT'] . '/common/fileImage.php'; // 파일과 이미지 불러오고 저장하는 서브모듈 ?>
<!-- 부트스트랩 툴팁 -->
<script>
document.addEventListener('DOMContentLoaded', function () {
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl);
});
// $("#order_form_write").modal("show");
});
</script>