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

454 lines
18 KiB
PHP

<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/instock/commonRequest.php'; // 구글드라이브 세션 파일 포함
$title_message = '인정검사';
$tablename = 'output';
$item = $title_message;
include $_SERVER['DOCUMENT_ROOT'] . '/load_header.php';
?>
<title> <?=$title_message?> </title>
<link rel="stylesheet" href="../instock/css/style.css">
<link rel="stylesheet" href="../instock/css/style_inspection.css">
</head>
<body>
<?php
$num = isset($_REQUEST['num']) ? $_REQUEST['num'] : '';
$page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1;
// echo '<pre>';
// print_r($page);
// echo '</pre>';
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
$pdo = db_connect();
// $todayStr = date("m/d");
// $inspectionDate = date("m/d");
$todayStr = date("y/m/d"); // 연도를 두 자리로 나타냄
$inspectionDate = date("y/m/d"); // 동일한 형식으로 출력
$approvalDate = null;
$writerName = $user_name; // 기본값: 로그인 사용자 이름
$approvalName = '';
$userNameInput = '';
$screenorslat ='';
try {
$sql = "SELECT * FROM {$DB}.{$tablename} WHERE num = ?";
$stmh = $pdo->prepare($sql);
$stmh->bindValue(1, $num, PDO::PARAM_STR);
$stmh->execute();
$row = $stmh->fetch(PDO::FETCH_ASSOC);
include $_SERVER['DOCUMENT_ROOT'] . "/output/_row.php";
// 전체수량 합산
$shutterSurang = 0; // 셔터 수량 합계를 저장할 변수 초기화
$shutterSurang_slat = 0; // 철재
// 길이, 높이
$prod_width = [];
$prod_height = [];
// JSON 데이터를 배열로 디코딩
// $eList_screenData = json_decode($eList_screen, true);
// $eList_slatData = json_decode($eList_slat, true);
// if (is_array($eList_screenData)) {
// foreach ($eList_screenData as $item) {
// $shutterSurang += isset($item['col14']) ? (int)$item['col14'] : 0;
// $prod_width[] = isset($item['col8']) ? intval($item['col8']) : 0;
// $prod_height[] = isset($item['col9']) ? intval($item['col9']) : 0;
// }
// $screenorslat ='스크린';
// if($shutterSurang>0)
// $lotVolumn = $shutterSurang ;
// }
// // slat 반복문을 통해
// if (is_array($eList_slatData)) {
// foreach ($eList_slatData as $item) {
// $shutterSurang_slat += isset($item['col15']) ? (int)$item['col15'] : 0;
// $prod_width[] = isset($item['col8']) ? intval($item['col8']) : 0;
// $prod_height[] = isset($item['col9']) ? intval($item['col9']) : 0;
// }
// $screenorslat ='철재';
// if($shutterSurang_slat>0)
// $lotVolumn = $shutterSurang_slat ;
// }
// // JSON 파일에서 iList 데이터 읽기
// $jsonFilePath = "../output/i_json/" . $num . ".json";
// if (file_exists($jsonFilePath)) {
// $iList = json_decode(file_get_contents($jsonFilePath), true);
// } else {
// $iList = '{}' ; // 기본값
// }
// echo "<script>";
// echo "var iList = " . json_encode($iList) . ";"; // 전역 변수 iList에 할당
// echo "var iListData;"; // iListData 변수만 선언
// echo "$(document).ready(function() {";
// echo " iListData = iList; console.log('초기로드 데이터 상태:', iListData);"; // iListData에 iList 할당
// echo "});";
// echo "</script>";
// i_json 파일 우선 로드
$jsonFilePath = "../output/i_json/" . $num . ".json";
if (file_exists($jsonFilePath)) {
// 파일 내용어 '[]'은 삭제하고 다시 읽음
$iList = json_decode(file_get_contents($jsonFilePath), true);
if (empty($iList)) {
unlink($jsonFilePath); // 빈 배열일 경우 파일 삭제
$jsonFilePath = "../output/real_json/" . $num . ".json";
if (file_exists($jsonFilePath)) {
$iList = json_decode(file_get_contents($jsonFilePath), true);
$dataSource = 'real_json';
} else {
echo "<h1 style='color: red; text-align: center;'>생성된 자료가 없습니다.</h1>";
}
} else {
$dataSource = 'i_json';
}
} else {
// i_json 파일이 없으면 real_json 파일 로드
$jsonFilePath = "../output/real_json/" . $num . ".json";
if (file_exists($jsonFilePath)) {
$iList = json_decode(file_get_contents($jsonFilePath), true);
$dataSource = 'real_json';
} else {
// JSON 파일이 없으면 메시지 출력
echo "<h1 style='color: red; text-align: center;'>생성된 자료가 없습니다.</h1>";
exit; // 이후 코드 실행 중단
}
}
// exceptCheck 값이 1인 항목 제외 및 데이터 처리
$lotVolumn = 0;
if (isset($iList['exceptCheck'])) {
foreach ($iList['exceptCheck'] as $index => $except) {
if ($except === "1") {
continue; // 제외 처리
}
// 수량 합산
$lotVolumn ++;
// 길이, 높이 추가
if (isset($iList['afterWidth'][$index])) {
$prod_width[] = (int)$iList['afterWidth'][$index];
}
if (isset($iList['afterHeight'][$index])) {
$prod_height[] = (int)$iList['afterHeight'][$index];
}
}
}
echo "<script>";
echo "var iList = " . json_encode($iList) . ";"; // 전역 변수 iList에 할당
echo "var iListData;"; // iListData 변수만 선언
echo "$(document).ready(function() {";
echo " iListData = iList; console.log('초기로드 데이터 상태:', iListData);"; // iListData에 iList 할당
echo "});";
echo "</script>";
// echo "<pre>";
// echo print_r($iList);
// echo "</pre>";
} catch (PDOException $Exception) {
print "오류: " . $Exception->getMessage();
}
$prodName = ""; // 상품명을 저장할 변수
// if문을 사용하여 제품 코드에 따른 상품명 설정
if ($prodCode == 'KSS01') {
$prodName = '국민방화 스크린 셔터';
$arrayWidth = $prod_width[$page-1] ;
$arrayHeight = $prod_height[$page-1] ;
} elseif ($prodCode == 'KSE01') {
$prodName = '국민방화 스크린 셔터';
$arrayWidth = $prod_width[$page-1] ;
$arrayHeight = $prod_height[$page-1] ;
} elseif ($prodCode == 'KWE01') {
$prodName = '국민방화 스크린 플러스 셔터';
$arrayWidth = $prod_width[$page-1] ;
$arrayHeight = $prod_height[$page-1] ;
} elseif ($prodCode == 'KD-SL60') {
$prodName = '국민방화 스틸 셔터';
$arrayWidth = $prod_width[$page-1] ;
$arrayHeight = $prod_height[$page-1] ;
} elseif ($prodCode == 'KTE01') {
$prodName = '국민방화 스틸 셔터';
$arrayWidth = $prod_width[$page-1] ;
$arrayHeight = $prod_height[$page-1] ;
} elseif ($prodCode == 'KQTS01') {
$prodName = '국민방화 투시형 스틸 셔터';
$arrayWidth = $prod_width[$page-1] ;
$arrayHeight = $prod_height[$page-1] ;
} else {
$prodName = "유효하지 않은 제품 코드입니다.";
}
$pageWidth = $arrayWidth;
$pageHeight = $arrayHeight;
?>
<?php
$itemTitle = '인정검사';
$today = date("Y-m-d");
require_once $_SERVER['DOCUMENT_ROOT'] . '/' . $tablename . '/common/GDload.php'; // 구글드라이브 파일형태 이미지형태 읽어오기 모듈
$savetitle ='인정검사';
?>
<?php
// 품질담당자 및 관리자인 경우 권한 부여
$QCadmin = false ;
if($user_name=='이세희' || $user_name=='개발자' || $user_name=='함신옥' || $user_name=='노완호' )
$QCadmin = true ;
?>
<form id="board_form" name="board_form" method="post" enctype="multipart/form-data" onkeydown="return captureReturnKey(event)" >
<input type="hidden" id="id" name="id" value="<?= isset($num) ? $num : '' ?>" >
<input type="hidden" id="num" name="num" value="<?= isset($num) ? $num : '' ?>">
<input type="hidden" id="item" name="item" value="<?= isset($item) ? $item : '' ?>" >
<input type="hidden" id="page" name="page" value="<?= isset($page) ? $page : 1 ?>" >
<input type="hidden" id="lotVolumn" name="lotVolumn" value="<?= isset($lotVolumn) ? $lotVolumn : 1 ?>" >
<input type="hidden" id="tablename" name="tablename" value="<?= isset($tablename) ? $tablename : '' ?>" >
<input type="hidden" id="drivetablename" name="drivetablename" value="<?= isset($drivetablename) ? $drivetablename : $tablename ?>" >
<input type="hidden" id="savetitle" name="savetitle" value="<?= isset($savetitle) ? $savetitle : '' ?>" >
<input type="hidden" id="mode" name="mode" value="<?= isset($mode) ? $mode : '' ?>" >
<input type="hidden" id="timekey" name="timekey" value="<?= isset($timekey) ? $timekey : '' ?>" >
<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="item_name" name="item_name" value="<?= isset($item_name) ? $item_name : '' ?>">
<input type="hidden" id="screenorslat" name="screenorslat" value="<?= isset($screenorslat) ? $screenorslat : '' ?>">
<input type="hidden" id="ACIdoneDate" name="ACIdoneDate" value="<?= isset($ACIdoneDate) ? $ACIdoneDate : null ?>">
<input type="hidden" id="iList" name="iList" >
<div class="container mt-2">
<div class="d-flex align-items-center justify-content-end mt-1">
<div class="card">
<div class="card-body">
<div class="d-flex justify-content-center">
<!-- 파일 선택 -->
<input type="file" id="upfile" name="upfile[]" multiple style="display:none;">
<button class="btn btn-dark btn-sm me-4" type="button" onclick="document.getElementById('upfile').click();">
<i class="bi bi-image"></i> </button>
<!-- 드롭 영역 -->
<div id="dropArea" style="border: 1px dashed #ccc; padding: 5px; width:220px; text-align: center;">
사진 drop 영역
</div>
</div>
<div class="d-flex mt-2 justify-content-center">
<!-- 파일 목록 표시 -->
<div id="displayFile"></div>
</div>
</div>
</div>
<?php if($QCadmin) { ?>
<button class="btn btn-primary btn-sm me-1 ms-2 approvalBtn" ><i class="bi bi-award-fill"></i> 승인 </button>
<?php } ?>
<button type="button" class="btn btn-danger btn-sm me-1 ms-1 initialBtn" > <i class="bi bi-arrow-counterclockwise"></i> 초기화 </button>
<button type="button" class="btn btn-dark btn-sm me-1 ms-1 saveData" > <i class="bi bi-floppy2-fill"></i> 저장 </button>
<button type="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 me-1 ms-1" onclick="self.close();"> <i class="bi bi-x-lg"></i> 닫기 </button>&nbsp;
</div>
</div>
<div class="container mt-2">
<table class="table table-bordered">
<thead class="table-light">
<tr>
<th>요청일</th>
<th>페이지 이동</th>
<th>사진 등록 미완료 페이지</th>
</tr>
</thead>
<tbody>
<tr>
<!-- 요청일 -->
<td>
<span class="border d-flex justify-content-center align-items-center p-2">
<input type="date" id="ACIaskDate" name="ACIaskDate" class="form-control text-center noborder-input w-auto" autocomplete="off" value="<?=$ACIaskDate?>">
</span>
</td>
<!-- 페이지 이동 -->
<td>
<div class="d-flex justify-content-center align-items-center">
<!-- 왼쪽 화살표 -->
<button type="button" class="btn btn-outline-primary btn-sm" id="prevPage">
<i class="bi bi-arrow-left"></i>
</button>
<!-- 현재 페이지 표시 (select로 변환) -->
<select id="pageSelect" class="form-select mx-3 w-auto">
<?php for ($i = 1; $i <= $lotVolumn; $i++): ?>
<option value="<?= $i ?>" <?= $i == $page ? 'selected' : '' ?>><?= $i ?></option>
<?php endfor; ?>
</select><span class="mx-3 fs-6">/ &nbsp; <?=$lotVolumn?></span>
<!-- 오른쪽 화살표 -->
<button type="button" class="btn btn-outline-primary btn-sm" id="nextPage">
<i class="bi bi-arrow-right"></i>
</button>
</div>
</td>
<!-- 사진 등록 미완료 페이지 -->
<td>
<div class="text-center" id="missingPagesContainer">
<div id="missingPagesButtons" class="mt-2"></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div id="content-to-print">
<br>
<div class="container mt-1">
<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-1 me-1 fs-2" > 제 </span>
<span class="text-dark me-1 fs-2" > 품</span>
<span class="text-dark me-1 fs-2" > 검 </span>
<span class="text-dark me-1 fs-2" > 사 </span>
<span class="text-dark me-1 fs-2" > </span>
<span class="text-dark me-1 fs-2" > 성 </span>
<span class="text-dark me-1 fs-2" > 적 </span>
<span class="text-dark me-1 fs-2" > 서 </span>
</div>
</div>
</div>
</th>
<th rowspan="3" class="text-center fw-bold" style="height:100px;"> 결<br>재</th>
<th class="text-center p-1" style="width : 100px; height:22px; padding:2px;"> <span id="editButton" > 작성 </span> </th>
<th class="text-center p-1" style="width : 100px; height:22px; padding:2px;"> 승인 </th>
</tr>
<tr style="height:40px;">
<th class="text-center">
<div id="chargedDiv">
<span id="writer"> <?= htmlspecialchars($writerName) ?> </span> <br>
<span id="writerDate"> <?= htmlspecialchars($inspectionDate) ?> </span>
</div>
</th>
<th class="text-center">
<div id="approvalDiv">
<span id="approval"> <?= htmlspecialchars($approvalName) ?> </span> <br>
<span id="approvalDate">
<?= htmlspecialchars($approvalDate) ?>
<?php if(!empty($approvalDate)): ?>
<i class="bi bi-x-circle remove-approval" style="cursor: pointer;"></i>
<?php endif; ?>
</span>
</div>
</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;">
<tbody>
<tr>
<td class="text-center align-middle w100px">상 품 명</td>
<td class="text-center fw-bold"><?=$prodName?></td>
<td class="text-center align-middle w100px">제품 LOT NO</td>
<td class="text-center text-primary fw-bold">
<?= $lotNum ?>-<?= str_pad($page, 2, "0", STR_PAD_LEFT) ?>
</td>
</tr>
<tr>
<td class="text-center align-middle ">제 품 명</td>
<td class="text-center fw-bold"><?=$prodCode?></td>
<td class="text-center align-middle ">로트크기</td>
<td class="text-center text-dark fw-bold">
<input type="text" class="form-control text-center noborder-input" id="lotVolumn" name="lotVolumn" value="<?=$lotVolumn?> EA" autocomplete="off">
</td>
</tr>
<tr>
<td class="text-center align-middle ">발주처</td>
<td class="text-center text-secondary fw-bold"><?=$secondord?> </td>
<td class="text-center align-middle ">검사일자</td>
<td class="text-center">
<input type="text" class="form-control text-center noborder-input" id="inspectionDate" name="inspectionDate" value="<?=$inspectionDate?>" autocomplete="off">
</td>
</tr>
<tr>
<td class="text-center align-middle ">현장명</td>
<td class="text-center text-dark fw-bold"><?=$outworkplace?> </td>
<td class="text-center align-middle ">검사자</td>
<td class="text-center">
<div class="d-flex justify-content-center">
<div id="inspectionDiv" >
<input type="text" id="userNameInput" name="userNameInput" class="form-control d-inline-block noborder-input text-center" style="width:100px;" autocomplete="off" value="<?=$userNameInput?>">
<button type="button" id="cancelButton" class="btn btn-outline-danger btn-sm"> <i class="bi bi-x"> </i> </button>
</div>
</div>
</td>
</tr>
<tr>
<td class="text-center align-middle blueBlackBold ">제품사진</td>
<td class="text-center" colspan="3" >
<div class="d-flex justify-content-center">
<img src="img/<?=$prodCode?>.jpg" style="width:100%; height:auto;">
</div>
</td>
</tr>
<script>
$(document).ready(function() {
// '검사자' 버튼 클릭 시
$('#editButton').on('click', function() {
// 입력 필드 표시 및 버튼 숨기기
$('#inspectionDiv').show();
$('#chargedDiv').show();
// 작성자와 작성일 표시
const userName = '<?=$user_name?>'; // PHP에서 로그인 사용자 이름 가져오기
const today = new Date();
const todayStr = '<?=$todayStr?>';
const formattedDate = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, '0')}-${String(today.getDate()).padStart(2, '0')}`;
$('#writer').text(userName);
$('#writerDate').text(todayStr);
// 검사일자 설정
$('#inspectionDate').val(formattedDate);
$('#userNameInput').val(userName);
});
// '취소' 버튼 클릭 시
$('#cancelButton').on('click', function() {
// 입력 필드 숨기기 및 버튼 표시
$('#inspectionDivBtn').show();
// 데이터 초기화
$('#writer').text('');
$('#writerDate').text('');
$('#userNameInput').val('');
$('#inspectionDate').val('');
});
});
</script>
</tbody>
</table>
</div>