- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경 - DB 연결 하드코딩 → .env 기반으로 변경 - MySQL strict mode DATE 오류 수정
278 lines
11 KiB
PHP
278 lines
11 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;
|
|
}
|
|
ini_set('display_errors', 1);
|
|
ini_set('display_startup_errors', 1);
|
|
error_reporting(E_ALL);
|
|
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/load_header.php';
|
|
$title_message = '자동방화셔터 품질관리서';
|
|
?>
|
|
<title> <?=$title_message?> </title>
|
|
</head>
|
|
<body>
|
|
<?php require_once($_SERVER['DOCUMENT_ROOT'] . '/myheader.php'); ?>
|
|
<?php require_once($_SERVER['DOCUMENT_ROOT'] . '/mymodal.php'); ?>
|
|
|
|
<?php
|
|
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
|
$pdo = db_connect();
|
|
|
|
// 검색 날짜 파라미터 (GET)
|
|
$fromdate = isset($_REQUEST['fromdate']) ? $_REQUEST['fromdate'] : '';
|
|
$todate = isset($_REQUEST['todate']) ? $_REQUEST['todate'] : '';
|
|
$search = $_REQUEST['search'] ?? '';
|
|
$currentDate = date("Y-m-d");
|
|
if (empty($fromdate) || empty($todate)) {
|
|
$fromdate = date("Y-m-d", strtotime("-6 months", strtotime($currentDate)));
|
|
$todate = date("Y-m-d", strtotime("+3 months", strtotime($currentDate)));
|
|
}
|
|
|
|
// 유틸리티 함수: inputValue 배열에서 특정 id의 값을 찾음
|
|
function getInputValue($inputArray, $id) {
|
|
foreach ($inputArray as $item) {
|
|
if ($item['id'] === $id) {
|
|
return $item['value'];
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
|
|
// JSON 파일들이 저장된 폴더 (서버 경로)
|
|
// 주의: 현재 스크립트의 위치에 따라 경로를 조정합니다.
|
|
$jsonDir = $_SERVER['DOCUMENT_ROOT'] . "/output/qc_json/";
|
|
$jsonFiles = glob($jsonDir . "*.json");
|
|
|
|
$records = array();
|
|
foreach ($jsonFiles as $file) {
|
|
$jsonContent = file_get_contents($file);
|
|
$data = json_decode($jsonContent, true);
|
|
if (!$data) continue;
|
|
// "inputValue" 배열에 필요한 정보가 저장되어 있음.
|
|
$inputValue = isset($data['inputValue']) ? $data['inputValue'] : array();
|
|
$ACIregDate = getInputValue($inputValue, "ACIregDate");
|
|
// 날짜 필터: ACIregDate가 존재하고, fromdate <= ACIregDate <= todate
|
|
if (!empty($ACIregDate) && $ACIregDate >= $fromdate && $ACIregDate <= $todate) {
|
|
$record = array(
|
|
"ACIregDate" => $ACIregDate,
|
|
"groupCode" => getInputValue($inputValue, "groupCode"),
|
|
"outworkplace" => getInputValue($inputValue, "outworkplace"),
|
|
"secondord" => getInputValue($inputValue, "secondord"),
|
|
"outdate" => getInputValue($inputValue, "outdate"),
|
|
"lotVolumn" => getInputValue($inputValue, "lotVolumn")
|
|
);
|
|
|
|
// 검색어가 있을 경우, outworkplace와 secondord 필드 중 하나라도 검색어를 포함하는지 확인
|
|
if (!empty($search)) {
|
|
if (stripos($record['outworkplace'], $search) === false && stripos($record['secondord'], $search) === false) {
|
|
continue; // 검색어가 없으면 이 레코드는 건너뜁니다.
|
|
}
|
|
}
|
|
|
|
// 추가 필드도 필요하면 여기에 추가합니다.
|
|
$records[] = $record;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 내림차순 정렬 (접수일 기준)
|
|
usort($records, function($a, $b) {
|
|
return strcmp($b["ACIregDate"], $a["ACIregDate"]);
|
|
});
|
|
|
|
$total_row = count($records);
|
|
?>
|
|
|
|
<form id="board_form" name="board_form" method="post" >
|
|
<input type="hidden" id="mode" name="mode" value="<?=$mode?>">
|
|
<input type="hidden" id="num" name="num">
|
|
<input type="hidden" id="header" name="header" value="<?=$header?>">
|
|
|
|
<div class="container">
|
|
<div class="card mb-2 mt-2">
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-sm-7">
|
|
<div class="d-flex p-1 m-1 mt-1 justify-content-end align-items-center ">
|
|
<h5> <?=$title_message?> </h5>
|
|
<button type="button" class="btn btn-dark btn-sm " onclick='location.reload();' > <i class="bi bi-arrow-clockwise"></i> </button>
|
|
</div>
|
|
</div>
|
|
<div class="col-sm-5">
|
|
<div class="d-flex justify-content-end align-items-center ">
|
|
<h5> <span id="total_screen" class="text-primary me-2"></span>
|
|
<span id="total_screen_m2" class="badge bg-primary me-5"></span>
|
|
<span id="total_egi" class="text-secondary me-2"></span>
|
|
<span id="total_egi_m2" class="badge bg-secondary me-2"></span>
|
|
</h5>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="d-flex p-1 m-1 mt-1 mb-1 justify-content-center align-items-center">
|
|
▷ <?= $total_row ?>
|
|
|
|
<!-- 작년 분기 버튼 -->
|
|
<button type="button" class="btn btn-outline-secondary btn-sm me-1" onclick="setLastYearQuarter(1)">작년 1분기</button>
|
|
<button type="button" class="btn btn-outline-secondary btn-sm me-1" onclick="setLastYearQuarter(2)">작년 2분기</button>
|
|
<button type="button" class="btn btn-outline-secondary btn-sm me-1" onclick="setLastYearQuarter(3)">작년 3분기</button>
|
|
<button type="button" class="btn btn-outline-secondary btn-sm me-1" onclick="setLastYearQuarter(4)">작년 4분기</button>
|
|
<!-- 올해 분기 버튼 -->
|
|
<button type="button" class="btn btn-outline-dark btn-sm me-1" onclick="setQuarter(1)">1분기</button>
|
|
<button type="button" class="btn btn-outline-dark btn-sm me-1" onclick="setQuarter(2)">2분기</button>
|
|
<button type="button" class="btn btn-outline-dark btn-sm me-1" onclick="setQuarter(3)">3분기</button>
|
|
<button type="button" class="btn btn-outline-dark btn-sm me-1" onclick="setQuarter(4)">4분기</button>
|
|
|
|
<!-- 반기 버튼 -->
|
|
<button type="button" class="btn btn-dark btn-sm me-1" onclick="setHalfYear(1)">상반기</button>
|
|
<button type="button" class="btn btn-dark btn-sm me-1" onclick="setHalfYear(2)">하반기</button>
|
|
|
|
<!-- 날짜 입력 -->
|
|
<input type="date" id="fromdate" name="fromdate" class="form-control" style="width:100px;" value="<?= $fromdate ?>"> ~
|
|
<input type="date" id="todate" name="todate" class="form-control me-1" style="width:100px;" value="<?= $todate ?>">
|
|
|
|
<!-- 검색 -->
|
|
<div class="inputWrap">
|
|
<input type="text" id="search" name="search" value="<?=$search?>" onkeydown="JavaScript:SearchEnter();" autocomplete="off" class="form-control mx-1" style="width:150px;height:30px;" >
|
|
<button class="btnClear"></button>
|
|
</div>
|
|
<button id="searchBtn" type="button" class="btn btn-dark btn-sm"><i class="bi bi-search"></i> 검색 </button>
|
|
</div>
|
|
</div>
|
|
</div> <!--card-body-->
|
|
</div> <!--card -->
|
|
</div> <!--container-fluid -->
|
|
|
|
<div class="container-fluid">
|
|
<table class="table table-hover" id="myTable">
|
|
<thead class="table-primary">
|
|
<tr>
|
|
<th class="text-center" style="width:50px;">번호</th>
|
|
<th class="text-center" style="width:80px;">접수일</th>
|
|
<th class="text-center" style="width:120px;">품질관리서 번호</th>
|
|
<th class="text-center" style="width:150px;">현장명</th>
|
|
<th class="text-center" style="width:100px;">발주처</th>
|
|
<th class="text-center" style="width:80px;">출고일</th>
|
|
<th class="text-center" style="width:60px;">수량</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
if ($total_row > 0) {
|
|
$i = 1;
|
|
foreach ($records as $record) {
|
|
// 포맷: 접수일 날짜 뒤에 요일을 추가하고 싶다면 추가 처리 가능
|
|
$ACIregDate = $record["ACIregDate"];
|
|
$groupCode = $record["groupCode"];
|
|
$outworkplace = $record["outworkplace"];
|
|
$secondord = $record["secondord"];
|
|
$outdate = $record["outdate"];
|
|
$lotVolumn = $record["lotVolumn"];
|
|
echo "<tr onclick=\"redirectToView('{$groupCode}')\">";
|
|
echo "<td class=\"text-center\">{$i}</td>";
|
|
echo "<td class=\"text-center\">{$ACIregDate}</td>";
|
|
echo "<td class=\"text-center\">{$groupCode}</td>";
|
|
echo "<td class=\"text-center\">{$outworkplace}</td>";
|
|
echo "<td class=\"text-center\">{$secondord}</td>";
|
|
echo "<td class=\"text-center\">{$outdate}</td>";
|
|
echo "<td class=\"text-center\">{$lotVolumn}</td>";
|
|
echo "</tr>";
|
|
$i++;
|
|
}
|
|
} else {
|
|
echo "<tr><td colspan='7' class='text-center'>검색된 자료가 없습니다.</td></tr>";
|
|
}
|
|
?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
</form>
|
|
|
|
<script>
|
|
// 페이지 로딩
|
|
$(document).ready(function(){
|
|
var loader = document.getElementById('loadingOverlay');
|
|
if(loader)
|
|
loader.style.display = 'none';
|
|
});
|
|
|
|
var dataTable; // DataTables 인스턴스 전역 변수
|
|
var QClistpageNumber; // 현재 페이지 번호 저장을 위한 전역 변수
|
|
|
|
$(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('QClistpageNumber');
|
|
if (savedPageNumber) {
|
|
dataTable.page(parseInt(savedPageNumber) - 1).draw(false);
|
|
}
|
|
|
|
// 페이지 변경 이벤트 리스너
|
|
dataTable.on('page.dt', function() {
|
|
var QClistpageNumber = dataTable.page.info().page + 1;
|
|
setCookie('QClistpageNumber', QClistpageNumber, 10); // 쿠키에 페이지 번호 저장
|
|
});
|
|
|
|
// 페이지 길이 셀렉트 박스 변경 이벤트 처리
|
|
$('#myTable_length select').on('change', function() {
|
|
var selectedValue = $(this).val();
|
|
dataTable.page.len(selectedValue).draw(); // 페이지 길이 변경 (DataTable 파괴 및 재초기화 없이)
|
|
|
|
// 변경 후 현재 페이지 번호 복원
|
|
savedPageNumber = getCookie('QClistpageNumber');
|
|
if (savedPageNumber) {
|
|
dataTable.page(parseInt(savedPageNumber) - 1).draw(false);
|
|
}
|
|
});
|
|
|
|
});
|
|
|
|
function restorePageNumber() {
|
|
var savedPageNumber = getCookie('QClistpageNumber');
|
|
// if (savedPageNumber) {
|
|
// dataTable.page(parseInt(savedPageNumber) - 1).draw('page');
|
|
// }
|
|
location.reload(true);
|
|
}
|
|
|
|
function redirectToView(groupCode) {
|
|
let url;
|
|
|
|
url = "view_QCcertificate.php?groupCode=" + encodeURIComponent(groupCode) ;
|
|
|
|
customPopup(url, '', 800, 900);
|
|
}
|
|
|
|
|
|
function submitForm(status) {
|
|
$('input[name=status_option]').val(status);
|
|
document.getElementById('board_form').submit();
|
|
}
|
|
|
|
$(document).ready(function(){
|
|
// 방문기록 남김
|
|
var title = '<?php echo $title_message; ?>';
|
|
saveMenuLog(title);
|
|
});
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|