초기 커밋: 5130 레거시 시스템
- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경 - DB 연결 하드코딩 → .env 기반으로 변경 - MySQL strict mode DATE 오류 수정
This commit is contained in:
16
annualleave/_request.php
Normal file
16
annualleave/_request.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
$num = isset($_REQUEST["num"]) ? $_REQUEST["num"] : '';
|
||||
$author_id = isset($_REQUEST["author_id"]) ? $_REQUEST["author_id"] : ''; // Using corrected key
|
||||
$author = isset($_REQUEST["author"]) ? $_REQUEST["author"] : '';
|
||||
$al_company = isset($_REQUEST["al_company"]) ? $_REQUEST["al_company"] : '';
|
||||
$al_part = isset($_REQUEST["al_part"]) ? $_REQUEST["al_part"] : '';
|
||||
$registdate = isset($_REQUEST["registdate"]) ? $_REQUEST["registdate"] : '';
|
||||
$al_item = isset($_REQUEST["al_item"]) ? $_REQUEST["al_item"] : '';
|
||||
$al_askdatefrom = isset($_REQUEST["al_askdatefrom"]) ? $_REQUEST["al_askdatefrom"] : '';
|
||||
$al_askdateto = isset($_REQUEST["al_askdateto"]) ? $_REQUEST["al_askdateto"] : '';
|
||||
$al_usedday = isset($_REQUEST["al_usedday"]) ? $_REQUEST["al_usedday"] : '';
|
||||
$al_content = isset($_REQUEST["al_content"]) ? $_REQUEST["al_content"] : '';
|
||||
$status = isset($_REQUEST["status"]) ? $_REQUEST["status"] : '';
|
||||
$e_confirm = isset($_REQUEST["e_confirm"]) ? $_REQUEST["e_confirm"] : '';
|
||||
$e_confirm_id = isset($_REQUEST["e_confirm_id"]) ? $_REQUEST["e_confirm_id"] : '';
|
||||
?>
|
||||
18
annualleave/_row.php
Normal file
18
annualleave/_row.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
$num = isset($row["num"]) ? $row["num"] : '';
|
||||
$name = isset($row["name"]) ? $row["name"] : '';
|
||||
$company = isset($row["company"]) ? $row["company"] : '';
|
||||
$part = isset($row["part"]) ? $row["part"] : '';
|
||||
$dateofentry = isset($row["dateofentry"]) ? $row["dateofentry"] : '';
|
||||
$referencedate = isset($row["referencedate"]) ? $row["referencedate"] : date('Y');
|
||||
$availableday = isset($row["availableday"]) ? $row["availableday"] : 0;
|
||||
$comment = isset($row["comment"]) ? $row["comment"] : '';
|
||||
$is_deleted = isset($row["is_deleted"]) ? $row["is_deleted"] : '';
|
||||
$update_log = isset($row["update_log"]) ? $row["update_log"] : '';
|
||||
|
||||
// 새로 추가된 컬럼들
|
||||
$years_of_service = isset($row["years_of_service"]) ? $row["years_of_service"] : '';
|
||||
$initial_less_than_one_year = isset($row["initial_less_than_one_year"]) ? $row["initial_less_than_one_year"] : '';
|
||||
$service_based = isset($row["service_based"]) ? $row["service_based"] : '';
|
||||
$previous_year_usage = isset($row["previous_year_usage"]) ? $row["previous_year_usage"] : '';
|
||||
?>
|
||||
470
annualleave/admin.php
Normal file
470
annualleave/admin.php
Normal file
@@ -0,0 +1,470 @@
|
||||
<?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;
|
||||
}
|
||||
$title_message = '연차 관리자모드';
|
||||
$tablename = 'almember';
|
||||
|
||||
include $_SERVER['DOCUMENT_ROOT'] . '/load_header.php';
|
||||
?>
|
||||
|
||||
<title><?= $title_message ?></title>
|
||||
|
||||
<body>
|
||||
<?php if($mycompany ==='경동')
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . '/myheader.php');
|
||||
else
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . '/myheader1.php');
|
||||
?>
|
||||
</head>
|
||||
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/common.php");
|
||||
|
||||
// 테스트 예제
|
||||
// $fiscalYearEnd = "2024-12-31"; // 현재 기준 회계년도말
|
||||
// 현재 연도를 가져온 후, 이전 연도의 마지막 날을 생성
|
||||
// $fiscalYearEnd = (date('Y') - 1) . "-12-31";
|
||||
|
||||
// // 입사일 배열
|
||||
// $hireDates = [
|
||||
// "2024-12-2", "2024-12-5", "2024-11-21", "2024-6-17", "2022-6-8",
|
||||
// "2022-10-11", "2022-10-17", "2020-3-6", "2020-8-1", "2021-1-7",
|
||||
// "2021-1-25", "2021-3-22", "2021-6-24", "2021-9-13", "2021-10-1",
|
||||
// "2020-5-1", "2019-4-1", "2019-12-9", "2023-3-6", "2017-11-1",
|
||||
// "2023-4-3", "2016-11-14", "2015-7-14", "2024-4-9", "2023-7-3",
|
||||
// "2023-7-24", "2023-8-1", "2023-8-1", "2024-3-4", "2023-9-1",
|
||||
// "2024-2-5"
|
||||
// ];
|
||||
|
||||
// foreach ($hireDates as $hireDate) {
|
||||
// $result = calculateAnnualLeave($hireDate, $fiscalYearEnd);
|
||||
// echo "입사일: $hireDate, 근속연수: {$result['G']}, 최초1,2년미만 가산: {$result['H']}, 년도별 연차일수: {$result['I']}, 총발생일수: {$result['J']}<br>";
|
||||
// }
|
||||
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
|
||||
// 검색 조건 변수 추가
|
||||
$mode = isset($_REQUEST["mode"]) ? $_REQUEST["mode"] : "";
|
||||
$search = isset($_REQUEST["search"]) ? $_REQUEST["search"] : "";
|
||||
$corpSearch = isset($_REQUEST["corpSearch"]) ? $_REQUEST["corpSearch"] : $mycompany ;
|
||||
$partSearch = isset($_REQUEST["partSearch"]) ? $_REQUEST["partSearch"] : "";
|
||||
|
||||
|
||||
$year = isset($_REQUEST["year"]) ? $_REQUEST["year"] : date("Y");
|
||||
$showRetired = isset($_POST['showRetired']) ? $_POST['showRetired'] : 0;
|
||||
|
||||
// JSON 파일에서 소속 및 부서 데이터 로드
|
||||
$corpFile = $_SERVER['DOCUMENT_ROOT'] . '/member/corp.json';
|
||||
$corpData = file_exists($corpFile) ? json_decode(file_get_contents($corpFile), true) : [];
|
||||
if (!is_array($corpData)) $corpData = [];
|
||||
|
||||
$partFile = $_SERVER['DOCUMENT_ROOT'] . '/member/part.json';
|
||||
$partData = file_exists($partFile) ? json_decode(file_get_contents($partFile), true) : [];
|
||||
if (!is_array($partData)) $partData = [];
|
||||
|
||||
// 기본 SQL 조건
|
||||
$conditions = ["referencedate = :year", "is_deleted IS NULL"];
|
||||
$bindParams = [':year' => $year];
|
||||
|
||||
if (!$showRetired) {
|
||||
$conditions[] = "(comment IS NULL OR comment = '')";
|
||||
} else {
|
||||
$conditions[] = "comment = '퇴사'";
|
||||
}
|
||||
|
||||
// 검색 조건 추가
|
||||
if ($mode == "search") {
|
||||
if (!empty($search)) {
|
||||
$columns = [];
|
||||
$stmt = $pdo->query("SHOW COLUMNS FROM " . $DB . "." . $tablename);
|
||||
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
$columns[] = $row['Field'];
|
||||
}
|
||||
$searchConditions = [];
|
||||
foreach ($columns as $index => $col) {
|
||||
$paramName = ":search{$index}";
|
||||
$searchConditions[] = "$col LIKE $paramName";
|
||||
$bindParams[$paramName] = "%$search%";
|
||||
}
|
||||
$conditions[] = "(" . implode(" OR ", $searchConditions) . ")";
|
||||
}
|
||||
if (!empty($corpSearch)) {
|
||||
$conditions[] = "company LIKE :corpSearch";
|
||||
$bindParams[":corpSearch"] = "%$corpSearch%";
|
||||
}
|
||||
if (!empty($partSearch)) {
|
||||
$conditions[] = "part LIKE :partSearch";
|
||||
$bindParams[":partSearch"] = "%$partSearch%";
|
||||
}
|
||||
}
|
||||
|
||||
// almember의 기본정보 배열을 불러옴 (예, $basic_name_arr, $basic_part_arr 등)
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/almember/load_DB.php");
|
||||
|
||||
// echo '<pre>';
|
||||
// print_r($previous_year_usage_arr);
|
||||
// echo '</pre>';
|
||||
|
||||
$sql = "SELECT * FROM {$DB}.almember WHERE " . implode(" AND ", $conditions) . " ORDER BY referencedate DESC, dateofentry ASC, num DESC";
|
||||
$stmh = $pdo->prepare($sql);
|
||||
$stmh->execute($bindParams);
|
||||
$total_row = $stmh->rowCount();
|
||||
|
||||
// print $admin;
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<form name="board_form" id="board_form" method="post" action="admin.php?mode=search">
|
||||
<input type="hidden" id="ALadmin" name="ALadmin" value="<?=$ALadmin?>">
|
||||
<div class="container">
|
||||
<div class="card mt-2 mb-4">
|
||||
<div class="card-body">
|
||||
<div class="d-flex mt-3 mb-3 justify-content-center align-items-center">
|
||||
<span class="text-dark 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>
|
||||
<button type="button" id="backBtn" class="btn btn-outline-primary btn-sm mx-2" > <ion-icon name="caret-back-circle-outline"></ion-icon> 이전화면 </button>
|
||||
</div>
|
||||
<div class="d-flex mt-3 mb-3 justify-content-center align-items-center">
|
||||
<span class="text-secondary fs-6" > 주일/경동 연차는 (회계년도말) 기준으로 산정한다. </span>
|
||||
</div>
|
||||
<div class="d-flex mt-3 justify-content-center align-items-center">
|
||||
<i class="bi bi-caret-right"></i> <?= $total_row ?>개
|
||||
<!-- 퇴사자 체크박스 -->
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" id="showRetired" name="showRetired" value=1 onchange="filterRetired()" <?php echo isset($_POST['showRetired']) && $_POST['showRetired'] == 1 ? 'checked' : ''; ?>>
|
||||
<label class="form-check-label mx-2" for="showRetired">퇴사자 보기</label>
|
||||
</div>
|
||||
|
||||
<span class="mx-1"> 선택년도</span>
|
||||
<select name="year" id="year" class="form-select w80px mx-1" style="font-size: 0.8rem; height: 32px;">
|
||||
<?php
|
||||
$current_year = date("Y"); // 현재 년도를 얻습니다.
|
||||
$year_arr = array(); // 빈 배열을 생성합니다.
|
||||
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
$year_arr[] = $current_year - $i;
|
||||
}
|
||||
for($i=0;$i<count($year_arr);$i++) {
|
||||
if($year==$year_arr[$i])
|
||||
print "<option selected value='" . $year_arr[$i] . "'> " . $year_arr[$i] . "</option>";
|
||||
else
|
||||
print "<option value='" . $year_arr[$i] . "'> " . $year_arr[$i] . "</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
|
||||
<!-- 소속 검색 select 추가 -->
|
||||
<div class="inputWrap30 mx-1">
|
||||
<select name="corpSearch" id="corpSearch" class="form-select w-auto mx-1" style="font-size: 0.8rem; height: 32px;">
|
||||
<option value=""><?= "(소속)" ?></option>
|
||||
<?php foreach($corpData as $corp): ?>
|
||||
<option value="<?= htmlspecialchars($corp, ENT_QUOTES, 'UTF-8') ?>" <?= ($corpSearch === $corp) ? 'selected' : '' ?>>
|
||||
<?= htmlspecialchars($corp, ENT_QUOTES, 'UTF-8') ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<!-- 부서 검색 select 추가 -->
|
||||
<div class="inputWrap30 mx-1">
|
||||
<select name="partSearch" id="partSearch" class="form-select w-auto mx-1" style="font-size: 0.8rem; height: 32px;">
|
||||
<option value=""><?= "(부서)" ?></option>
|
||||
<!-- 옵션은 JS에서 동적으로 채워짐 -->
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<input type="text" name="search" id="search" class="form-control mx-1" style="width:150px; height: 32px;" value="<?=$search?>" onkeydown="JavaScript:SearchEnter();" placeholder="검색어" autocomplete="off" >
|
||||
|
||||
<button type="button" id="searchBtn" class="btn btn-dark btn-sm mx-1" > <i class="bi bi-search"></i> 검색 </button>
|
||||
<?php if (intval($ALadmin) == 1 ) { ?>
|
||||
<button type="button" class="btn btn-dark btn-sm mx-1" onclick="popupCenter('write_form.php', '신규', 600, 400);return false;" > <i class="bi bi-pencil"></i> 신규 </button>
|
||||
<button type="button" class="btn btn-dark btn-sm mx-1" id="csvDownload" > <i class="bi bi-floppy-fill"></i> CSV </button>
|
||||
<button type="button" id="massBtn" class="btn btn-sm btn-primary mx-1"> <i class="bi bi-cloud-arrow-up"></i> 대량등록</button>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
<div class="row d-flex mt-3 mb-1 justify-content-center align-items-center">
|
||||
<table class="table table-hover" id="myTable">
|
||||
<thead class="table-primary">
|
||||
<tr>
|
||||
<th class="text-center">번호</th>
|
||||
<th class="text-center">구분</th>
|
||||
<th class="text-center">성명</th>
|
||||
<th class="text-center">회사</th>
|
||||
<th class="text-center">파트</th>
|
||||
<th class="text-center">입사일</th>
|
||||
<th class="text-center">해당연도</th>
|
||||
<th class="text-center">근속년</th>
|
||||
<th class="text-center">1~2년미만 가산</th>
|
||||
<th class="text-center">근속년수별</th>
|
||||
<th class="text-center">발생일합</th>
|
||||
<th class="text-center">전년도 선사용</th>
|
||||
<th class="text-center">사용일 합계</th>
|
||||
<th class="text-center">잔여일</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$start_num = $total_row;
|
||||
while ($row = $stmh->fetch(PDO::FETCH_ASSOC)) {
|
||||
include "_row.php";
|
||||
|
||||
// 년도를 추출하여 -1을 적용
|
||||
// 문자열 연결 연산자 `.` 추가
|
||||
$fiscalYearEnd = ($referencedate - 1) . "-12-31";
|
||||
// echo '참고년도 : ' . $referencedate ;
|
||||
// echo '전년도 : ' . $fiscalYearEnd ;
|
||||
$result = calculateAnnualLeave($dateofentry, $fiscalYearEnd);
|
||||
$continueYear = $result['G'];
|
||||
$initial_less_than_one_year = $result['H'];
|
||||
$service_based = $result['I'];
|
||||
$availableday = $result['J'];
|
||||
|
||||
$totalusedday = 0;
|
||||
$totalremainday = isset($availableday) ? $availableday : 0;
|
||||
|
||||
if (isset($totalname_arr) && is_array($totalname_arr) && count($totalname_arr) > 0) {
|
||||
for ($i = 0; $i < count($totalname_arr); $i++) {
|
||||
if (trim($name) == trim($totalname_arr[$i]) && $referencedate == $totalusedYear_arr[$i]) {
|
||||
$totalusedday = $totalused_arr[$i];
|
||||
$previous_year_usage = $previous_year_usage_arr[$i];
|
||||
$totalremainday = $availableday - $totalusedday - $previous_year_usage;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<tr onclick="redirectToView('<?= $row['num'] ?>', '<?= $tablename ?>')">
|
||||
<td class="text-center"><?=$start_num?> </td>
|
||||
<td class="text-center"><?=$comment?> </td>
|
||||
<td class="text-center"><?=$name?> </td>
|
||||
<td class="text-center"><?=$company?> </td>
|
||||
<td class="text-center"><?=$part?> </td>
|
||||
<td class="text-center"><?=$dateofentry?> </td>
|
||||
<td class="text-center"><?=$referencedate?> </td>
|
||||
<td class="text-center"><?= $continueYear ? $continueYear : '' ?> </td>
|
||||
<td class="text-center text-dark"><?= $initial_less_than_one_year ? $initial_less_than_one_year : '' ?> </td>
|
||||
<td class="text-center text-secondary"><b><?= $service_based ? $service_based : '' ?></b> </td>
|
||||
<td class="text-center text-primary"><b><?= $availableday ? $availableday : '' ?></b> </td>
|
||||
<td class="text-center "> <?= $previous_year_usage ? '<h6> <span class="badge bg-primary"> ' . $previous_year_usage . ' </span> </h6> ' : '' ?> </td>
|
||||
<td class="text-center text-success"><b><?= $totalusedday ? $totalusedday : '' ?></b> </td>
|
||||
<td class="text-center <?= ($totalremainday < 0) ? 'text-danger' : 'text-dark' ?>">
|
||||
<b><?= $totalremainday ?: '' ?></b>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
$start_num--;
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<br>
|
||||
<br>
|
||||
<div class="container">
|
||||
<? include '../footer.php'; ?>
|
||||
</div>
|
||||
|
||||
<!-- 페이지로딩 -->
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
var loader = document.getElementById('loadingOverlay');
|
||||
loader.style.display = 'none';
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
var dataTable; // DataTables 인스턴스 전역 변수
|
||||
var aladminpageNumber; // 현재 페이지 번호 저장을 위한 전역 변수
|
||||
|
||||
$(document).ready(function() {
|
||||
// DataTables 초기 설정
|
||||
dataTable = $('#myTable').DataTable({
|
||||
"paging": true,
|
||||
"ordering": true,
|
||||
"searching": false,
|
||||
"pageLength": 50,
|
||||
"lengthMenu": [25, 50, 100, 200, 500, 1000],
|
||||
"language": {
|
||||
"lengthMenu": "Show _MENU_ entries",
|
||||
"search": "Live Search:"
|
||||
},
|
||||
"order": [[0, 'desc']]
|
||||
});
|
||||
|
||||
// 페이지 번호 복원 (초기 로드 시)
|
||||
var savedPageNumber = getCookie('aladminpageNumber');
|
||||
if (savedPageNumber) {
|
||||
dataTable.page(parseInt(savedPageNumber) - 1).draw(false);
|
||||
}
|
||||
|
||||
// 페이지 변경 이벤트 리스너
|
||||
dataTable.on('page.dt', function() {
|
||||
var aladminpageNumber = dataTable.page.info().page + 1;
|
||||
setCookie('aladminpageNumber', aladminpageNumber, 10); // 쿠키에 페이지 번호 저장
|
||||
});
|
||||
|
||||
// 페이지 길이 셀렉트 박스 변경 이벤트 처리
|
||||
$('#myTable_length select').on('change', function() {
|
||||
var selectedValue = $(this).val();
|
||||
dataTable.page.len(selectedValue).draw(); // 페이지 길이 변경 (DataTable 파괴 및 재초기화 없이)
|
||||
|
||||
// 변경 후 현재 페이지 번호 복원
|
||||
savedPageNumber = getCookie('aladminpageNumber');
|
||||
if (savedPageNumber) {
|
||||
dataTable.page(parseInt(savedPageNumber) - 1).draw(false);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function restorePageNumber() {
|
||||
var savedPageNumber = getCookie('aladminpageNumber');
|
||||
if (savedPageNumber) {
|
||||
dataTable.page(parseInt(savedPageNumber) - 1).draw('page');
|
||||
}
|
||||
}
|
||||
|
||||
function SearchEnter(){
|
||||
if(event.keyCode == 13){
|
||||
document.getElementById('board_form').submit();
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
$('select[name="year"]').change(function(){
|
||||
var val = $('input[name="year"]:checked').val();
|
||||
document.getElementById('board_form').submit();
|
||||
});
|
||||
|
||||
$("#closeModalBtn").click(function(){
|
||||
$('#myModal').modal('hide');
|
||||
});
|
||||
|
||||
$("#searchBtn").click(function(){
|
||||
document.getElementById('board_form').submit();
|
||||
});
|
||||
|
||||
$("#backBtn").click(function(){
|
||||
location.href='/annualleave/index.php';
|
||||
});
|
||||
|
||||
$("#massBtn").click(function(){
|
||||
popupCenter('write_form_init.php', '연초 대량등록', 420, 800);
|
||||
});
|
||||
});
|
||||
|
||||
function redirectToView(num, tablename) {
|
||||
var ALadmin = document.getElementById("ALadmin").value; // hidden input의 값 가져오기
|
||||
|
||||
if (ALadmin != "1") {
|
||||
Swal.fire({
|
||||
title: '접근 제한',
|
||||
text: '관리자만 수정이 가능합니다.',
|
||||
icon: 'warning',
|
||||
confirmButtonText: '확인'
|
||||
});
|
||||
return; // 함수 실행 중지
|
||||
}
|
||||
|
||||
var url = "write_form.php?mode=modify&num=" + num + "&tablename=" + tablename;
|
||||
customPopup(url, '연차 수정', 600, 400);
|
||||
}
|
||||
|
||||
|
||||
document.getElementById("csvDownload").addEventListener("click", function() {
|
||||
const table = document.getElementById("myTable");
|
||||
const theadRow = table.querySelector("thead tr");
|
||||
const rows = table.querySelectorAll("tbody tr");
|
||||
|
||||
const csvRows = [];
|
||||
|
||||
// Include the header row
|
||||
const headerData = [];
|
||||
theadRow.querySelectorAll("th").forEach(function(cell) {
|
||||
headerData.push(cell.textContent);
|
||||
});
|
||||
csvRows.push(headerData.join(","));
|
||||
|
||||
// Include the data rows
|
||||
rows.forEach(function(row) {
|
||||
const rowData = [];
|
||||
row.querySelectorAll("td").forEach(function(cell) {
|
||||
rowData.push(cell.textContent);
|
||||
});
|
||||
csvRows.push(rowData.join(","));
|
||||
});
|
||||
|
||||
const csvContent = csvRows.join("\n");
|
||||
// 한글깨짐문제 '\ufeff' + data 이것 참조
|
||||
const blob = new Blob(['\ufeff' + csvContent], { type: "text/csv;charset=utf-8;" });
|
||||
const link = document.createElement("a");
|
||||
link.href = URL.createObjectURL(blob);
|
||||
link.setAttribute("download", "직원연차.csv");
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
});
|
||||
|
||||
function filterRetired() {
|
||||
// 퇴사자 체크박스 상태 확인
|
||||
// const showRetired = document.getElementById('showRetired').checked;
|
||||
document.getElementById('board_form').submit();
|
||||
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
var title = '<?=$title_message;?>';
|
||||
saveMenuLog(title);
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
// PHP의 부서 JSON 데이터를 JS 변수로 저장 (각 항목은 ['corp'=> ..., 'part'=> ...] 형식)
|
||||
var partData = <?= json_encode($partData) ?>;
|
||||
|
||||
// PHP에서 전달된 부서 검색 값 (기존에 선택된 값)
|
||||
var initialPart = "<?= htmlspecialchars($partSearch, ENT_QUOTES, 'UTF-8') ?>";
|
||||
|
||||
// 부서 select 업데이트 함수
|
||||
function updatePartSelect(selectedCorp) {
|
||||
var $partSelect = $('#partSearch');
|
||||
$partSelect.empty();
|
||||
$partSelect.append('<option value=""><?= "(부서)" ?></option>');
|
||||
// 선택된 소속과 일치하는 부서 옵션만 추가
|
||||
$.each(partData, function(index, dept) {
|
||||
if(dept.corp === selectedCorp) {
|
||||
$partSelect.append('<option value="'+ dept.part +'">'+ dept.part +'</option>');
|
||||
}
|
||||
});
|
||||
// 만약 초기 부서값이 있다면 선택
|
||||
if(initialPart !== "") {
|
||||
$partSelect.val(initialPart);
|
||||
}
|
||||
}
|
||||
|
||||
// 페이지 로드 시, 이미 소속이 선택되어 있다면 부서 옵션 업데이트
|
||||
var initialCorp = $('#corpSearch').val();
|
||||
updatePartSelect(initialCorp);
|
||||
|
||||
// 소속 select 변경 시 부서 select 업데이트
|
||||
$('#corpSearch').on('change', function(){
|
||||
var selectedCorp = $(this).val();
|
||||
updatePartSelect(selectedCorp);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
456
annualleave/batchDB.php
Normal file
456
annualleave/batchDB.php
Normal file
@@ -0,0 +1,456 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
$tablename = 'eworks';
|
||||
|
||||
include $_SERVER['DOCUMENT_ROOT'] . '/load_header.php' ?>
|
||||
|
||||
<title> 연차 사용 리스트 </title>
|
||||
</head>
|
||||
<?php
|
||||
|
||||
isset($_REQUEST["fromdate"]) ? $fromdate = $_REQUEST["fromdate"] : $fromdate="";
|
||||
isset($_REQUEST["todate"]) ? $todate = $_REQUEST["todate"] : $todate="";
|
||||
isset($_REQUEST["recordDate"]) ? $recordDate = $_REQUEST["recordDate"] : $recordDate=date("Y-m-d");
|
||||
|
||||
if(isset($_REQUEST["check"]))
|
||||
$check=$_REQUEST["check"]; // 미출고 리스트 request 사용 페이지 이동버튼 누를시`
|
||||
else
|
||||
$check=$_POST["check"]; // 미출고 리스트 POST사용
|
||||
|
||||
if(isset($_REQUEST["plan_output_check"]))
|
||||
$plan_output_check=$_REQUEST["plan_output_check"]; // 미출고 리스트 request 사용 페이지 이동버튼 누를시`
|
||||
else
|
||||
if(isset($_POST["plan_output_check"]))
|
||||
$plan_output_check=$_POST["plan_output_check"]; // 미출고 리스트 POST사용
|
||||
else
|
||||
$plan_output_check='0';
|
||||
|
||||
if(isset($_REQUEST["output_check"]))
|
||||
$output_check=$_REQUEST["output_check"]; // 출고완료
|
||||
else
|
||||
if(isset($_POST["output_check"]))
|
||||
$output_check=$_POST["output_check"]; // 출고완료
|
||||
else
|
||||
$output_check='0';
|
||||
|
||||
if(isset($_REQUEST["team_check"]))
|
||||
$team_check=$_REQUEST["team_check"]; // 시공팀미지정
|
||||
else
|
||||
if(isset($_POST["team_check"]))
|
||||
$team_check=$_POST["team_check"]; // 시공팀미지정
|
||||
else
|
||||
$team_check='0';
|
||||
|
||||
if(isset($_REQUEST["measure_check"]))
|
||||
$measure_check=$_REQUEST["measure_check"]; // 미실측리스트
|
||||
else
|
||||
if(isset($_POST["measure_check"]))
|
||||
$measure_check=$_POST["measure_check"]; // 미실측리스트
|
||||
else
|
||||
$measure_check='0';
|
||||
|
||||
if(isset($_REQUEST["page"])) // $_REQUEST["page"]값이 없을 때에는 1로 지정
|
||||
{
|
||||
$page=$_REQUEST["page"]; // 페이지 번호
|
||||
}
|
||||
else
|
||||
{
|
||||
$page=1;
|
||||
}
|
||||
|
||||
// print $output_check;
|
||||
|
||||
$cursort=$_REQUEST["cursort"]; // 현재 정렬모드 지정
|
||||
$sortof=$_REQUEST["sortof"]; // 클릭해서 넘겨준 값
|
||||
$stable=$_REQUEST["stable"]; // 정렬모드 변경할지 안할지 결정
|
||||
|
||||
if(isset($_REQUEST["sortof"]))
|
||||
{
|
||||
|
||||
if($sortof==1 and $stable==0) { //접수일 클릭되었을때
|
||||
|
||||
if($cursort!=1)
|
||||
$cursort=1;
|
||||
else
|
||||
$cursort=2;
|
||||
}
|
||||
if($sortof==2 and $stable==0) { //납기일 클릭되었을때
|
||||
|
||||
if($cursort!=3)
|
||||
$cursort=3;
|
||||
else
|
||||
$cursort=4;
|
||||
}
|
||||
if($sortof==3 and $stable==0) { //실측일 클릭되었을때
|
||||
|
||||
if($cursort!=5)
|
||||
$cursort=5;
|
||||
else
|
||||
$cursort=6;
|
||||
}
|
||||
if($sortof==4 and $stable==0) { //도면작성일 클릭되었을때
|
||||
|
||||
if($cursort!=7)
|
||||
$cursort=7;
|
||||
else
|
||||
$cursort=8;
|
||||
}
|
||||
if($sortof==5 and $stable==0) { //출고일 클릭되었을때
|
||||
|
||||
if($cursort!=9)
|
||||
$cursort=9;
|
||||
else
|
||||
$cursort=10;
|
||||
}
|
||||
if($sortof==6 and $stable==0) { //청구 클릭되었을때
|
||||
|
||||
if($cursort!=11)
|
||||
$cursort=11;
|
||||
else
|
||||
$cursort=12;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$sortof=0;
|
||||
$cursort=0;
|
||||
}
|
||||
|
||||
|
||||
$sum=array();
|
||||
|
||||
if(isset($_REQUEST["mode"]))
|
||||
$mode=$_REQUEST["mode"];
|
||||
else
|
||||
$mode="";
|
||||
|
||||
if(isset($_REQUEST["find"])) //목록표에 제목,이름 등 나오는 부분
|
||||
$find=$_REQUEST["find"];
|
||||
|
||||
if($fromdate=="")
|
||||
{
|
||||
$fromdate=substr(date("Y-m-d",time()),0,7) ;
|
||||
$fromdate=$fromdate . "-01";
|
||||
}
|
||||
if($todate=="")
|
||||
{
|
||||
$todate=date("Y-m-d");
|
||||
$Transtodate=strtotime($todate.'+1 days');
|
||||
$Transtodate=date("Y-m-d",$Transtodate);
|
||||
}
|
||||
else
|
||||
{
|
||||
$Transtodate=strtotime($todate);
|
||||
$Transtodate=date("Y-m-d",$Transtodate);
|
||||
}
|
||||
|
||||
if(isset($_REQUEST["search"])) //
|
||||
$search=$_REQUEST["search"];
|
||||
|
||||
$orderby=" order by al_askdateto desc ";
|
||||
|
||||
$now = date("Y-m-d"); // 현재 날짜와 크거나 같으면 출고예정으로 구분
|
||||
|
||||
if($mode=="search"){
|
||||
if($search==""){
|
||||
$sql="select * from " . $DB . "." . $tablename . " where al_askdateto between date('$fromdate') and date('$Transtodate') AND is_deleted IS NULL " . $orderby;
|
||||
}
|
||||
elseif($search!="")
|
||||
{
|
||||
$sql ="select * from " . $DB . "." . $tablename . " where ((author like '%$search%' ) or (al_askdateto like '%$search%' ) or (al_askdatefrom like '%$search%' )) ";
|
||||
$sql .=" and ( al_askdateto between date('$fromdate') and date('$Transtodate')) AND is_deleted IS NULL " . $orderby ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql="select * from " . $DB . "." . $tablename . " where al_askdateto between date('$fromdate') and date('$Transtodate') AND is_deleted IS NULL " . $orderby;
|
||||
}
|
||||
|
||||
require_once("../lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
|
||||
$counter=0;
|
||||
$num_arr=array();
|
||||
$id_arr=array();
|
||||
$name_arr=array();
|
||||
$part_arr=array();
|
||||
$registdate_arr=array();
|
||||
$item_arr=array();
|
||||
$al_askdatefrom_arr=array();
|
||||
$al_askdateto_arr=array();
|
||||
$usedday_arr=array();
|
||||
$content_arr=array();
|
||||
$state_arr=array();
|
||||
$sum1=0;
|
||||
$sum2=0;
|
||||
$sum3=0;
|
||||
|
||||
|
||||
try{
|
||||
|
||||
$stmh = $pdo->query($sql); // 검색조건에 맞는글 stmh
|
||||
$rowNum = $stmh->rowCount();
|
||||
|
||||
|
||||
while($row = $stmh->fetch(PDO::FETCH_ASSOC)) {
|
||||
|
||||
include 'rowDBask.php';
|
||||
|
||||
array_push($num_arr,$num);
|
||||
array_push($id_arr,$author_id);
|
||||
array_push($name_arr,$author);
|
||||
array_push($part_arr,$al_part);
|
||||
array_push($registdate_arr,$registdate);
|
||||
array_push($item_arr,$al_item);
|
||||
array_push($al_askdatefrom_arr,$al_askdatefrom);
|
||||
array_push($al_askdateto_arr,$al_askdateto);
|
||||
array_push($usedday_arr,$al_usedday);
|
||||
array_push($content_arr,$al_content);
|
||||
|
||||
switch($status) {
|
||||
|
||||
case 'send':
|
||||
$statusstr = '결재상신';
|
||||
break;
|
||||
case 'ing':
|
||||
$statusstr = '결재중';
|
||||
break;
|
||||
case 'end':
|
||||
$statusstr = '결재완료';
|
||||
break;
|
||||
default:
|
||||
$statusstr = '';
|
||||
break;
|
||||
}
|
||||
|
||||
array_push($state_arr,$statusstr);
|
||||
|
||||
}
|
||||
} catch (PDOException $Exception) {
|
||||
print "오류: ".$Exception->getMessage();
|
||||
}
|
||||
$all_sum=$sum1 + $sum2 + $sum3;
|
||||
|
||||
?>
|
||||
|
||||
<form name="board_form" id="board_form" method="post" action="batchDB.php?mode=search&year=<?=$year?>&search=<?=$search?>&process=<?=$process?>&asprocess=<?=$asprocess?>&fromdate=<?=$fromdate?>&todate=<?=$todate?>&up_fromdate=<?=$up_fromdate?>&up_todate=<?=$up_todate?>&separate_date=<?=$separate_date?>&view_table=<?=$view_table?>">
|
||||
<div class="container-fluid">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
|
||||
<div class="d-flex mb-1 mt-2 justify-content-center align-items-center">
|
||||
|
||||
<span class="badge bg-primary fs-6 "> 직원 연차 list </span>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="d-flex mt-1 mb-2 justify-content-center align-items-center ">
|
||||
<!-- 기간설정 칸 -->
|
||||
<?php include $_SERVER['DOCUMENT_ROOT'] . '/setdate.php' ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div> <!-- end of card-header -->
|
||||
|
||||
<div class="card-body">
|
||||
|
||||
<div id="grid" style="width:1250px;"></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of container -->
|
||||
</form> <!-- end of board_form -->
|
||||
|
||||
|
||||
<form id=Form1 name="Form1">
|
||||
<input type=hidden id="num_arr" name="num_arr[]" >
|
||||
<input type=hidden id="recordDate_arr" name="recordDate_arr[]">
|
||||
</form>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
|
||||
$("#searchBtn").click(function(){ document.getElementById('board_form').submit(); });
|
||||
|
||||
var arr1 = <?php echo json_encode($num_arr);?> ;
|
||||
|
||||
var numcopy = new Array(); ;
|
||||
|
||||
var arr2 = <?php echo json_encode($registdate_arr);?> ;
|
||||
var arr3 = <?php echo json_encode($al_askdatefrom_arr);?> ;
|
||||
var arr4 = <?php echo json_encode($al_askdateto_arr);?> ;
|
||||
var arr5 = <?php echo json_encode($usedday_arr);?> ;
|
||||
var arr6 = <?php echo json_encode($name_arr);?> ;
|
||||
var arr7 = <?php echo json_encode($state_arr);?> ;
|
||||
|
||||
|
||||
|
||||
var total_sum=0;
|
||||
|
||||
var rowNum = arr1.length;
|
||||
|
||||
const data = [];
|
||||
const columns = [];
|
||||
var count=0; // 전체줄수 카운트
|
||||
|
||||
for(i=0;i<rowNum;i++) {
|
||||
total_sum = total_sum + Number(uncomma(arr6[i]));
|
||||
row = { name: i };
|
||||
row[`col1`] = arr1[i] ;
|
||||
row[`col2`] = arr2[i] ;
|
||||
row[`col3`] = arr3[i] ;
|
||||
row[`col4`] = arr4[i] ;
|
||||
row[`col5`] = arr5[i] ;
|
||||
row[`col6`] = arr6[i] ;
|
||||
row[`col7`] = arr7[i] ;
|
||||
data.push(row);
|
||||
count++;
|
||||
}
|
||||
|
||||
|
||||
class CustomTextEditor {
|
||||
constructor(props) {
|
||||
const el = document.createElement('input');
|
||||
const { maxLength } = props.columnInfo.editor.options;
|
||||
|
||||
el.type = 'text';
|
||||
el.maxLength = maxLength;
|
||||
el.value = String(props.value);
|
||||
|
||||
this.el = el;
|
||||
}
|
||||
|
||||
getElement() {
|
||||
return this.el;
|
||||
}
|
||||
|
||||
getValue() {
|
||||
return this.el.value;
|
||||
}
|
||||
|
||||
mounted() {
|
||||
this.el.select();
|
||||
}
|
||||
}
|
||||
|
||||
const grid = new tui.Grid({
|
||||
el: document.getElementById('grid'),
|
||||
data: data,
|
||||
bodyHeight: 650,
|
||||
columns: [
|
||||
{
|
||||
header: '번호',
|
||||
name: 'col1',
|
||||
sortingType: 'desc',
|
||||
sortable: true,
|
||||
width:100,
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
header: '접수일',
|
||||
name: 'col2',
|
||||
color : 'red',
|
||||
sortingType: 'desc',
|
||||
sortable: true,
|
||||
width:150,
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
header: '시작일',
|
||||
name: 'col3',
|
||||
color : 'red',
|
||||
sortingType: 'desc',
|
||||
sortable: true,
|
||||
width:150,
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
header: '종료일',
|
||||
name: 'col4',
|
||||
sortingType: 'desc',
|
||||
sortable: true,
|
||||
width:150,
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
header: '사용일수',
|
||||
name: 'col5',
|
||||
width: 150,
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
header: '성명',
|
||||
name: 'col6',
|
||||
width:150,
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
header: '결재상태',
|
||||
name: 'col7',
|
||||
width:150,
|
||||
align: 'center'
|
||||
}
|
||||
],
|
||||
columnOptions: {
|
||||
resizable: true
|
||||
},
|
||||
rowHeaders: ['rowNum','checkbox'],
|
||||
pageOptions: {
|
||||
useClient: false,
|
||||
perPage: 20
|
||||
}
|
||||
});
|
||||
var Grid = tui.Grid; // or require('tui-grid')
|
||||
Grid.applyTheme('default', {
|
||||
cell: {
|
||||
normal: {
|
||||
background: '#fbfbfb',
|
||||
border: '#e0e0e0',
|
||||
showVerticalBorder: true
|
||||
},
|
||||
header: {
|
||||
background: '#eee',
|
||||
border: '#ccc',
|
||||
showVerticalBorder: true
|
||||
},
|
||||
rowHeader: {
|
||||
border: '#ccc',
|
||||
showVerticalBorder: true
|
||||
},
|
||||
editable: {
|
||||
background: '#fbfbfb'
|
||||
},
|
||||
selectedHeader: {
|
||||
background: '#d8d8d8'
|
||||
},
|
||||
focused: {
|
||||
border: '#418ed4'
|
||||
},
|
||||
disabled: {
|
||||
text: '#b0b0b0'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}); // end toast gui
|
||||
|
||||
|
||||
</script>
|
||||
161
annualleave/copy_data.php
Normal file
161
annualleave/copy_data.php
Normal file
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
isset($_REQUEST["num"]) ? $num=$_REQUEST["num"] : $num=$_REQUEST["num"];
|
||||
require_once("../lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
|
||||
try{
|
||||
$sql = "select * from mirae8440.almember where num = ? ";
|
||||
$stmh = $pdo->prepare($sql);
|
||||
$stmh->bindValue(1,$num,PDO::PARAM_STR);
|
||||
$stmh->execute();
|
||||
$count = $stmh->rowCount();
|
||||
$row = $stmh->fetch(PDO::FETCH_ASSOC); // $row 배열로 DB 정보를 불러온다.
|
||||
|
||||
include 'rowDB.php';
|
||||
|
||||
}catch (PDOException $Exception) {
|
||||
print "오류: ".$Exception->getMessage();
|
||||
}
|
||||
// end of if
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="ko">
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
|
||||
<!-- Bootstrap CSS -->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" >
|
||||
<!-- Optional JavaScript -->
|
||||
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" ></script>
|
||||
|
||||
</head>
|
||||
<style>
|
||||
|
||||
html,body {
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
<body>
|
||||
<div class="container h-50">
|
||||
<div class="row d-flex justify-content-center align-items-center h-100">
|
||||
<div class="col-1"></div>
|
||||
<div class="col-12 text-center">
|
||||
<div class="card align-middle" style="width:30rem; border-radius:20px;">
|
||||
<div class="card" style="padding:10px;margin:10px;">
|
||||
<h3 class="card-title text-center" style="color:#113366;"> 연차일수 정보 등록/조회/수정 </h3>
|
||||
</div>
|
||||
<div class="card-body text-center">
|
||||
<form id="board_form" class="form-signin" method="post" action="insert.php" >
|
||||
<input type="hidden" id="mode" name="mode">
|
||||
<input type="hidden" id="num" name="num" value="<?=$num?>" >
|
||||
|
||||
|
||||
<h5 class="form-signin-heading">성명</h5>
|
||||
<input type="text" name="name" class="form-control" placeholder="성명" required value="<?=$name?>" >
|
||||
<h5 class="form-signin-heading">부서</h5>
|
||||
|
||||
<select name="part" id="part" class="form-control" >
|
||||
<?php
|
||||
for($i=0;$i<count($basic_part_arr);$i++) {
|
||||
if($part==$basic_part_arr[$i])
|
||||
print "<option selected value='" . $basic_part_arr[$i] . "'> " . $basic_part_arr[$i] . "</option>";
|
||||
else
|
||||
print "<option value='" . $basic_part_arr[$i] . "'> " . $basic_part_arr[$i] . "</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
|
||||
|
||||
<h5 class="form-signin-heading">입사일</h5>
|
||||
<input type="date" name="dateofentry" class="form-control" placeholder="입사일" required value="<?=$dateofentry?>" >
|
||||
<h5 class="form-signin-heading">해당연도</h5>
|
||||
<input type="number" name="referencedate" class="form-control" placeholder="해당연도" required value="<?=$referencedate?>" >
|
||||
<h5 class="form-signin-heading">연차 발생일수</h5>
|
||||
<input type="number" name="availableday" class="form-control" placeholder="발생일수" required autofocus value="<?=$availableday?>" ><br>
|
||||
|
||||
<button id="saveBtn" class="btn btn-lg btn-secondary btn-block" type="button">등록</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-1"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<form id=Form1 name="Form1">
|
||||
<input type=hidden id="steelcompany" name="steelcompany[]" >
|
||||
</form>
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
$("#closeBtn").click(function(){ // 저장하고 창닫기
|
||||
|
||||
// data저장을 위한 ajax처리구문
|
||||
// $.ajax({
|
||||
// url: "registcompany_process.php",
|
||||
// type: "post",
|
||||
// data: $("#Form1").serialize(),
|
||||
// dataType:"json",
|
||||
// success : function( data ){
|
||||
// console.log( data);
|
||||
// },
|
||||
// error : function( jqxhr , status , error ){
|
||||
// console.log( jqxhr , status , error );
|
||||
// }
|
||||
// });
|
||||
|
||||
// window.close();
|
||||
});
|
||||
|
||||
|
||||
$("#saveBtn").click(function(){ // DATA 저장버튼 누름
|
||||
|
||||
$("#mode").val('insert');
|
||||
|
||||
$.ajax({
|
||||
url: "insert.php",
|
||||
type: "post",
|
||||
data: $("#board_form").serialize(),
|
||||
dataType:"json",
|
||||
success : function( data ){
|
||||
console.log( data);
|
||||
opener.location.reload();
|
||||
window.close();
|
||||
},
|
||||
error : function( jqxhr , status , error ){
|
||||
console.log( jqxhr , status , error );
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
$("#deldataBtn").click(function(){ deldataDo(); });
|
||||
$("#SelInsertDataBtn").click(function(){ SelInsertData(); });
|
||||
|
||||
|
||||
}); // end of ready document
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
139
annualleave/css/style.css
Normal file
139
annualleave/css/style.css
Normal file
@@ -0,0 +1,139 @@
|
||||
#openModalBtn {
|
||||
padding: 10px 20px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.modal {
|
||||
display: none;
|
||||
position: fixed;
|
||||
z-index: 1;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden; /* Changed from 'auto' to 'hidden' to prevent closing on outside click */
|
||||
background-color: rgba(0, 0, 0, 0.4);
|
||||
padding-top: 80px;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
background-color: #fefefe;
|
||||
margin: auto;
|
||||
border-radius: 10px;
|
||||
width: 80%;
|
||||
max-width: 1200px;
|
||||
animation: fadeIn 0.5s;
|
||||
box-shadow: 0 5px 15px rgba(0,0,0,0.3);
|
||||
}
|
||||
|
||||
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; }
|
||||
to { opacity: 1; }
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
background-color: #1f48d4;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
border-top-left-radius: 10px;
|
||||
border-top-right-radius: 10px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.close {
|
||||
color: white;
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.close:hover,
|
||||
.close:focus {
|
||||
color: #bbb;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.modal-body {
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.custom-card {
|
||||
background-color: #f9f9f9;
|
||||
padding: 20px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
|
||||
.tooltip-inner {
|
||||
background-color: black !important; /* 배경색 */
|
||||
color: white !important; /* 글자색 */
|
||||
}
|
||||
.tooltip-arrow {
|
||||
color: black !important; /* 화살표 색상 */
|
||||
}
|
||||
|
||||
/* 입력창에 대한 설계 */
|
||||
.ui-autocomplete {
|
||||
max-height: 500px;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.specialinputWrap {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width:100%;
|
||||
}
|
||||
|
||||
.specialbtnClear {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: black;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.specialbtnClear:before {
|
||||
content: 'X';
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.specialbtnClear:hover {
|
||||
color: black;
|
||||
}
|
||||
|
||||
.btnClear_lot {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: black;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.btnClear_lot:before {
|
||||
content: 'X';
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.btnClear_lot:hover {
|
||||
color: black;
|
||||
}
|
||||
|
||||
.modal-backdrop {
|
||||
display: none;
|
||||
}
|
||||
366
annualleave/fetch_modal.php
Normal file
366
annualleave/fetch_modal.php
Normal file
@@ -0,0 +1,366 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
// 결재권자 직함과 이름을 정해준다.
|
||||
$approvalName = '대표 이경호';
|
||||
|
||||
$mode = isset($_POST['mode']) ? $_POST['mode'] : '';
|
||||
$num = isset($_POST['num']) ? $_POST['num'] : '';
|
||||
$al_part = $_POST['al_part'] ?? '';
|
||||
$al_company = $_POST['al_company'] ?? '';
|
||||
|
||||
$tablename = "eworks";
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
|
||||
// 배열로 기본정보 불러옴
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/common.php");
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/almember/load_DB.php");
|
||||
|
||||
// holiday 테이블에서 휴일 목록 불러오기
|
||||
$holidayDates = [];
|
||||
try {
|
||||
$holidaySql = "SELECT startdate, enddate FROM " . $DB . ".holiday WHERE is_deleted IS NULL";
|
||||
$holidayStmt = $pdo->query($holidaySql);
|
||||
$holidayRows = $holidayStmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
foreach ($holidayRows as $holidayRow) {
|
||||
$startdate = $holidayRow['startdate'];
|
||||
$enddate = $holidayRow['enddate'];
|
||||
|
||||
// enddate가 '0000-00-00'이거나 비어있으면 startdate만 휴일
|
||||
if (empty($enddate) || $enddate === '0000-00-00' || $enddate === null) {
|
||||
$holidayDates[] = $startdate;
|
||||
} else {
|
||||
// 기간 내의 모든 날짜를 배열에 추가
|
||||
$start = new DateTime($startdate);
|
||||
$end = new DateTime($enddate);
|
||||
$end->modify('+1 day'); // 종료일 포함
|
||||
|
||||
$period = new DatePeriod($start, new DateInterval('P1D'), $end);
|
||||
foreach ($period as $date) {
|
||||
$holidayDates[] = $date->format('Y-m-d');
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
// 오류 발생 시 빈 배열 유지
|
||||
error_log("Holiday 데이터 로드 오류: " . $e->getMessage());
|
||||
}
|
||||
|
||||
if ($mode === 'update' && $num) {
|
||||
try {
|
||||
$sqlModal = "SELECT * FROM " . $DB . "." . $tablename . " WHERE num=?";
|
||||
$stmh = $pdo->prepare($sqlModal);
|
||||
$stmh->bindValue(1, $num, PDO::PARAM_STR);
|
||||
$stmh->execute();
|
||||
$row = $stmh->fetch(PDO::FETCH_ASSOC);
|
||||
include 'rowDBask.php';
|
||||
} catch (PDOException $Exception) {
|
||||
echo "오류: " . $Exception->getMessage();
|
||||
}
|
||||
} else {
|
||||
include '_request.php';
|
||||
$mode = 'insert';
|
||||
|
||||
$registdate = date("Y-m-d H:i:s");
|
||||
$al_askdatefrom = date("Y-m-d");
|
||||
$al_askdateto = date("Y-m-d");
|
||||
$al_usedday = abs(strtotime($al_askdateto) - strtotime($al_askdatefrom)) + 1;
|
||||
$al_item = '연차';
|
||||
$status = 'send';
|
||||
$statusstr = '결재요청';
|
||||
$author = $_SESSION["name"];
|
||||
$author_id = $user_id;
|
||||
$al_company = $_SESSION["mycompany"];
|
||||
$al_part = $_SESSION["mypart"];
|
||||
}
|
||||
|
||||
try {
|
||||
$totalusedday = 0;
|
||||
$totalremainday = 0;
|
||||
$previous_usage = 0;
|
||||
for ($i = 0; $i < count($totalname_arr); $i++) {
|
||||
if ($author == $totalname_arr[$i]) {
|
||||
$previous_usage = $previous_usage_arr[$i];
|
||||
$availableday = $availableday_arr[$i] - $previous_usage;
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = 0; $i < count($totalname_arr); $i++) {
|
||||
if ($author == $totalname_arr[$i]) {
|
||||
$totalusedday = $totalused_arr[$i];
|
||||
$previous_usage = $previous_usage_arr[$i];
|
||||
$totalremainday = $availableday - $previous_usage - $totalusedday;
|
||||
}
|
||||
}
|
||||
} catch (PDOException $Exception) {
|
||||
echo "오류: " . $Exception->getMessage();
|
||||
}
|
||||
|
||||
// echo '<pre>';
|
||||
// print_r($employee_data);
|
||||
// echo '</pre>';
|
||||
|
||||
?>
|
||||
|
||||
<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="registdate" name="registdate" value="<?= isset($registdate) ? $registdate : '' ?>">
|
||||
<input type="hidden" id="author_id" name="author_id" value="<?= isset($author_id) ? $author_id : '' ?>">
|
||||
<input type="hidden" id="status" name="status" value="<?= isset($status) ? $status : '' ?>">
|
||||
<input type="hidden" id="division" name="division" value="<?= isset($al_company) ? $al_company : '' ?>">
|
||||
<input type="hidden" id="htmltext" name="htmltext">
|
||||
<?php
|
||||
// 임시 키 생성 (고유값, 예: uniqid 사용)
|
||||
if ($mode === 'insert' || empty($num)) {
|
||||
$temp_key = 'temp_' . uniqid('al_', true);
|
||||
} else {
|
||||
$temp_key = $num;
|
||||
}
|
||||
?>
|
||||
<input type="hidden" id="temp_key" name="temp_key" value="<?= $temp_key ?>">
|
||||
|
||||
<div class="container-fluid" >
|
||||
<div class="row d-flex justify-content-center align-items-center h-75">
|
||||
<div class="col-12 text-center">
|
||||
<div class="card" style="border-radius:20px;">
|
||||
<h4 class="card-title text-center" style="color:#113366;"> 연차 신청 <span class="text-secondary small"> #<?= $num ?></span> </h4>
|
||||
<div class="card-body">
|
||||
<?php if ($e_confirm === '') {
|
||||
$formattedDate = date("m/d", strtotime($registdate));
|
||||
if ($al_part == '경동' || $al_part == '주일' ) {
|
||||
$approvals = array(
|
||||
array("name" => $approvalName , "date" => $formattedDate),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$approver_ids = explode('!', $e_confirm_id);
|
||||
$approver_details = explode('!', $e_confirm);
|
||||
$approvals = array();
|
||||
foreach ($approver_ids as $index => $id) {
|
||||
if (isset($approver_details[$index])) {
|
||||
preg_match("/^(.+ \d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})$/", $approver_details[$index], $matches);
|
||||
if (count($matches) === 3) {
|
||||
$nameWithTitle = $matches[1];
|
||||
$time = $matches[2];
|
||||
$date = substr($nameWithTitle, -10);
|
||||
$nameWithTitle = trim(str_replace($date, '', $nameWithTitle));
|
||||
$formattedDate = date("m/d H:i:s", strtotime("$date $time"));
|
||||
$approvals[] = array("name" => $nameWithTitle, "date" => $formattedDate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($status === 'end') { ?>
|
||||
<div class="d-flex justify-content-center " >
|
||||
<div class="row d-flex justify-content-center align-items-center w300px">
|
||||
<table class="table table-bordered table-sm p-0" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="<?php echo count($approvals); ?>" class="text-center fs-6">결재</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<?php foreach ($approvals as $approval) { ?>
|
||||
<td class="text-center fs-6" style="height: 50px;"><?php echo $approval["name"]; ?></td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<tr>
|
||||
<?php foreach ($approvals as $approval) { ?>
|
||||
<td class="text-center"><?php echo $approval["date"]; ?></td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div id="savetext">
|
||||
<div class="row d-flex justify-content-center align-items-center">
|
||||
성명
|
||||
<select name="author" id="author" class="form-select mx-1 d-block w-auto" style="font-size: 0.8rem; height: 32px;">
|
||||
<?php
|
||||
for ($i = 0; $i < count($employee_name_arr); $i++) {
|
||||
if ($author == $employee_name_arr[$i])
|
||||
print "<option selected value='" . $employee_name_arr[$i] . "'> " . $employee_name_arr[$i] . "</option>";
|
||||
else
|
||||
print "<option value='" . $employee_name_arr[$i] . "'> " . $employee_name_arr[$i] . "</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
회사
|
||||
<input type="text" id="al_company" name="al_company" value="<?=$al_company ?>" class="form-control w100px mx-1" readonly>
|
||||
파트
|
||||
<input type="text" id="al_part" name="al_part" class="form-control mx-1" style="width:100px;" value="<?= $al_part ?>" readonly>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive mt-2">
|
||||
<table class="table table-bordered table-sm w-auto mb-2" style="width:auto; margin:0 auto;">
|
||||
<tr>
|
||||
<td class="text-center" style="width:120px;">구분</td>
|
||||
<td>
|
||||
<?php
|
||||
$item_arr = array('연차', '오전반차','오후반차','경조사');
|
||||
foreach ($item_arr as $i => $item) {
|
||||
echo "<label class='me-2'>";
|
||||
echo "<input type='radio' name='al_item' value='" . $item . "' " . ($al_item == $item ? "checked='checked'" : "") . "> " . $item;
|
||||
echo "</label>";
|
||||
// if ($i == 1) echo "<br>";
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-center">신청시작일</td>
|
||||
<td class="text-start">
|
||||
<input type="date" id="al_askdatefrom" name="al_askdatefrom" class="form-control d-inline-block" style="width:120px;" required value="<?= $al_askdatefrom ?>">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-center">신청종료일</td>
|
||||
<td class="text-start">
|
||||
<input type="date" id="al_askdateto" name="al_askdateto" class="form-control d-inline-block" style="width:120px;" required value="<?= $al_askdateto ?>">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-center" style="color:blue;">신청 기간 산출</td>
|
||||
<td class="text-start">
|
||||
<input type="text" id="al_usedday" size="2" name="al_usedday" readonly class="form-control text-center d-inline-block" style="width:50px;" value="<?= $al_usedday ?>">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-center" style="color:red;">연차 잔여일수</td>
|
||||
<td class="text-start">
|
||||
<input type="text" id="totalremainday" name="totalremainday" size="2" class="form-control text-center d-inline-block" style="width:50px;" readonly value="<?= $totalremainday ?>">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="table-responsive mt-2">
|
||||
<table class="table table-bordered table-sm w-auto mb-2" style="width:auto; margin:0 auto;">
|
||||
<tr>
|
||||
<td class="text-center" style="width:120px;">신청 사유</td>
|
||||
<td>
|
||||
<select name="al_content" id="al_content" class="form-select mx-1 d-block w-auto" style="font-size: 0.8rem; height: 32px;">
|
||||
<?php
|
||||
$al_content_arr = array("개인사정", "휴가", "여행", "병원진료등", "전직원연차", "경조사", "기타");
|
||||
for ($i = 0; $i < count($al_content_arr); $i++) {
|
||||
if ($al_content == $al_content_arr[$i])
|
||||
print "<option selected value='" . $al_content_arr[$i] . "'> " . $al_content_arr[$i] . "</option>";
|
||||
else
|
||||
print "<option value='" . $al_content_arr[$i] . "'> " . $al_content_arr[$i] . "</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-center" style="width:120px;">결재 상태</td>
|
||||
<td class="text-start align-middle vertical-align-middle">
|
||||
<?php
|
||||
switch ($status) {
|
||||
case 'send':
|
||||
$statusstr = '결재요청';
|
||||
break;
|
||||
case 'ing':
|
||||
$statusstr = '결재중';
|
||||
break;
|
||||
case 'end':
|
||||
$statusstr = '결재완료';
|
||||
break;
|
||||
default:
|
||||
$statusstr = '';
|
||||
break;
|
||||
}
|
||||
?>
|
||||
<input type="text" id="statusstr" name="statusstr" class="form-control text-center" readonly value="<?= $statusstr ?>">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- 파일첨부 섹션 추가 -->
|
||||
<div class="table-responsive mt-2">
|
||||
<table class="table table-bordered table-sm w-auto mb-2" style="width:auto; margin:0 auto;">
|
||||
<tr>
|
||||
<td class="text-center" style="width:120px;">파일첨부</td>
|
||||
<td class="text-start">
|
||||
<div class="d-flex flex-column gap-2">
|
||||
<!-- 일반 파일 첨부 -->
|
||||
<div class="d-flex align-items-center">
|
||||
<label for="upfile" class="input-group-text btn btn-outline-primary btn-sm me-2" style="font-size: 0.8rem;">
|
||||
파일 첨부
|
||||
</label>
|
||||
<input id="upfile" name="upfile[]" type="file" multiple style="display:none" accept=".pdf,.doc,.docx,.xls,.xlsx,.txt,.zip,.rar">
|
||||
<span class="text-muted small">(10MB 이하, PDF, 문서, 압축파일 등)</span>
|
||||
</div>
|
||||
<!-- 이미지 첨부 -->
|
||||
<div class="d-flex align-items-center">
|
||||
<label for="upfileimage" class="input-group-text btn btn-outline-dark btn-sm me-2" style="font-size: 0.8rem;">
|
||||
이미지 첨부
|
||||
</label>
|
||||
<input id="upfileimage" name="upfileimage[]" type="file" multiple style="display:none" accept=".gif,.jpg,.jpeg,.png">
|
||||
<span class="text-muted small">(이미지 파일: GIF, JPG, PNG)</span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 첨부된 파일 표시 영역 -->
|
||||
<div id="displayFile" class="mt-2" style="display:none;"></div>
|
||||
<div id="displayImage" class="mt-2" style="display:none;"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
<div class=" d-flex justify-content-center mt-2 mb-2 align-items-center">
|
||||
<? if ((int)$num > 0 and $level =='1' ) {
|
||||
print '<button type="button" id="saveBtn" class="btn btn-sm btn-dark mx-1 " type="button">';
|
||||
print '결재요청(수정)';
|
||||
print '</button>';
|
||||
} else if ($statusstr !== '결재완료') {
|
||||
print '<button type="button" id="saveBtn" class="btn btn-sm btn-dark mx-1 " type="button">';
|
||||
print '결재요청';
|
||||
print '</button>';
|
||||
}
|
||||
if ((int)$num > 0 and $level =='1' ) { ?>
|
||||
<button type="button" id="deleteBtn" class="btn btn-sm btn-danger mx-1" type="button"> <i class="bi bi-trash"></i> 삭제 </button>
|
||||
<? } ?>
|
||||
|
||||
<button type="button" class="btn btn-dark btn-sm ms-4" id="closeBtn"> × 닫기 </button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// fetch_modal.php에서도 holiday 데이터를 전달 (기존 holidaySet과 병합)
|
||||
(function() {
|
||||
var modalHolidayDates = <?= json_encode($holidayDates, JSON_UNESCAPED_UNICODE) ?>;
|
||||
|
||||
// 전역 holidaySet 초기화 또는 업데이트
|
||||
if (typeof window.holidaySet === 'undefined' || !(window.holidaySet instanceof Set)) {
|
||||
window.holidaySet = new Set(modalHolidayDates);
|
||||
} else {
|
||||
// 기존 holidaySet에 추가
|
||||
modalHolidayDates.forEach(function(date) {
|
||||
window.holidaySet.add(date);
|
||||
});
|
||||
}
|
||||
|
||||
// 로컬 스코프에도 설정 (기존 코드와의 호환성)
|
||||
if (typeof holidaySet === 'undefined') {
|
||||
window.holidaySet = window.holidaySet || new Set(modalHolidayDates);
|
||||
} else {
|
||||
modalHolidayDates.forEach(function(date) {
|
||||
holidaySet.add(date);
|
||||
});
|
||||
}
|
||||
|
||||
console.log('Holiday 데이터 로드 완료:', modalHolidayDates.length, '개');
|
||||
})();
|
||||
</script>
|
||||
71
annualleave/get_employee_info.php
Normal file
71
annualleave/get_employee_info.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
// 연차계산 함수 포함
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/common.php");
|
||||
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
|
||||
// load_DB.php를 통해 almember, eworks 관련 데이터를 가져오고
|
||||
// 기본 정보 및 연차 사용량 배열($basic_name_arr, $availableday_arr, $totalused_arr 등)을 생성합니다.
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/almember/load_DB.php");
|
||||
|
||||
if (isset($_POST['name'])) {
|
||||
$name = $_POST['name'];
|
||||
try {
|
||||
// member 테이블에서 division, part, enterDate(입사일) 컬럼을 조회합니다.
|
||||
$sql = "SELECT division, part, enterDate FROM {$DB}.member WHERE name = ?";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$name]);
|
||||
$data = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
// load_DB.php에서 생성한 배열을 활용하여 연차 잔여일(remainday)을 계산합니다.
|
||||
// $basic_name_arr: almember 테이블에서 불러온 이름 배열
|
||||
// $availableday_arr: 각 직원의 연차 총 사용 가능일수
|
||||
// $totalused_arr: 해당 직원이 사용한 연차 일수 (계산 결과)
|
||||
$index = array_search($name, $basic_name_arr);
|
||||
if ($index !== false) {
|
||||
// 문자열로 전달될 수 있으므로 floatval()를 이용해 숫자로 변환합니다.
|
||||
$available = floatval($availableday_arr[$index]);
|
||||
$previous_year_usage = floatval($previous_year_usage_arr[$index]);
|
||||
$used = floatval($totalused_arr[$index]);
|
||||
$remainday = $available - $used;
|
||||
|
||||
// 추가 데이터도 포함 (연차 계산 결과)
|
||||
$continueYear = isset($continueYear_arr[$index]) ? $continueYear_arr[$index] : 0;
|
||||
$initial_less_than_one_year = isset($initial_less_than_one_year_arr[$index]) ? $initial_less_than_one_year_arr[$index] : 0;
|
||||
$service_based = isset($service_based_arr[$index]) ? $service_based_arr[$index] : 0;
|
||||
$referencedate = isset($referencedate_arr[$index]) ? $referencedate_arr[$index] : 0;
|
||||
} else {
|
||||
// 해당 이름이 almember 테이블에 없는 경우 기본값 0을 할당합니다.
|
||||
$available = 0;
|
||||
$used = 0;
|
||||
$remainday = 0;
|
||||
$continueYear = 0;
|
||||
$initial_less_than_one_year = 0;
|
||||
$service_based = 0;
|
||||
$previous_year_usage = 0;
|
||||
}
|
||||
|
||||
// 조회한 회원 정보에 연차 관련 데이터 추가
|
||||
$data['available'] = $available;
|
||||
$data['used'] = $used;
|
||||
$data['remainday'] = $remainday;
|
||||
$data['continueYear'] = $continueYear;
|
||||
$data['initial_less_than_one_year'] = $initial_less_than_one_year;
|
||||
$data['service_based'] = $service_based;
|
||||
$data['referencedate'] = $referencedate;
|
||||
$data['previous_year_usage'] = $previous_year_usage;
|
||||
$data['part'] = $data['part'];
|
||||
$data['company'] = $data['division'];
|
||||
$data['dateofentry'] = $data['enterDate'];
|
||||
|
||||
echo json_encode($data);
|
||||
} catch (PDOException $e) {
|
||||
echo json_encode(['error' => $e->getMessage()]);
|
||||
}
|
||||
} else {
|
||||
echo json_encode(['error' => 'No name provided']);
|
||||
}
|
||||
?>
|
||||
2402
annualleave/index.php
Normal file
2402
annualleave/index.php
Normal file
File diff suppressed because it is too large
Load Diff
109
annualleave/insert.php
Normal file
109
annualleave/insert.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
header("Content-Type: application/json"); // JSON을 사용하기 위해 필요한 구문
|
||||
|
||||
isset($_REQUEST["mode"]) ? $mode = $_REQUEST["mode"] : $mode="";
|
||||
isset($_REQUEST["num"]) ? $num = $_REQUEST["num"] : $num="";
|
||||
|
||||
include $_SERVER['DOCUMENT_ROOT'] . "/almember/_request.php";
|
||||
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
|
||||
if ($mode == "modify") {
|
||||
try {
|
||||
$sql = "SELECT * FROM " . $DB . ".almember WHERE num=?"; // get target record
|
||||
$stmh = $pdo->prepare($sql);
|
||||
$stmh->bindValue(1, $num, PDO::PARAM_STR);
|
||||
$stmh->execute();
|
||||
$row = $stmh->fetch(PDO::FETCH_ASSOC);
|
||||
} catch (PDOException $Exception) {
|
||||
$pdo->rollBack();
|
||||
print "오류: ".$Exception->getMessage();
|
||||
}
|
||||
|
||||
try {
|
||||
$pdo->beginTransaction();
|
||||
$sql = "UPDATE " . $DB . ".almember
|
||||
SET name=?, part=?, dateofentry=?, referencedate=?, availableday=?, comment=?,
|
||||
years_of_service=?, initial_less_than_one_year=?, service_based=?, previous_year_usage=?
|
||||
WHERE num=? LIMIT 1";
|
||||
|
||||
$stmh = $pdo->prepare($sql);
|
||||
$stmh->bindValue(1, $name, PDO::PARAM_STR);
|
||||
$stmh->bindValue(2, $part, PDO::PARAM_STR);
|
||||
$stmh->bindValue(3, $dateofentry, PDO::PARAM_STR);
|
||||
$stmh->bindValue(4, $referencedate, PDO::PARAM_STR);
|
||||
$stmh->bindValue(5, $availableday, PDO::PARAM_STR);
|
||||
$stmh->bindValue(6, $comment, PDO::PARAM_STR);
|
||||
$stmh->bindValue(7, $years_of_service, PDO::PARAM_STR);
|
||||
$stmh->bindValue(8, $initial_less_than_one_year, PDO::PARAM_STR);
|
||||
$stmh->bindValue(9, $service_based, PDO::PARAM_STR);
|
||||
$stmh->bindValue(10, $previous_year_usage, PDO::PARAM_STR);
|
||||
$stmh->bindValue(11, $num, PDO::PARAM_STR);
|
||||
|
||||
$stmh->execute();
|
||||
$pdo->commit();
|
||||
} catch (PDOException $Exception) {
|
||||
$pdo->rollBack();
|
||||
print "오류: ".$Exception->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode == "insert" || $mode == "copy") {
|
||||
try {
|
||||
$pdo->beginTransaction();
|
||||
|
||||
$sql = "INSERT INTO " . $DB . ".almember (name, part, dateofentry, referencedate, availableday, comment,
|
||||
years_of_service, initial_less_than_one_year, service_based, previous_year_usage)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
|
||||
$stmh = $pdo->prepare($sql);
|
||||
$stmh->bindValue(1, $name, PDO::PARAM_STR);
|
||||
$stmh->bindValue(2, $part, PDO::PARAM_STR);
|
||||
$stmh->bindValue(3, $dateofentry, PDO::PARAM_STR);
|
||||
$stmh->bindValue(4, $referencedate, PDO::PARAM_STR);
|
||||
$stmh->bindValue(5, $availableday, PDO::PARAM_STR);
|
||||
$stmh->bindValue(6, $comment, PDO::PARAM_STR);
|
||||
$stmh->bindValue(7, $years_of_service, PDO::PARAM_STR);
|
||||
$stmh->bindValue(8, $initial_less_than_one_year, PDO::PARAM_STR);
|
||||
$stmh->bindValue(9, $service_based, PDO::PARAM_STR);
|
||||
$stmh->bindValue(10, $previous_year_usage, PDO::PARAM_STR);
|
||||
|
||||
$stmh->execute();
|
||||
$pdo->commit();
|
||||
} catch (PDOException $Exception) {
|
||||
$pdo->rollBack();
|
||||
print "오류: ".$Exception->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode == "delete") {
|
||||
try {
|
||||
$pdo->beginTransaction();
|
||||
|
||||
$sql = "DELETE FROM " . $DB . ".almember WHERE num = ?";
|
||||
$stmh = $pdo->prepare($sql);
|
||||
$stmh->bindValue(1, $num, PDO::PARAM_STR);
|
||||
$stmh->execute();
|
||||
$pdo->commit();
|
||||
} catch (PDOException $Exception) {
|
||||
$pdo->rollBack();
|
||||
print "오류: ".$Exception->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
// 각각의 정보를 하나의 배열 변수에 넣어준다.
|
||||
$data = array(
|
||||
"mode" => $mode,
|
||||
"dateofentry" => $dateofentry,
|
||||
"years_of_service" => $years_of_service,
|
||||
"initial_less_than_one_year" => $initial_less_than_one_year,
|
||||
"service_based" => $service_based,
|
||||
"previous_year_usage" => $previous_year_usage
|
||||
);
|
||||
|
||||
// JSON 출력
|
||||
echo json_encode($data, JSON_UNESCAPED_UNICODE);
|
||||
?>
|
||||
280
annualleave/insert_ask.php
Normal file
280
annualleave/insert_ask.php
Normal file
@@ -0,0 +1,280 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
$tablename = "eworks";
|
||||
|
||||
header("Content-Type: application/json");
|
||||
|
||||
isset($_REQUEST["mode"]) ? $mode = $_REQUEST["mode"] : $mode = "";
|
||||
isset($_REQUEST["num"]) ? $num = $_REQUEST["num"] : $num = "";
|
||||
isset($_REQUEST["temp_key"]) ? $temp_key = $_REQUEST["temp_key"] : $temp_key = "";
|
||||
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/common.php");
|
||||
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
|
||||
include '_request.php';
|
||||
|
||||
$status = $_REQUEST["status"] ?? '';
|
||||
$htmltext = $_REQUEST["htmltext"] ?? '';
|
||||
|
||||
// 파일 업로드 처리 함수
|
||||
function handleFileUpload($files, $num, $tablename, $item) {
|
||||
if (empty($files) || !is_array($files)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$uploadedFiles = [];
|
||||
$uploadDir = $_SERVER['DOCUMENT_ROOT'] . '/uploads/' . $tablename . '/' . $item . '/';
|
||||
|
||||
// 디렉토리가 없으면 생성
|
||||
if (!is_dir($uploadDir)) {
|
||||
mkdir($uploadDir, 0755, true);
|
||||
}
|
||||
|
||||
foreach ($files as $file) {
|
||||
if ($file['error'] === UPLOAD_ERR_OK) {
|
||||
try {
|
||||
// 파일명 중복 방지를 위한 타임스탬프 추가
|
||||
$timestamp = time();
|
||||
$filename = $timestamp . '_' . $file['name'];
|
||||
$filepath = $uploadDir . $filename;
|
||||
|
||||
if (move_uploaded_file($file['tmp_name'], $filepath)) {
|
||||
$uploadedFiles[] = [
|
||||
'filename' => $filename,
|
||||
'realname' => $file['name'],
|
||||
'size' => $file['size'],
|
||||
'type' => $file['type'],
|
||||
'path' => $filepath
|
||||
];
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
error_log("파일 업로드 오류: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $uploadedFiles;
|
||||
}
|
||||
|
||||
// 이름찾아 결재 아이디 찾아내기
|
||||
try {
|
||||
$membersql = "SELECT * FROM {$DB}.member WHERE name = ?";
|
||||
$stmh = $pdo->prepare($membersql);
|
||||
$stmh->bindValue(1, trim($author), PDO::PARAM_STR);
|
||||
$stmh->execute();
|
||||
$rowMember = $stmh->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
// 조회된 데이터가 있는지 확인 후 설정
|
||||
$first_approval_id = trim($rowMember['first_approval_id']) ?? ''; // 값이 없으면 빈 문자열
|
||||
$first_approval_name = trim($rowMember['first_approval_name']) ?? '';
|
||||
|
||||
} catch (PDOException $Exception) {
|
||||
print "오류: " . $Exception->getMessage();
|
||||
}
|
||||
|
||||
if ($mode == "modify") {
|
||||
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);
|
||||
} catch (PDOException $Exception) {
|
||||
$pdo->rollBack();
|
||||
print "오류: " . $Exception->getMessage();
|
||||
}
|
||||
|
||||
// 전자 결재에 보여질 내용 data 수정 update
|
||||
|
||||
$data = array(
|
||||
"author" => $author,
|
||||
"al_item" => $al_item,
|
||||
"al_askdatefrom" => $al_askdatefrom,
|
||||
"al_askdateto" => $al_askdateto,
|
||||
"al_usedday" => $al_usedday,
|
||||
"al_content" => $al_content,
|
||||
"e_line_id" => $e_line_id,
|
||||
"e_line" => $e_line,
|
||||
"approvalLines" => $approvalLines,
|
||||
"first_approval_name" => $first_approval_name,
|
||||
"first_approval_id" => $first_approval_id
|
||||
);
|
||||
|
||||
$contents = json_encode($data, JSON_UNESCAPED_UNICODE);
|
||||
|
||||
try {
|
||||
$pdo->beginTransaction();
|
||||
$sql = "update " . $DB . "." . $tablename . " set author_id=?, author=?, registdate=?, al_item=?, al_askdatefrom=?, al_askdateto=?, al_usedday=?, al_content=?, status=?, al_part=?, contents=?, al_company=? ";
|
||||
$sql .= " where num=? LIMIT 1";
|
||||
$stmh = $pdo->prepare($sql);
|
||||
$stmh->bindValue(1, $author_id, PDO::PARAM_STR);
|
||||
$stmh->bindValue(2, $author, PDO::PARAM_STR);
|
||||
$stmh->bindValue(3, $registdate, PDO::PARAM_STR);
|
||||
$stmh->bindValue(4, $al_item, PDO::PARAM_STR);
|
||||
$stmh->bindValue(5, $al_askdatefrom, PDO::PARAM_STR);
|
||||
$stmh->bindValue(6, $al_askdateto, PDO::PARAM_STR);
|
||||
$stmh->bindValue(7, $al_usedday, PDO::PARAM_STR);
|
||||
$stmh->bindValue(8, $al_content, PDO::PARAM_STR);
|
||||
$stmh->bindValue(9, $status, PDO::PARAM_STR);
|
||||
$stmh->bindValue(10, $al_part, PDO::PARAM_STR);
|
||||
$stmh->bindValue(11, $contents, PDO::PARAM_STR);
|
||||
$stmh->bindValue(12, $al_company, PDO::PARAM_STR);
|
||||
$stmh->bindValue(13, $num, PDO::PARAM_STR);
|
||||
|
||||
$stmh->execute();
|
||||
$pdo->commit();
|
||||
} catch (PDOException $Exception) {
|
||||
$pdo->rollBack();
|
||||
print "오류: " . $Exception->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($mode == "insert") {
|
||||
try {
|
||||
$pdo->beginTransaction();
|
||||
|
||||
// Read and decode the JSON file
|
||||
// $jsonString = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/member/Company_approvalLine_.json');
|
||||
// $approvalLines = json_decode($jsonString, true);
|
||||
|
||||
// Default values for e_line_id and e_line
|
||||
|
||||
// $first_approval_id = isset($row["first_approval_id"]) ? $row["first_approval_id"] : '';
|
||||
// $first_approval_name = isset($row["first_approval_name"]) ? $row["first_approval_name"] : '';
|
||||
|
||||
$e_line_id = $first_approval_id;
|
||||
$e_line = $first_approval_name ;
|
||||
|
||||
// // Check if decoded JSON is an array and process it
|
||||
// if (is_array($approvalLines)) {
|
||||
// foreach ($approvalLines as $line) {
|
||||
// if ($al_company == $line['savedName']) { // 회사이름이 같으면 결재라인 지정 결재라인은 회사명으로 만든다
|
||||
// foreach ($line['approvalOrder'] as $order) {
|
||||
// $e_line_id .= $order['user-id'] . '!';
|
||||
// $e_line .= $order['name'] . '!';
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// Set status based on the part
|
||||
$status ='send';
|
||||
$e_title = '연차신청';
|
||||
|
||||
// 전자 결재에 보여질 내용 data 수정 update
|
||||
|
||||
$data = array(
|
||||
"author" => $author,
|
||||
"al_item" => $al_item,
|
||||
"al_askdatefrom" => $al_askdatefrom,
|
||||
"al_askdateto" => $al_askdateto,
|
||||
"al_usedday" => $al_usedday,
|
||||
"al_content" => $al_content,
|
||||
"e_line_id" => $e_line_id,
|
||||
"e_line" => $e_line,
|
||||
"approvalLines" => $approvalLines,
|
||||
"first_approval_name" => $first_approval_name,
|
||||
"first_approval_id" => $first_approval_id
|
||||
);
|
||||
|
||||
$contents = json_encode($data, JSON_UNESCAPED_UNICODE);
|
||||
|
||||
$eworks_item = '연차';
|
||||
|
||||
// SQL statement with additional fields for e_line_id, e_line, and status
|
||||
$sql = "INSERT INTO " . $DB . "." . $tablename . " (author_id, author, registdate, al_item, al_askdatefrom, al_askdateto, al_usedday, al_content, status, al_part, e_line_id, e_line, e_title, contents, eworks_item, al_company) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
|
||||
$stmh = $pdo->prepare($sql);
|
||||
$stmh->bindValue(1, $author_id, PDO::PARAM_STR);
|
||||
$stmh->bindValue(2, $author, PDO::PARAM_STR);
|
||||
$stmh->bindValue(3, $registdate, PDO::PARAM_STR);
|
||||
$stmh->bindValue(4, $al_item, PDO::PARAM_STR);
|
||||
$stmh->bindValue(5, $al_askdatefrom, PDO::PARAM_STR);
|
||||
$stmh->bindValue(6, $al_askdateto, PDO::PARAM_STR);
|
||||
$stmh->bindValue(7, $al_usedday, PDO::PARAM_STR);
|
||||
$stmh->bindValue(8, $al_content, PDO::PARAM_STR);
|
||||
$stmh->bindValue(9, $status, PDO::PARAM_STR);
|
||||
$stmh->bindValue(10, $al_part, PDO::PARAM_STR);
|
||||
$stmh->bindValue(11, rtrim($e_line_id, '!'), PDO::PARAM_STR);
|
||||
$stmh->bindValue(12, rtrim($e_line, '!'), PDO::PARAM_STR);
|
||||
$stmh->bindValue(13, $e_title, PDO::PARAM_STR);
|
||||
$stmh->bindValue(14, $contents, PDO::PARAM_STR);
|
||||
$stmh->bindValue(15, $eworks_item, PDO::PARAM_STR);
|
||||
$stmh->bindValue(16, $al_company, PDO::PARAM_STR);
|
||||
|
||||
$stmh->execute();
|
||||
$pdo->commit();
|
||||
|
||||
// 신규 레코드 번호 가져오기
|
||||
$sql = "SELECT num FROM {$DB}.{$tablename} ORDER BY num DESC LIMIT 1";
|
||||
$stmh = $pdo->prepare($sql);
|
||||
$stmh->execute();
|
||||
$row = $stmh->fetch(PDO::FETCH_ASSOC);
|
||||
$num = $row["num"];
|
||||
|
||||
// 임시 키가 있는 경우 picuploads 테이블에서 임시키를 정식 num으로 업데이트
|
||||
if (!empty($temp_key)) {
|
||||
try {
|
||||
$pdo->beginTransaction();
|
||||
$sql = "UPDATE {$DB}.picuploads SET parentnum = ? WHERE parentnum = ?";
|
||||
$stmh = $pdo->prepare($sql);
|
||||
$stmh->bindValue(1, $num, PDO::PARAM_STR);
|
||||
$stmh->bindValue(2, $temp_key, PDO::PARAM_STR);
|
||||
$stmh->execute();
|
||||
$pdo->commit();
|
||||
} catch (PDOException $Exception) {
|
||||
$pdo->rollBack();
|
||||
error_log("임시키 업데이트 오류: " . $Exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
} catch (PDOException $Exception) {
|
||||
$pdo->rollBack();
|
||||
print "오류: " . $Exception->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode == "delete") {
|
||||
try {
|
||||
$pdo->beginTransaction();
|
||||
$sql = "update " . $DB . "." . $tablename . " set is_deleted=? ";
|
||||
$sql .= " where num=? LIMIT 1";
|
||||
$stmh = $pdo->prepare($sql);
|
||||
$stmh->bindValue(1, true, PDO::PARAM_STR);
|
||||
$stmh->bindValue(2, $num, PDO::PARAM_STR); // Binding the $num variable
|
||||
|
||||
$stmh->execute();
|
||||
$pdo->commit();
|
||||
} catch (PDOException $Exception) {
|
||||
$pdo->rollBack();
|
||||
print "오류: " . $Exception->getMessage();
|
||||
}
|
||||
|
||||
$e_line_id = null;
|
||||
$e_line = null;
|
||||
$approvalLines = null;
|
||||
$company = null;
|
||||
|
||||
$data = array(
|
||||
"registdate" => $registdate,
|
||||
"status" => $status,
|
||||
"num" => $num,
|
||||
"mode" => $mode,
|
||||
"e_line_id" => $e_line_id,
|
||||
"e_line" => $e_line,
|
||||
"approvalLines" => $approvalLines,
|
||||
"first_approval_name" => $first_approval_name,
|
||||
"first_approval_id" => $first_approval_id,
|
||||
"al_company" => $al_company,
|
||||
"al_part" => $al_part,
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
echo(json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
?>
|
||||
54
annualleave/insert_init.php
Normal file
54
annualleave/insert_init.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
include $_SERVER['DOCUMENT_ROOT'] . '/session.php';
|
||||
header("Content-Type: application/json"); // JSON 응답을 위해 설정
|
||||
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
|
||||
try {
|
||||
// POST 데이터에서 author_list와 기타 정보를 가져옴
|
||||
$authorList = isset($_POST['author_list']) ? json_decode($_POST['author_list'], true) : [];
|
||||
$currentYear = $_POST['current_year'] ?? "";
|
||||
|
||||
if (empty($authorList)) {
|
||||
echo json_encode(["status" => "error", "message" => "등록할 직원 정보가 없습니다."]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$pdo->beginTransaction();
|
||||
|
||||
$sql = "INSERT INTO {$DB}.almember (name, company, part, dateofentry, referencedate, availableday, service_based, initial_less_than_one_year)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
$stmh = $pdo->prepare($sql);
|
||||
|
||||
foreach ($authorList as $author) {
|
||||
$name = $author['name'] ?? "";
|
||||
$company = $author['company'] ?? "";
|
||||
$part = $author['part'] ?? "";
|
||||
$dateofentry = $author['dateofentry'] ?? '' ;
|
||||
$availableday = $author['availableday'] ?? '' ;
|
||||
$service_based = $author['service_based'] ?? '' ;
|
||||
$initial_less_than_one_year = $author['initial_less_than_one_year'] ?? '' ;
|
||||
|
||||
|
||||
// 각 직원의 데이터를 삽입
|
||||
$stmh->bindValue(1, $name, PDO::PARAM_STR);
|
||||
$stmh->bindValue(2, $company, PDO::PARAM_STR);
|
||||
$stmh->bindValue(3, $part, PDO::PARAM_STR);
|
||||
$stmh->bindValue(4, $dateofentry, PDO::PARAM_STR); // 입사일
|
||||
$stmh->bindValue(5, $currentYear, PDO::PARAM_STR); // 해당 연도
|
||||
$stmh->bindValue(6, $availableday, PDO::PARAM_INT); // 계산된 연차 발생일수
|
||||
$stmh->bindValue(7, $service_based, PDO::PARAM_INT);
|
||||
$stmh->bindValue(8, $initial_less_than_one_year, PDO::PARAM_INT);
|
||||
$stmh->execute();
|
||||
}
|
||||
|
||||
$pdo->commit();
|
||||
|
||||
echo json_encode(["status" => "success", "message" => "대량 등록이 성공적으로 완료되었습니다."]);
|
||||
} catch (PDOException $e) {
|
||||
$pdo->rollBack();
|
||||
echo json_encode(["status" => "error", "message" => "DB 오류: " . $e->getMessage()]);
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
69
annualleave/mass_insert.php
Normal file
69
annualleave/mass_insert.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
header("Content-Type: application/json"); //json을 사용하기 위해 필요한 구문
|
||||
|
||||
isset($_REQUEST["mode"]) ? $mode = $_REQUEST["mode"] : $mode="";
|
||||
isset($_REQUEST["num"]) ? $num = $_REQUEST["num"] : $num="";
|
||||
|
||||
require_once("../lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
|
||||
// 배열로 기본정보 불러옴
|
||||
include "load_DB.php";
|
||||
|
||||
// 전 직원 배열로 계산 후 사용일수 남은일수 값 넣기
|
||||
// 2022년 2023년 등 자료의 유일한 값을 위주로 대량생산함 array_unique
|
||||
for($i=0;$i<count(array_unique($basic_name_arr));$i++)
|
||||
{
|
||||
$id=$id_arr[$i];
|
||||
$name=$basic_name_arr[$i];
|
||||
$part=$part_arr[$i];
|
||||
$registdate=$_REQUEST["registdate"];
|
||||
$item=$_REQUEST["item"];
|
||||
$askdatefrom=$_REQUEST["askdatefrom"];
|
||||
$askdateto=$_REQUEST["askdateto"];
|
||||
$usedday=$_REQUEST["usedday"];
|
||||
$content=$_REQUEST["content"];
|
||||
$state='처리완료'; // 강제처리완료 처리함
|
||||
|
||||
if ($mode=="insert"){
|
||||
try{
|
||||
$pdo->beginTransaction();
|
||||
|
||||
$sql = "insert into mirae8440.al(id , name , registdate , item , askdatefrom , askdateto , usedday , content , state, part ) ";
|
||||
$sql .= " values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ";
|
||||
|
||||
|
||||
$stmh = $pdo->prepare($sql);
|
||||
$stmh->bindValue(1, $id, PDO::PARAM_STR);
|
||||
$stmh->bindValue(2, $name, PDO::PARAM_STR);
|
||||
$stmh->bindValue(3, $registdate, PDO::PARAM_STR);
|
||||
$stmh->bindValue(4, $item, PDO::PARAM_STR);
|
||||
$stmh->bindValue(5, $askdatefrom, PDO::PARAM_STR);
|
||||
$stmh->bindValue(6, $askdateto, PDO::PARAM_STR);
|
||||
$stmh->bindValue(7, $usedday, PDO::PARAM_STR);
|
||||
$stmh->bindValue(8, $content, PDO::PARAM_STR);
|
||||
$stmh->bindValue(9, $state, PDO::PARAM_STR);
|
||||
$stmh->bindValue(10, $part, PDO::PARAM_STR);
|
||||
|
||||
$stmh->execute();
|
||||
$pdo->commit();
|
||||
} catch (PDOException $Exception) {
|
||||
$pdo->rollBack();
|
||||
print "오류: ".$Exception->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//각각의 정보를 하나의 배열 변수에 넣어준다.
|
||||
$data = array(
|
||||
"registdate" => $registdate,
|
||||
"state" => $state,
|
||||
);
|
||||
|
||||
//json 출력
|
||||
echo(json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
|
||||
?>
|
||||
131
annualleave/monthly_leave_ajax.php
Normal file
131
annualleave/monthly_leave_ajax.php
Normal file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . '/session.php');
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . '/common.php'); // $DB 정의
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . '/lib/mydb.php');
|
||||
$pdo = db_connect();
|
||||
|
||||
// 입력값: 년도, 회사(필터)
|
||||
$year = isset($_POST['year']) ? (int)$_POST['year'] : (int)date('Y');
|
||||
$corp = isset($_POST['corp']) ? trim($_POST['corp']) : '';
|
||||
|
||||
// 1) eworks 테이블에서 실제 사용된 연차만 월별 집계 (author → member.name JOIN)
|
||||
$sql1 = "
|
||||
SELECT
|
||||
m.id AS uid,
|
||||
MONTH(CAST(e.al_askdatefrom AS DATE)) AS mon,
|
||||
SUM(CAST(e.al_usedday AS DECIMAL(10,1))) AS used
|
||||
FROM {$DB}.eworks e
|
||||
JOIN {$DB}.member m
|
||||
ON TRIM(e.author) = m.name
|
||||
AND (m.quitDate IS NULL OR m.quitDate = '0000-00-00')
|
||||
WHERE e.eworks_item = '연차'
|
||||
AND e.is_deleted IS NULL
|
||||
AND e.status = 'end'
|
||||
AND e.done = 'done'
|
||||
AND YEAR(CAST(e.al_askdatefrom AS DATE)) = :year
|
||||
AND CAST(e.al_usedday AS DECIMAL(10,1)) > 0
|
||||
";
|
||||
if ($corp !== '') {
|
||||
$sql1 .= " AND m.division LIKE :corp ";
|
||||
}
|
||||
$sql1 .= "
|
||||
GROUP BY m.id, mon
|
||||
";
|
||||
|
||||
$stmt1 = $pdo->prepare($sql1);
|
||||
$stmt1->bindValue(':year', $year, PDO::PARAM_INT);
|
||||
if ($corp !== '') {
|
||||
$stmt1->bindValue(':corp', "%{$corp}%", PDO::PARAM_STR);
|
||||
}
|
||||
$stmt1->execute();
|
||||
$rows = $stmt1->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Pivot: [uid][month] = used
|
||||
$usageData = [];
|
||||
foreach ($rows as $r) {
|
||||
$uid = $r['uid'];
|
||||
$mon = (int)$r['mon'];
|
||||
$usageData[$uid][$mon] = ($usageData[$uid][$mon] ?? 0) + (float)$r['used'];
|
||||
}
|
||||
|
||||
// 2) member 테이블에서 재직 중 전체 직원 조회 (퇴직자 제외, 회사 필터)
|
||||
$sql2 = "
|
||||
SELECT
|
||||
m.id AS uid,
|
||||
m.name AS name,
|
||||
m.division AS corp,
|
||||
m.part AS dept,
|
||||
m.position AS position
|
||||
FROM {$DB}.member m
|
||||
WHERE (m.quitDate IS NULL OR m.quitDate = '0000-00-00')
|
||||
";
|
||||
if ($corp !== '') {
|
||||
$sql2 .= " AND m.division LIKE :corp ";
|
||||
}
|
||||
$stmt2 = $pdo->prepare($sql2);
|
||||
if ($corp !== '') {
|
||||
$stmt2->bindValue(':corp', "%{$corp}%", PDO::PARAM_STR);
|
||||
}
|
||||
$stmt2->execute();
|
||||
$members = $stmt2->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// 3) 전체 직원 기준으로 초기 배열 구성
|
||||
$data = [];
|
||||
foreach ($members as $m) {
|
||||
$data[] = [
|
||||
'uid' => $m['uid'],
|
||||
'corp' => $m['corp'],
|
||||
'dept' => $m['dept'],
|
||||
'position' => $m['position'],
|
||||
'name' => $m['name'],
|
||||
'months' => array_fill(1, 12, 0),
|
||||
];
|
||||
}
|
||||
|
||||
// 4) 사용량이 있는 달에만 값 채우기
|
||||
foreach ($data as &$row) {
|
||||
$uid = $row['uid'];
|
||||
if (isset($usageData[$uid])) {
|
||||
foreach ($usageData[$uid] as $mon => $used) {
|
||||
$row['months'][$mon] = $used;
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($row);
|
||||
|
||||
// 5) 결과 테이블 출력
|
||||
?>
|
||||
<table class="table table-bordered text-center">
|
||||
<thead class="table-secondary">
|
||||
<tr>
|
||||
<th>번호</th>
|
||||
<th>소속</th>
|
||||
<th>부서</th>
|
||||
<th>직위</th>
|
||||
<th>이름</th>
|
||||
<?php for ($m = 1; $m <= 12; $m++): ?>
|
||||
<th><?= $m ?>월</th>
|
||||
<?php endfor; ?>
|
||||
<th>합계</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$no = 1;
|
||||
foreach ($data as $row):
|
||||
$sum = array_sum($row['months']);
|
||||
?>
|
||||
<tr>
|
||||
<td><?= $no++ ?></td>
|
||||
<td><?= htmlspecialchars($row['corp'], ENT_QUOTES) ?></td>
|
||||
<td><?= htmlspecialchars($row['dept'], ENT_QUOTES) ?></td>
|
||||
<td><?= htmlspecialchars($row['position'], ENT_QUOTES) ?></td>
|
||||
<td><?= htmlspecialchars($row['name'], ENT_QUOTES) ?></td>
|
||||
<?php foreach ($row['months'] as $v): ?>
|
||||
<td><?= $v !== 0 ? $v : '' ?></td>
|
||||
<?php endforeach; ?>
|
||||
<td><?= $sum !== 0 ? $sum : '' ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
455
annualleave/process.php
Normal file
455
annualleave/process.php
Normal file
@@ -0,0 +1,455 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
$title_message = '연차 신청';
|
||||
|
||||
include $_SERVER['DOCUMENT_ROOT'] . '/load_header.php';
|
||||
|
||||
$tablename = "eworks";
|
||||
|
||||
isset($_REQUEST["num"]) ? $num=$_REQUEST["num"] : $num='';
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.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();
|
||||
$row = $stmh->fetch(PDO::FETCH_ASSOC); // $row 배열로 DB 정보를 불러온다.
|
||||
|
||||
include 'rowDBask.php';
|
||||
|
||||
}catch (PDOException $Exception) {
|
||||
print "오류: ".$Exception->getMessage();
|
||||
}
|
||||
// end of if
|
||||
|
||||
// 배열로 기본정보 불러옴
|
||||
include "load_DB.php";
|
||||
|
||||
// holiday 테이블에서 휴일 목록 불러오기
|
||||
$holidayDates = [];
|
||||
try {
|
||||
$holidaySql = "SELECT startdate, enddate FROM " . $DB . ".holiday WHERE is_deleted IS NULL";
|
||||
$holidayStmt = $pdo->query($holidaySql);
|
||||
$holidayRows = $holidayStmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
foreach ($holidayRows as $holidayRow) {
|
||||
$startdate = $holidayRow['startdate'];
|
||||
$enddate = $holidayRow['enddate'];
|
||||
|
||||
// enddate가 '0000-00-00'이거나 비어있으면 startdate만 휴일
|
||||
if (empty($enddate) || $enddate === '0000-00-00' || $enddate === null) {
|
||||
$holidayDates[] = $startdate;
|
||||
} else {
|
||||
// 기간 내의 모든 날짜를 배열에 추가
|
||||
$start = new DateTime($startdate);
|
||||
$end = new DateTime($enddate);
|
||||
$end->modify('+1 day'); // 종료일 포함
|
||||
|
||||
$period = new DatePeriod($start, new DateInterval('P1D'), $end);
|
||||
foreach ($period as $date) {
|
||||
$holidayDates[] = $date->format('Y-m-d');
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
// 오류 발생 시 빈 배열 유지
|
||||
error_log("Holiday 데이터 로드 오류: " . $e->getMessage());
|
||||
}
|
||||
|
||||
// print $totalremainday;
|
||||
|
||||
// 잔여일수 개인별 산출 루틴
|
||||
try{
|
||||
// 연차 잔여일수 산출
|
||||
$totalusedday = 0;
|
||||
$totalremainday = 0;
|
||||
for($i=0;$i<count($totalname_arr);$i++)
|
||||
if($author== $totalname_arr[$i])
|
||||
{
|
||||
$availableday = $availableday_arr[$i];
|
||||
}
|
||||
|
||||
// 연차 사용일수 계산
|
||||
for($i=0;$i<count($totalname_arr);$i++)
|
||||
if($author== $totalname_arr[$i])
|
||||
{
|
||||
$totalusedday = $totalused_arr[$i];
|
||||
$totalremainday = $availableday - $totalusedday;
|
||||
|
||||
}
|
||||
|
||||
} catch (PDOException $Exception) {
|
||||
print "오류: ".$Exception->getMessage();
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<body>
|
||||
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="myModal" role="dialog">
|
||||
<div class="modal-dialog modal-lg modal-center" >
|
||||
|
||||
<!-- Modal content-->
|
||||
<div class="modal-content modal-lg">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">알림</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div id=alertmsg class="fs-1 mb-5 justify-content-center" >
|
||||
결재가 완료되었습니다. <br>
|
||||
<br>
|
||||
수고하셨습니다.
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" id="closeModalBtn" class="btn btn-default" data-dismiss="modal">닫기</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container h-60">
|
||||
<div class="row d-flex justify-content-center align-items-center h-50">
|
||||
<div class="col-12 text-center">
|
||||
<div class="card align-middle" style="width:24rem; border-radius:20px;">
|
||||
<div class="card" style="padding:10px;margin:10px;">
|
||||
<h3 class="card-title text-center" style="color:#113366;"> (연차) 승인</h3>
|
||||
</div>
|
||||
<div class="card-body text-center">
|
||||
<form id="board_form" class="form-signin" method="post" >
|
||||
<input type="hidden" id="mode" name="mode">
|
||||
<input type="hidden" id="num" name="num" value="<?=$num?>" >
|
||||
<input type="hidden" id="registdate" name="registdate" value="<?=$today?>" >
|
||||
<input type="hidden" id="al_part" name="al_part" value="<?=$al_part?>" >
|
||||
<input type="hidden" id="author_id" name="author_id" value="<?=$author_id?>" >
|
||||
<input type="hidden" id="admin_name" name="admin_name" value="<?=$admin_name?>" >
|
||||
|
||||
<span class="form-control">
|
||||
성 명 <input type="text" id="author" name="author" size=8 class="text-center" readonly value="<?=$author?>" >
|
||||
</span>
|
||||
<span class="form-control">
|
||||
선택
|
||||
<?php
|
||||
// 연차종류 4종류로 만듬
|
||||
$item_arr = array('연차','오전반차','오전반반차','오후반차','오후반반차');
|
||||
for($i=0;$i<count($item_arr);$i++) {
|
||||
if($al_item==$item_arr[$i])
|
||||
print "<input type='radio' name='al_item' checked='checked' value='" . $item_arr[$i] . "'> " . $item_arr[$i] . "   ";
|
||||
else
|
||||
print "<input type='radio' name='al_item' value='" . $item_arr[$i] . "'> " . $item_arr[$i] . "   ";
|
||||
}
|
||||
?>
|
||||
|
||||
</span>
|
||||
<span class="form-control">
|
||||
신청시작일 <input type="date" id="al_askdatefrom" name="al_askdatefrom" readonly required autofocus value="<?=$al_askdatefrom?>" >
|
||||
</span>
|
||||
<span class="form-control">
|
||||
신청종료일
|
||||
<input type="date" id="askdateto" name="askdateto" readonly required value="<?=$al_askdateto?>" >
|
||||
</span>
|
||||
<span class="form-control">
|
||||
<span style="color:blue">신청 기간 산출</span>
|
||||
<input type="text" id="al_usedday" size=2 name="al_usedday" readonly class="text-center" value="<?=$al_usedday?>" >
|
||||
</span>
|
||||
<span class="form-control">
|
||||
<span style="color:red">연차 잔여일수</span>
|
||||
<input type="text" id="totalremainday" name="totalremainday" size=2 class="text-center" readonly value="<?=$totalremainday?>" >
|
||||
</span>
|
||||
<br>
|
||||
<h6 class="form-signin-heading">신청 사유</h6>
|
||||
<select name="al_content" id="al_content" readonly class="form-control text-center" >
|
||||
<?php
|
||||
$content_arr= array();
|
||||
array_push($content_arr,"개인사정","휴가","여행", "병원진료등", "모두 함께 쉬는 연차휴가", "기타");
|
||||
for($i=0;$i<count($content_arr);$i++) {
|
||||
if($al_content==$content_arr[$i])
|
||||
print "<option selected readonly value='" . $content_arr[$i] . "'> " . $content_arr[$i] . "</option>";
|
||||
else
|
||||
print "<option readonly value='" . $content_arr[$i] . "'> " . $content_arr[$i] . "</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<?php
|
||||
switch($status) {
|
||||
case 'send':
|
||||
$statusstr = '결재요청';
|
||||
break;
|
||||
case 'ing':
|
||||
$statusstr = '결재중';
|
||||
break;
|
||||
case 'end':
|
||||
$statusstr = '결재완료';
|
||||
break;
|
||||
default:
|
||||
$statusstr = '';
|
||||
break;
|
||||
}
|
||||
?>
|
||||
<h6 class="form-signin-heading">결재 상태</h6>
|
||||
<input type="hidden" id="status" name="status" value="<?=$status?>" >
|
||||
<input type="text" id="statusstr" name="statusstr" class="form-control text-center" readonly value="<?=$statusstr?>" >
|
||||
<br>
|
||||
<button id="saveBtn" class="btn btn-lg btn-secondary btn-block" type="button">
|
||||
<? if((int)$num>0) print '승인'; else print '결재요청(등록)'; ?></button>
|
||||
<? if((int)$num>0) { ?>
|
||||
<button id="delBtn" class="btn btn-lg btn-danger btn-block" type="button">삭제</button>
|
||||
<? } ?>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function(){
|
||||
// 파트 가져옴 (제조파트, 지원파트)
|
||||
var al_part = '<?php echo $al_part; ?>';
|
||||
|
||||
// 신청일 변경시 종료일도 변경함
|
||||
$("#al_askdatefrom").change(function(){
|
||||
var radioVal = $('input[name="al_item"]:checked').val();
|
||||
console.log(radioVal);
|
||||
$('#al_askdateto').val($("#al_askdatefrom").val());
|
||||
|
||||
const result = getDateDiff($("#al_askdatefrom").val(), $("#al_askdateto").val());
|
||||
|
||||
switch(radioVal)
|
||||
{
|
||||
case '연차' :
|
||||
$('#al_usedday').val(result);
|
||||
break;
|
||||
case '오전반차' :
|
||||
case '오후반차' :
|
||||
$('#al_usedday').val(result/2);
|
||||
break;
|
||||
case '오전반반차' :
|
||||
case '오후반반차' :
|
||||
$('#al_usedday').val(result/4);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
$('input[name="al_item"]').change(function(){
|
||||
var radioVal = $('input[name="al_item"]:checked').val();
|
||||
console.log(radioVal);
|
||||
|
||||
// $('#al_askdateto').val($("#al_askdatefrom").val());
|
||||
|
||||
const result = getDateDiff($("#al_askdatefrom").val(), $("#al_askdateto").val());
|
||||
|
||||
switch(radioVal)
|
||||
{
|
||||
case '연차' :
|
||||
$('#al_usedday').val(result);
|
||||
break;
|
||||
case '오전반차' :
|
||||
case '오후반차' :
|
||||
$('#al_usedday').val(result/2);
|
||||
break;
|
||||
case '오전반반차' :
|
||||
case '오후반반차' :
|
||||
$('#al_usedday').val(result/4);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
// 종료일을 변경해도 자동계산해 주기
|
||||
$("#al_askdateto").change(function(){
|
||||
var radioVal = $('input[name="al_item"]:checked').val();
|
||||
console.log(radioVal);
|
||||
// $('#al_askdateto').val($("#al_askdatefrom").val());
|
||||
|
||||
const result = getDateDiff($("#al_askdatefrom").val(), $("#al_askdateto").val());
|
||||
|
||||
switch(radioVal)
|
||||
{
|
||||
case '연차' :
|
||||
$('#al_usedday').val(result);
|
||||
break;
|
||||
case '오전반차' :
|
||||
case '오후반차' :
|
||||
$('#al_usedday').val(result/2);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
$("#closeBtn").click(function(){ // 저장하고 창닫기
|
||||
|
||||
});
|
||||
|
||||
$("#copyBtn").click(function(){ // 데이터복사버튼
|
||||
|
||||
var num = $("#num").val();
|
||||
location.href='copy_data.php?num=' + num;
|
||||
});
|
||||
|
||||
$("#saveBtn").click(function(){ // DATA 저장버튼 누름
|
||||
var num = $("#num").val();
|
||||
var status = $("#status").val();
|
||||
$("#mode").val('modify');
|
||||
var admin_name = $("#admin_name").val();
|
||||
|
||||
var resultOK = 0;
|
||||
|
||||
console.log(status);
|
||||
console.log(admin_name);
|
||||
|
||||
if((admin_name == '소현철' || admin_name =='김보곤') && status =='ing') {
|
||||
$("#status").val('end');
|
||||
resultOK = 1;
|
||||
} // end of if
|
||||
|
||||
// 지원파트 1차 결재
|
||||
if((admin_name=='최장중' || admin_name=='김보곤') && status=='send' && al_part=='지원파트') {
|
||||
$("#status").val('ing');
|
||||
resultOK = 1;
|
||||
} // end of if
|
||||
// 제조파트 1차 결재
|
||||
if((admin_name=='이경묵' || admin_name=='김보곤') && status=='send' && al_part=='제조파트') {
|
||||
$("#status").val('ing');
|
||||
resultOK = 1;
|
||||
} // end of if
|
||||
|
||||
console.log('변경후 status ' + status);
|
||||
if(resultOK == 1) { // 결과가 성공하면
|
||||
$.ajax({
|
||||
url: "insert_ask.php",
|
||||
type: "post",
|
||||
data: $("#board_form").serialize(),
|
||||
dataType:"json",
|
||||
success : function( data ){
|
||||
console.log( data);
|
||||
$('#myModal').modal('show');
|
||||
//1초 지연후 실행
|
||||
setTimeout(function() {
|
||||
opener.location.reload();
|
||||
window.close();
|
||||
}, 2000);
|
||||
},
|
||||
error : function( jqxhr , status , error ){
|
||||
console.log( jqxhr , status , error );
|
||||
}
|
||||
});
|
||||
}
|
||||
else // 오류가 있으면 오류창 띄움
|
||||
{
|
||||
tmp='결재권자가 틀립니다. 확인바랍니다.';
|
||||
$('#alertmsg').html(tmp);
|
||||
$('#myModal').modal('show');
|
||||
//1초 지연후 실행
|
||||
setTimeout(function() {
|
||||
opener.location.reload();
|
||||
window.close();
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
$("#delBtn").click(function(){ // del
|
||||
var num = $("#num").val();
|
||||
var status = $("#status").val();
|
||||
|
||||
// 결재요청이 아닌경우 수정안됨
|
||||
if(confirm("데이터 삭제.\n\n정말 지우시겠습니까?")) {
|
||||
$("#mode").val('delete');
|
||||
$.ajax({
|
||||
url: "insert_ask.php",
|
||||
type: "post",
|
||||
data: $("#board_form").serialize(),
|
||||
dataType:"json",
|
||||
success : function( data ){
|
||||
console.log( data);
|
||||
opener.location.reload();
|
||||
window.close();
|
||||
},
|
||||
error : function( jqxhr , status , error ){
|
||||
console.log( jqxhr , status , error );
|
||||
}
|
||||
});
|
||||
} // end of if
|
||||
|
||||
});
|
||||
|
||||
|
||||
}); // end of ready document
|
||||
|
||||
// PHP에서 전달된 휴일 목록을 JavaScript 변수로 변환
|
||||
var holidayDates = <?= json_encode($holidayDates, JSON_UNESCAPED_UNICODE) ?>;
|
||||
// 휴일 날짜를 Set으로 변환하여 빠른 검색 가능하도록 함
|
||||
var holidaySet = new Set(holidayDates);
|
||||
|
||||
// 날짜를 YYYY-MM-DD 형식으로 변환하는 함수
|
||||
function formatDate(date) {
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
return year + '-' + month + '-' + day;
|
||||
}
|
||||
|
||||
// 두날짜 사이 일자 구하기 (주말과 휴일 제외)
|
||||
const getDateDiff = (d1, d2) => {
|
||||
if (!d1 || !d2) return 0;
|
||||
|
||||
const date1 = new Date(d1);
|
||||
const date2 = new Date(d2);
|
||||
|
||||
// 날짜 유효성 검사
|
||||
if (isNaN(date1.getTime()) || isNaN(date2.getTime())) {
|
||||
console.warn('getDateDiff: 유효하지 않은 날짜', d1, d2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// holidaySet이 없으면 빈 Set 사용 (방어 코드)
|
||||
const holidays = (typeof holidaySet !== 'undefined' && holidaySet instanceof Set)
|
||||
? holidaySet
|
||||
: (typeof window.holidaySet !== 'undefined' && window.holidaySet instanceof Set)
|
||||
? window.holidaySet
|
||||
: new Set();
|
||||
|
||||
let count = 0;
|
||||
const oneDay = 24 * 60 * 60 * 1000; // 하루의 밀리세컨드 수
|
||||
|
||||
// 시작일과 종료일을 포함하여 계산하기 위해 date1의 복사본 생성
|
||||
let startDate = new Date(date1);
|
||||
let endDate = new Date(date2);
|
||||
|
||||
// 시작일이 종료일보다 큰 경우 교환
|
||||
if (startDate > endDate) {
|
||||
const temp = startDate;
|
||||
startDate = endDate;
|
||||
endDate = temp;
|
||||
}
|
||||
|
||||
// 시작일부터 종료일까지 반복 (포함)
|
||||
const currentDate = new Date(startDate);
|
||||
while (currentDate <= endDate) {
|
||||
const dayOfWeek = currentDate.getDay(); // 요일 (0:일, 1:월, ..., 6:토)
|
||||
const dateString = formatDate(currentDate); // YYYY-MM-DD 형식으로 변환
|
||||
|
||||
// 주말이 아니고 휴일도 아닌 경우에만 count 증가
|
||||
if (dayOfWeek !== 0 && dayOfWeek !== 6 && !holidays.has(dateString)) {
|
||||
count++;
|
||||
}
|
||||
|
||||
currentDate.setTime(currentDate.getTime() + oneDay); // 다음 날짜로 이동
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
15
annualleave/rowDB.php
Normal file
15
annualleave/rowDB.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?
|
||||
|
||||
// .almember 테이블의 자료
|
||||
$num = isset($row["num"]) ? $row["num"] : '';
|
||||
$name = isset($row["name"]) ? $row["name"] : '';
|
||||
$part = isset($row["part"]) ? $row["part"] : '';
|
||||
$company = isset($row["company"]) ? $row["company"] : '';
|
||||
|
||||
$dateofentry = isset($row["dateofentry"]) ? $row["dateofentry"] : '';
|
||||
$referencedate = isset($row["referencedate"]) ? $row["referencedate"] : '';
|
||||
$availableday = isset($row["availableday"]) ? $row["availableday"] : '';
|
||||
$comment = isset($row["comment"]) ? $row["comment"] : '';
|
||||
|
||||
|
||||
?>
|
||||
18
annualleave/rowDBask.php
Normal file
18
annualleave/rowDBask.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
$num = isset($row["num"]) ? $row["num"] : '';
|
||||
$author_id = isset($row["author_id"]) ? $row["author_id"] : ''; // Using corrected key
|
||||
$author = isset($row["author"]) ? $row["author"] : '';
|
||||
$al_company = isset($row["al_company"]) ? $row["al_company"] : '';
|
||||
$al_part = isset($row["al_part"]) ? $row["al_part"] : '';
|
||||
$registdate = isset($row["registdate"]) ? $row["registdate"] : '';
|
||||
$al_item = isset($row["al_item"]) ? $row["al_item"] : '';
|
||||
$al_askdatefrom = isset($row["al_askdatefrom"]) ? $row["al_askdatefrom"] : '';
|
||||
$al_askdateto = isset($row["al_askdateto"]) ? $row["al_askdateto"] : '';
|
||||
$al_usedday = isset($row["al_usedday"]) ? $row["al_usedday"] : '';
|
||||
$al_content = isset($row["al_content"]) ? $row["al_content"] : '';
|
||||
$status = isset($row["status"]) ? $row["status"] : '';
|
||||
$e_line = isset($row["e_line"]) ? $row["e_line"] : '';
|
||||
$e_confirm = isset($row["e_confirm"]) ? $row["e_confirm"] : '';
|
||||
$e_confirm_id = isset($row["e_confirm_id"]) ? $row["e_confirm_id"] : '';
|
||||
|
||||
?>
|
||||
287
annualleave/write_form.php
Normal file
287
annualleave/write_form.php
Normal file
@@ -0,0 +1,287 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
// 권한 체크 (관리자 이하만 접근)
|
||||
if (!isset($_SESSION["level"]) || intval($_SESSION["level"]) > 1) {
|
||||
sleep(1);
|
||||
header("Location:" . $WebSite . "login/login_form.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$title_message = '연차 설정';
|
||||
$admin = (intval($_SESSION["level"]) === 1) ? 1 : 0;
|
||||
|
||||
$tablename = 'almember';
|
||||
$num = $_REQUEST["num"] ?? '';
|
||||
$mode = $_REQUEST["mode"] ?? '';
|
||||
$mode = isset($_REQUEST["mode"]) ? $_REQUEST["mode"] : '';
|
||||
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/common.php");
|
||||
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
|
||||
// modify 모드면 기존 데이터 조회하여 변수 설정
|
||||
if ($mode == 'modify' && !empty($num)) {
|
||||
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);
|
||||
// _row.php 내부에서 $name, $comment, $company, $part, $dateofentry, $referencedate, $availableday 등 변수를 설정한다고 가정
|
||||
include $_SERVER['DOCUMENT_ROOT'] . '/almember/_row.php';
|
||||
|
||||
} catch (PDOException $Exception) {
|
||||
print "오류: " . $Exception->getMessage();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
$referencedate = date('Y'); // 현재 연도만 가져오기
|
||||
}
|
||||
|
||||
$usedname = $name; // 불러온 이름 저장
|
||||
|
||||
// almember의 기본정보 배열을 불러옴 (예, $basic_name_arr, $basic_part_arr 등)
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/almember/load_DB.php");
|
||||
|
||||
// member 테이블에서 회사(division) 정보를 distinct로 조회하여 select 옵션에 사용
|
||||
$divisions = [];
|
||||
try {
|
||||
$sql = "SELECT DISTINCT division FROM {$DB}.member WHERE division IS NOT NULL AND division <> ''";
|
||||
$stmt = $pdo->query($sql);
|
||||
$divisions = $stmt->fetchAll(PDO::FETCH_COLUMN);
|
||||
} catch (PDOException $e) {
|
||||
print "오류: " . $e->getMessage();
|
||||
}
|
||||
|
||||
include $_SERVER['DOCUMENT_ROOT'] . '/load_header.php' ?>
|
||||
<title><?=htmlspecialchars($title_message)?></title>
|
||||
<!-- 추가 CSS나 메타 태그가 필요하면 여기 추가 -->
|
||||
</head>
|
||||
<body>
|
||||
<div class="container mt-4">
|
||||
<h4 class="text-center mb-4"><?=htmlspecialchars($title_message)?></h4>
|
||||
<form name="board_form" id="board_form" method="post">
|
||||
<!-- 숨겨진 필드들 -->
|
||||
<input type="hidden" id="mode" name="mode">
|
||||
<input type="hidden" id="num" name="num" value="<?=htmlspecialchars($num)?>">
|
||||
<input type="hidden" id="user_name" name="user_name" value="<?=htmlspecialchars($user_name)?>">
|
||||
<input type="hidden" id="admin" name="admin" value="<?=htmlspecialchars($admin)?>">
|
||||
<!-- 부트스트랩 table (4열) 형태의 입력폼 -->
|
||||
<table class="table table-bordered">
|
||||
<tbody>
|
||||
<!-- 1행: 회사 / 부서 -->
|
||||
<tr>
|
||||
<td style="width:20%;"><label for="name">성명</label></td>
|
||||
<td style="width:30%;">
|
||||
<select name="name" id="name" required class="form-select mx-1 d-block w-auto" style="font-size: 0.8rem; height: 32px;">
|
||||
<?php
|
||||
// employee_name_arr 를 이용하여 옵션 생성 (중복 제거)
|
||||
$unique_names = array_unique($employee_name_arr);
|
||||
foreach ($unique_names as $n) {
|
||||
$selected = (isset($usedname) && $usedname === $n) ? "selected" : "";
|
||||
echo "<option value=\"" . htmlspecialchars($n) . "\" $selected>" . htmlspecialchars($n) . "</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
<td style="width:20%;"><label for="dateofentry">입사일</label></td>
|
||||
<td style="width:30%;">
|
||||
<input type="date" id="dateofentry" name="dateofentry" class="form-control" placeholder="입사일" readonly required value="<?=isset($dateofentry) ? htmlspecialchars($dateofentry) : ''?>">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="company">회사</label></td>
|
||||
<td>
|
||||
<input type="text" id="company" name="company" class="form-control" placeholder="회사" readonly required value="<?=isset($company) ? htmlspecialchars($company) : ''?>">
|
||||
</td>
|
||||
<td style="width:15%;"><label for="part">부서</label></td>
|
||||
<td style="width:35%;">
|
||||
<input type="text" id="part" name="part" class="form-control" placeholder="부서" readonly required value="<?=isset($part) ? htmlspecialchars($part) : ''?>">
|
||||
</td>
|
||||
</tr>
|
||||
<!-- 3행: 해당연도 -->
|
||||
<tr>
|
||||
<td><label for="referencedate">해당연도</label></td>
|
||||
<td>
|
||||
<input type="number" id="referencedate" name="referencedate" class="form-control" placeholder="해당연도" required value="<?=isset($referencedate) ? htmlspecialchars($referencedate) : ''?>">
|
||||
</td>
|
||||
<td class="text-center"><label for="continueYear">근속년수</label></td>
|
||||
<td>
|
||||
<input type="number" id="continueYear" name="continueYear" class="form-control" placeholder="근속년수" readonly required value="<?=isset($continueYear) ? htmlspecialchars($availableday) : ''?>">
|
||||
</td>
|
||||
</tr>
|
||||
<!-- 4행: 해당연도 -->
|
||||
<tr>
|
||||
<td class="text-center"><label for="initial_less_than_one_year">1년미만 가산</label></td>
|
||||
<td>
|
||||
<input type="number" id="initial_less_than_one_year" name="initial_less_than_one_year" class="form-control" readonly placeholder="1년미만 가산" required value="<?=isset($initial_less_than_one_year) ? htmlspecialchars($availableday) : ''?>">
|
||||
</td>
|
||||
<td><label for="service_based">년도별 연차</label></td>
|
||||
<td>
|
||||
<input type="number" id="service_based" name="service_based" class="form-control" placeholder="년도별 연차" readonly required value="<?=isset($service_based) ? htmlspecialchars($service_based) : ''?>">
|
||||
</td>
|
||||
</tr>
|
||||
<!-- 5행: 선사용 년도별 연차 발생일수 -->
|
||||
<tr>
|
||||
<td class="text-center"><label for="previous_year_usage" class="fw-bold text-dnager" >전년도 선사용</label></td>
|
||||
<td colspan="1">
|
||||
<input type="number" id="previous_year_usage" name="previous_year_usage" class="form-control fw-bold text-dnager" placeholder="전년도 선사용" required value="<?=isset($previous_year_usage) ? htmlspecialchars($previous_year_usage) : ''?>">
|
||||
</td>
|
||||
<td class="text-center"><label for="availableday" class="fw-bold text-primary" >발생일수</label></td>
|
||||
<td colspan="1">
|
||||
<input type="number" id="availableday" name="availableday" class="form-control fw-bold text-primary" placeholder="발생일수" readonly required value="<?=isset($availableday) ? htmlspecialchars($availableday) : ''?>">
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
<!-- 하단 버튼 영역 -->
|
||||
<div class="d-flex justify-content-end mt-4">
|
||||
<button type="button" id="saveBtn" class="btn btn-dark btn-sm mx-1"> <i class="bi bi-floppy-fill"></i> 저장
|
||||
<?= ((int)$num > 0 ? '수정' : '저장') ?>
|
||||
</button>
|
||||
<?php if ((int)$num > 0) { ?>
|
||||
<button type="button" id="copyBtn" class="btn btn-primary btn-sm mx-1"> <i class="bi bi-copy"></i> 데이터복사</button>
|
||||
<button type="button" id="delBtn" class="btn btn-danger btn-sm mx-1"> <i class="bi bi-trash"></i> 삭제 </button>
|
||||
<?php } ?>
|
||||
<button type="button" id="closeBtn" class="btn btn-secondary btn-sm ms-4"> × 닫기</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
// 로딩 오버레이가 있다면 숨김
|
||||
var loader = document.getElementById('loadingOverlay');
|
||||
if(loader) loader.style.display = 'none';
|
||||
|
||||
// 성명 선택 변경 시, 해당 직원의 정보를 가져와 동적으로 업데이트
|
||||
$("#name").change(function(){
|
||||
var selectedName = $(this).val();
|
||||
$.ajax({
|
||||
url: "get_employee_info.php",
|
||||
type: "post",
|
||||
data: { name: selectedName },
|
||||
dataType: "json",
|
||||
success: function(data){
|
||||
//alert(data);
|
||||
console.log(data);
|
||||
if(data) {
|
||||
// 업데이트: 회사, 부서, 입사일
|
||||
$("#company").val(data.division);
|
||||
$("#part").val(data.part);
|
||||
$("#dateofentry").val(data.enterDate);
|
||||
$("#referencedate").val(data.referencedate);
|
||||
$("#initial_less_than_one_year").val(data.initial_less_than_one_year);
|
||||
$("#continueYear").val(data.continueYear);
|
||||
$("#service_based").val(data.service_based);
|
||||
$("#previous_year_usage").val(data.previous_year_usage);
|
||||
$("#availableday").val(data.available);
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error){
|
||||
console.log("Error: " + error);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$("#closeBtn").click(function(){
|
||||
self.close();
|
||||
});
|
||||
|
||||
$("#saveBtn").click(function(){
|
||||
var admin = $("#admin").val();
|
||||
if(admin == '1'){
|
||||
var num = $("#num").val();
|
||||
// num 값이 있으면 modify, 없으면 insert 모드로 전송
|
||||
if(Number(num) > 0)
|
||||
$("#mode").val('modify');
|
||||
else
|
||||
$("#mode").val('insert');
|
||||
|
||||
$.ajax({
|
||||
url: "insert.php",
|
||||
type: "post",
|
||||
data: $("#board_form").serialize(),
|
||||
dataType: "json",
|
||||
success: function(data){
|
||||
console.log(data);
|
||||
setTimeout(function(){
|
||||
opener.location.reload();
|
||||
window.close();
|
||||
}, 1000);
|
||||
},
|
||||
error: function(jqxhr, status, error){
|
||||
console.log(jqxhr, status, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$("#copyBtn").click(function(){
|
||||
var admin = $("#admin").val();
|
||||
if(admin == '1'){
|
||||
$("#mode").val('copy');
|
||||
$.ajax({
|
||||
url: "insert.php",
|
||||
type: "post",
|
||||
data: $("#board_form").serialize(),
|
||||
dataType: "json",
|
||||
success: function(data){
|
||||
console.log(data);
|
||||
setTimeout(function(){
|
||||
opener.location.reload();
|
||||
window.close();
|
||||
}, 1000);
|
||||
},
|
||||
error: function(jqxhr, status, error){
|
||||
console.log(jqxhr, status, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$("#delBtn").click(function(){
|
||||
var admin = $("#admin").val();
|
||||
if(admin == '1'){
|
||||
Swal.fire({
|
||||
title: '해당 DATA 삭제',
|
||||
text: "DATA 삭제는 신중하셔야 합니다.\n정말 삭제 하시겠습니까?",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: '삭제',
|
||||
cancelButtonText: '취소'
|
||||
}).then((result) => {
|
||||
if(result.isConfirmed){
|
||||
$("#mode").val('delete');
|
||||
$.ajax({
|
||||
url: "insert.php",
|
||||
type: "post",
|
||||
data: $("#board_form").serialize(),
|
||||
dataType: "json",
|
||||
success: function(data){
|
||||
console.log(data);
|
||||
opener.location.reload();
|
||||
window.close();
|
||||
},
|
||||
error: function(jqxhr, status, error){
|
||||
console.log(jqxhr, status, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// 최초실행시 선택
|
||||
$("#name").trigger('change');
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
715
annualleave/write_form_ask.php
Normal file
715
annualleave/write_form_ask.php
Normal file
@@ -0,0 +1,715 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
$title_message = '연차 신청';
|
||||
|
||||
?>
|
||||
|
||||
<?php include $_SERVER['DOCUMENT_ROOT'] . '/load_header.php' ?>
|
||||
|
||||
|
||||
<title> <?=$title_message?> </title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="myModal" role="dialog">
|
||||
<div class="modal-dialog modal-lg modal-center" >
|
||||
|
||||
<!-- Modal al_content-->
|
||||
<div class="modal-al_content modal-lg">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">알림</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div id="alertmsg" class="fs-1 mb-5 justify-al_content-center" >
|
||||
결재가 진행중입니다. <br>
|
||||
<br>
|
||||
수정사항이 있으면 결재권자에게 말씀해 주세요.
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" id="closeModalBtn" class="btn btn-default" data-dismiss="modal">닫기</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
$tablename = "eworks";
|
||||
|
||||
isset($_REQUEST["num"]) ? $num=$_REQUEST["num"] : $num='';
|
||||
isset($_REQUEST["viewoption"]) ? $viewoption = $_REQUEST["viewoption"] : $viewoption='';
|
||||
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.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();
|
||||
$row = $stmh->fetch(PDO::FETCH_ASSOC); // $row 배열로 DB 정보를 불러온다.
|
||||
|
||||
include 'rowDBask.php';
|
||||
|
||||
}catch (PDOException $Exception) {
|
||||
print "오류: ".$Exception->getMessage();
|
||||
}
|
||||
// end of if
|
||||
|
||||
// 배열로 기본정보 불러옴
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/almember/load_DB.php");
|
||||
|
||||
// holiday 테이블에서 휴일 목록 불러오기
|
||||
$holidayDates = [];
|
||||
try {
|
||||
$holidaySql = "SELECT startdate, enddate FROM " . $DB . ".holiday WHERE is_deleted IS NULL";
|
||||
$holidayStmt = $pdo->query($holidaySql);
|
||||
$holidayRows = $holidayStmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
foreach ($holidayRows as $holidayRow) {
|
||||
$startdate = $holidayRow['startdate'];
|
||||
$enddate = $holidayRow['enddate'];
|
||||
|
||||
// enddate가 '0000-00-00'이거나 비어있으면 startdate만 휴일
|
||||
if (empty($enddate) || $enddate === '0000-00-00' || $enddate === null) {
|
||||
$holidayDates[] = $startdate;
|
||||
} else {
|
||||
// 기간 내의 모든 날짜를 배열에 추가
|
||||
$start = new DateTime($startdate);
|
||||
$end = new DateTime($enddate);
|
||||
$end->modify('+1 day'); // 종료일 포함
|
||||
|
||||
$period = new DatePeriod($start, new DateInterval('P1D'), $end);
|
||||
foreach ($period as $date) {
|
||||
$holidayDates[] = $date->format('Y-m-d');
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
// 오류 발생 시 빈 배열 유지
|
||||
error_log("Holiday 데이터 로드 오류: " . $e->getMessage());
|
||||
}
|
||||
|
||||
if($num=='')
|
||||
{
|
||||
$registdate = date("Y-m-d H:i:s");
|
||||
$al_askdatefrom=date("Y-m-d");
|
||||
$al_askdateto=date("Y-m-d");
|
||||
// 신규데이터인 경우
|
||||
$al_usedday = abs(strtotime($al_askdateto) - strtotime($al_askdatefrom)) + 1; // 날짜 빼기 계산
|
||||
$al_item='연차';
|
||||
$status='send';
|
||||
$statusstr='결재요청';
|
||||
$author= $_SESSION["name"];
|
||||
$author_id= $user_id;
|
||||
|
||||
// DB에서 al_part 찾아서 넣어주기
|
||||
|
||||
// 전 직원 배열로 계산 후 사용일수 남은일수 값 넣기
|
||||
for($i=0;$i<count($basic_name_arr);$i++)
|
||||
{
|
||||
if(trim($basic_name_arr[$i]) == trim($author))
|
||||
{
|
||||
$al_part = $basic_part_arr[$i];
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 잔여일수 개인별 산출 루틴
|
||||
try{
|
||||
|
||||
// 연차 잔여일수 산출
|
||||
$totalusedday = 0;
|
||||
$totalremainday = 0;
|
||||
for($i=0;$i<count($totalname_arr);$i++)
|
||||
if($author== $totalname_arr[$i])
|
||||
{
|
||||
$availableday = $availableday_arr[$i];
|
||||
}
|
||||
|
||||
// 연차 사용일수 계산
|
||||
for($i=0;$i<count($totalname_arr);$i++)
|
||||
if($author== $totalname_arr[$i])
|
||||
{
|
||||
$totalusedday = $totalused_arr[$i];
|
||||
$totalremainday = $availableday - $totalusedday;
|
||||
|
||||
}
|
||||
|
||||
} catch (PDOException $Exception) {
|
||||
print "오류: ".$Exception->getMessage();
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<form id="board_form" name="board_form" class="form-signin" method="post" >
|
||||
|
||||
<div class="container-fluid" style="width:380px;">
|
||||
<div class="row d-flex justify-al_content-center align-items-center h-50">
|
||||
<div class="col-12 text-center">
|
||||
<div class="card align-middle" style="border-radius:20px;">
|
||||
<div class="card" style="padding:10px;margin:10px;">
|
||||
<h3 class="card-title text-center" style="color:#113366;"> (연차)신청 </h3>
|
||||
</div>
|
||||
<div class="card-body text-center">
|
||||
|
||||
<input type="hidden" id="mode" name="mode">
|
||||
<input type="hidden" id="num" name="num" value="<?= isset($num) ? $num : '' ?>">
|
||||
<input type="hidden" id="registdate" name="registdate" value="<?= isset($registdate) ? $registdate : '' ?>">
|
||||
<input type="hidden" id="user_name" name="user_name" value="<?= isset($user_name) ? $user_name : '' ?>">
|
||||
<input type="hidden" id="author_id" name="author_id" value="<?= isset($author_id) ? $author_id : '' ?>">
|
||||
<input type="hidden" id="viewoption" name="viewoption" value="<?= isset($viewoption) ? $viewoption : '' ?>">
|
||||
<input type="hidden" id="htmltext" name="htmltext">
|
||||
<?php
|
||||
|
||||
//var_dump($al_part);
|
||||
if($e_confirm ==='')
|
||||
{
|
||||
$formattedDate = date("m/d", strtotime($registdate)); // 월/일 형식으로 변환
|
||||
// echo $formattedDate; // 출력
|
||||
|
||||
if($al_part=='대한')
|
||||
{
|
||||
$approvals = array(
|
||||
array("name" => "대표 신동조", "date" => $formattedDate),
|
||||
// 더 많은 결재권자가 있을 수 있음...
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$approver_ids = explode('!', $e_confirm_id);
|
||||
$approver_details = explode('!', $e_confirm);
|
||||
|
||||
$approvals = array();
|
||||
|
||||
foreach($approver_ids as $index => $id) {
|
||||
if (isset($approver_details[$index])) {
|
||||
// Use regex to match the pattern (name title date time)
|
||||
// The pattern looks for any character until it hits a series of digits that resemble a date followed by a time
|
||||
preg_match("/^(.+ \d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})$/", $approver_details[$index], $matches);
|
||||
|
||||
// Ensure that the full pattern and the two capturing groups are present
|
||||
if (count($matches) === 3) {
|
||||
$nameWithTitle = $matches[1]; // This is the name and title
|
||||
$time = $matches[2]; // This is the time
|
||||
$date = substr($nameWithTitle, -10); // Extract date from the end of the 'nameWithTitle' string
|
||||
$nameWithTitle = trim(str_replace($date, '', $nameWithTitle)); // Remove the date from the 'nameWithTitle' to get just the name and title
|
||||
$formattedDate = date("m/d H:i:s", strtotime("$date $time")); // Combining date and time
|
||||
|
||||
$approvals[] = array("name" => $nameWithTitle, "date" => $formattedDate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// // Now $approvals contains the necessary details
|
||||
// foreach ($approvals as $approval) {
|
||||
// echo "Approver: " . $approval['name'] . ", Date: " . $approval['date'] . "<br>";
|
||||
// }
|
||||
}
|
||||
|
||||
if($status === 'end')
|
||||
{
|
||||
?>
|
||||
<div class="container mb-2" style="width:300px;">
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="<?php echo count($approvals); ?>" class="text-center fs-6">결재</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<?php foreach ($approvals as $approval) { ?>
|
||||
<td class="text-center fs-6" style="height: 70px;"><?php echo $approval["name"]; ?></td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<tr>
|
||||
<?php foreach ($approvals as $approval) { ?>
|
||||
<td class="text-center"><?php echo $approval["date"]; ?></td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<? } ?>
|
||||
<div id="savetext">
|
||||
<span class="form-control">
|
||||
성명
|
||||
<select name="author" id="author" class="text-center" >
|
||||
<?php
|
||||
for($i=0;$i<count($employee_name_arr);$i++) {
|
||||
if($author==$employee_name_arr[$i])
|
||||
print "<option selected value='" . $employee_name_arr[$i] . "'> " . $employee_name_arr[$i] . "</option>";
|
||||
else
|
||||
print "<option value='" . $employee_name_arr[$i] . "'> " . $employee_name_arr[$i] . "</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<!-- 이전 코드 생략 -->
|
||||
부서
|
||||
|
||||
<input type="text" id="al_company" name="al_company" value="<?=$al_company ?>" class="form-control w80px" readonly>
|
||||
<input type="text" id="al_part" name="al_part" value="<?=$al_part ?>" class="form-control w80px" readonly>
|
||||
<!-- 나머지 코드 생략 -->
|
||||
</span>
|
||||
<h6 class="form-signin-heading mt-2 mb-2">구분</h6>
|
||||
<span class="form-control">
|
||||
<?php
|
||||
// 연차종류 6종류로 만듬
|
||||
$item_arr = array('연차','오전반차','오전반반차','오후반차','오후반반차','경조사');
|
||||
for($i=0;$i<count($item_arr);$i++) {
|
||||
if($al_item==$item_arr[$i])
|
||||
print "<input type='radio' name='al_item' checked='checked' value='" . $item_arr[$i] . "'> " . $item_arr[$i] . "   ";
|
||||
else
|
||||
print "<input type='radio' name='al_item' value='" . $item_arr[$i] . "'> " . $item_arr[$i] . "   ";
|
||||
|
||||
if($i%2 == 0)
|
||||
print "<br>";
|
||||
}
|
||||
?>
|
||||
|
||||
</span>
|
||||
|
||||
<h6 class="form-signin-heading mt-2 mb-2">기간</h6>
|
||||
<span class="form-control">
|
||||
신청시작일 <input type="date" id="al_askdatefrom" name="al_askdatefrom" required autofocus value="<?=$al_askdatefrom?>" >
|
||||
</span>
|
||||
<span class="form-control">
|
||||
신청종료일
|
||||
<input type="date" id="al_askdateto" name="al_askdateto" required value="<?=$al_askdateto?>" >
|
||||
</span>
|
||||
<span class="form-control">
|
||||
<span style="color:blue">신청 기간 산출</span>
|
||||
<input type="text" id="al_usedday" size="2" name="al_usedday" readonly class="text-center" value="<?=$al_usedday?>" >
|
||||
</span>
|
||||
<span class="form-control">
|
||||
<span style="color:red">연차 잔여일수</span>
|
||||
<input type="text" id="totalremainday" name="totalremainday" size="2" class="text-center" readonly value="<?=$totalremainday?>" >
|
||||
</span>
|
||||
<br>
|
||||
<h6 class="form-signin-heading mt-2 mb-2">신청 사유</h6>
|
||||
<select name="al_content" id="al_content" class="text-center" >
|
||||
<?php
|
||||
$al_content_arr= array();
|
||||
array_push($al_content_arr,"개인사정","휴가","여행", "병원진료등", "전직원연차", "경조사", "기타");
|
||||
for($i=0;$i<count($al_content_arr);$i++) {
|
||||
if($al_content==$al_content_arr[$i])
|
||||
print "<option selected value='" . $al_content_arr[$i] . "'> " . $al_content_arr[$i] . "</option>";
|
||||
else
|
||||
print "<option value='" . $al_content_arr[$i] . "'> " . $al_content_arr[$i] . "</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div> <!-- end of savetext -->
|
||||
|
||||
<?php
|
||||
switch($status) {
|
||||
|
||||
case 'send':
|
||||
$statusstr = '결재요청';
|
||||
break;
|
||||
case 'ing':
|
||||
$statusstr = '결재중';
|
||||
break;
|
||||
case 'end':
|
||||
$statusstr = '결재완료';
|
||||
break;
|
||||
default:
|
||||
$statusstr = '';
|
||||
break;
|
||||
}
|
||||
?>
|
||||
|
||||
<h6 class="form-signin-heading mt-2 mb-2">결재 상태</h6>
|
||||
<input type="hidden" id="status" name="status" value="<?=$status?>" >
|
||||
<input type="text" id="statusstr" name="statusstr" class="text-center mb-3" readonly value="<?=$statusstr?>" >
|
||||
<br>
|
||||
<? if((int)$num>0 and $statusstr!=='결재완료') {
|
||||
print '<button id="saveBtn" class="btn btn-sm btn-dark me-1 " type="button"> ';
|
||||
print '결재요청(수정)';
|
||||
print '</button>';
|
||||
}
|
||||
else if( $statusstr!=='결재완료') {
|
||||
print '<button id="saveBtn" class="btn btn-sm btn-dark me-1 " type="button"> ';
|
||||
print '결재요청';
|
||||
print '</button>';
|
||||
}
|
||||
?>
|
||||
<? if((int)$num>0 and $statusstr!=='결재완료') { ?>
|
||||
<button id="delBtn" class="btn btn-sm btn-danger mx-1" type="button"> <i class="bi bi-trash"></i> 삭제 </button>
|
||||
<? } ?>
|
||||
<? if($user_name=='김보곤' and (int)$num<2 ) { ?>
|
||||
<button id="massBtn" class="btn btn-sm btn-primary mx-1" type="button"> <i class="bi bi-floppy-fill"></i> 대량등록</button>
|
||||
<? } ?>
|
||||
<button class="btn btn-dark btn-sm ms-4" id="closeBtn" > × 닫기 </button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
ajaxRequest = null;
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
var loader = document.getElementById('loadingOverlay');
|
||||
if(loader)
|
||||
loader.style.display = 'none';
|
||||
|
||||
// Array of employee names, parts, and corresponding IDs
|
||||
var employeeNameArray = <?= json_encode($employee_name_arr); ?>;
|
||||
var employeePartArray = <?= json_encode($employee_part_arr); ?>; // Array of corresponding employee parts
|
||||
var employeeIdArray = <?= json_encode($employee_id_arr); ?>; // Array of corresponding employee IDs
|
||||
|
||||
// Elements from the DOM
|
||||
var nameSelect = document.getElementById("author");
|
||||
var partInput = document.getElementById("al_part");
|
||||
var authorIdInput = document.getElementById("author_id");
|
||||
|
||||
// Function to update part and author ID based on the selected name
|
||||
function updatePartAndId() {
|
||||
var selectedIndex = nameSelect.selectedIndex;
|
||||
var selectedPart = selectedIndex >= 0 ? employeePartArray[selectedIndex] : "";
|
||||
var selectedAuthorId = selectedIndex >= 0 ? employeeIdArray[selectedIndex] : "";
|
||||
|
||||
partInput.value = selectedPart;
|
||||
authorIdInput.value = selectedAuthorId;
|
||||
}
|
||||
|
||||
// Event listener for when the name selection changes
|
||||
nameSelect.addEventListener("change", updatePartAndId);
|
||||
|
||||
// Initialize part and author ID on page load
|
||||
updatePartAndId();
|
||||
|
||||
var status = $('#status').val();
|
||||
// 처리완료인 경우는 수정하기 못하게 한다.
|
||||
|
||||
$("#closeModalBtn").click(function(){
|
||||
$('#myModal').modal('hide');
|
||||
});
|
||||
|
||||
// 신청일 변경시 종료일도 변경함
|
||||
$("#al_askdatefrom").change(function(){
|
||||
var radioVal = $('input[name="al_item"]:checked').val();
|
||||
console.log(radioVal);
|
||||
$('#al_askdateto').val($("#al_askdatefrom").val());
|
||||
|
||||
const result = getDateDiff($("#al_askdatefrom").val(), $("#al_askdateto").val());
|
||||
|
||||
switch(radioVal)
|
||||
{
|
||||
case '연차' :
|
||||
$('#al_usedday').val(result);
|
||||
break;
|
||||
case '오전반차' :
|
||||
case '오후반차' :
|
||||
$('#al_usedday').val(result/2);
|
||||
break;
|
||||
case '오전반반차' :
|
||||
case '오후반반차' :
|
||||
$('#al_usedday').val(result/4);
|
||||
break;
|
||||
case '경조사' :
|
||||
$('#al_usedday').val(0);
|
||||
break;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$('input[name="al_item"]').change(function(){
|
||||
var radioVal = $('input[name="al_item"]:checked').val();
|
||||
console.log(radioVal);
|
||||
// $('#al_askdateto').val($("#al_askdatefrom").val());
|
||||
|
||||
const result = getDateDiff($("#al_askdatefrom").val(), $("#al_askdateto").val());
|
||||
|
||||
switch(radioVal)
|
||||
{
|
||||
case '연차' :
|
||||
$('#al_usedday').val(result);
|
||||
break;
|
||||
case '오전반차' :
|
||||
case '오후반차' :
|
||||
$('#al_usedday').val(result/2);
|
||||
break;
|
||||
case '오전반반차' :
|
||||
case '오후반반차' :
|
||||
$('#al_usedday').val(result/4);
|
||||
break;
|
||||
case '경조사' :
|
||||
$('#al_usedday').val(0);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
// 종료일을 변경해도 자동계산해 주기
|
||||
$("#al_askdateto").change(function(){
|
||||
var radioVal = $('input[name="al_item"]:checked').val();
|
||||
console.log(radioVal);
|
||||
// $('#al_askdateto').val($("#al_askdatefrom").val());
|
||||
|
||||
const result = getDateDiff($("#al_askdatefrom").val(), $("#al_askdateto").val());
|
||||
|
||||
switch(radioVal)
|
||||
{
|
||||
case '연차' :
|
||||
$('#al_usedday').val(result);
|
||||
break;
|
||||
case '오전반차' :
|
||||
case '오후반차' :
|
||||
$('#al_usedday').val(result/2);
|
||||
break;
|
||||
case '오전반반차' :
|
||||
case '오후반반차' :
|
||||
$('#al_usedday').val(result/4);
|
||||
break;
|
||||
case '경조사' :
|
||||
$('#al_usedday').val(0);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
$("#closeBtn").click(function(){ // 저장하고 창닫기
|
||||
window.close(); // 현재 창 닫기
|
||||
setTimeout(function(){
|
||||
if (window.opener && !window.opener.closed) {
|
||||
window.opener.location.reload(); // 부모 창 새로고침
|
||||
}
|
||||
|
||||
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
// 휴가 등 대량으로 데이터를 생성할때 활용하는 루틴
|
||||
$("#massBtn").click(function(){
|
||||
|
||||
$("#mode").val('insert');
|
||||
|
||||
$.ajax({
|
||||
url: "mass_insert.php",
|
||||
type: "post",
|
||||
data: $("#board_form").serialize(),
|
||||
dataType:"json",
|
||||
success : function( data ){
|
||||
console.log( data);
|
||||
opener.location.reload();
|
||||
window.close();
|
||||
},
|
||||
error : function( jqxhr , status , error ){
|
||||
console.log( jqxhr , status , error );
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#saveBtn").click(function(){ // DATA 저장버튼 누름
|
||||
var num = $("#num").val();
|
||||
var part = $("#part").val();
|
||||
var status = $("#status").val();
|
||||
var user_name = $("#user_name").val();
|
||||
var admin = '<?php echo $admin ; ?>';
|
||||
|
||||
if(status=='send' || admin === '1') {
|
||||
if(Number(num)>0)
|
||||
$("#mode").val('modify');
|
||||
else
|
||||
$("#mode").val('insert');
|
||||
|
||||
// savetext div의 HTML 내용을 가져옴
|
||||
var htmlContent = document.getElementById('savetext').innerHTML;
|
||||
|
||||
$("#htmltext").val(encodeURIComponent(htmlContent));
|
||||
|
||||
$.ajax({
|
||||
url: "insert_ask.php",
|
||||
type: "post",
|
||||
data: $("#board_form").serialize(),
|
||||
dataType:"json",
|
||||
success : function( data ){
|
||||
console.log( data);
|
||||
opener.location.reload();
|
||||
window.close();
|
||||
},
|
||||
error : function( jqxhr , status , error ){
|
||||
console.log( jqxhr , status , error );
|
||||
}
|
||||
});
|
||||
} // end of if
|
||||
else
|
||||
{
|
||||
Toastify({
|
||||
text: "본인과 관리자만 수정 가능",
|
||||
duration: 2000,
|
||||
close:true,
|
||||
gravity:"top",
|
||||
position: "center",
|
||||
style: {
|
||||
background: "linear-gradient(to right, #00b09b, #96c93d)"
|
||||
},
|
||||
}).showToast();
|
||||
}
|
||||
});
|
||||
|
||||
$("#delBtn").click(function(){ // del
|
||||
var num = $("#num").val();
|
||||
var status = $("#status").val();
|
||||
var user_name = $("#user_name").val();
|
||||
|
||||
// 결재요청이 아닌경우 수정안됨
|
||||
if(status=='send' || user_name=='김보곤') {
|
||||
|
||||
// DATA 삭제버튼 클릭시
|
||||
Swal.fire({
|
||||
title: '삭제',
|
||||
text: " 삭제! '\n 정말 삭제 하시겠습니까?",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: '삭제',
|
||||
cancelButtonText: '취소' })
|
||||
.then((result) => { if (result.isConfirmed) {
|
||||
|
||||
$("#mode").val('delete');
|
||||
|
||||
if (ajaxRequest !== null) {
|
||||
ajaxRequest.abort();
|
||||
}
|
||||
|
||||
// ajax 요청 생성
|
||||
ajaxRequest = $.ajax({
|
||||
url: "insert_ask.php",
|
||||
type: "post",
|
||||
data: $("#board_form").serialize(),
|
||||
dataType:"json",
|
||||
success : function( data ){
|
||||
console.log('저장된 Num ' + $("#num").val()) ;
|
||||
Toastify({
|
||||
text: "삭제 완료!",
|
||||
duration: 3000,
|
||||
close:true,
|
||||
gravity:"top",
|
||||
position: "center",
|
||||
style: {
|
||||
background: "linear-gradient(to right, #00b09b, #96c93d)"
|
||||
},
|
||||
}).showToast();
|
||||
|
||||
console.log( data);
|
||||
opener.location.reload();
|
||||
window.close();
|
||||
|
||||
},
|
||||
error : function( jqxhr , status , error ){
|
||||
console.log( jqxhr , status , error );
|
||||
|
||||
$('#myModal').modal('show');
|
||||
}
|
||||
});
|
||||
} })
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}); // end of ready document
|
||||
|
||||
// PHP에서 전달된 휴일 목록을 JavaScript 변수로 변환
|
||||
var holidayDates = <?= json_encode($holidayDates, JSON_UNESCAPED_UNICODE) ?>;
|
||||
// 휴일 날짜를 Set으로 변환하여 빠른 검색 가능하도록 함
|
||||
var holidaySet = new Set(holidayDates);
|
||||
|
||||
// 날짜를 YYYY-MM-DD 형식으로 변환하는 함수
|
||||
function formatDate(date) {
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
return year + '-' + month + '-' + day;
|
||||
}
|
||||
|
||||
// 두날짜 사이 일자 구하기 (주말과 휴일 제외)
|
||||
const getDateDiff = (d1, d2) => {
|
||||
if (!d1 || !d2) return 0;
|
||||
|
||||
const date1 = new Date(d1);
|
||||
const date2 = new Date(d2);
|
||||
|
||||
// 날짜 유효성 검사
|
||||
if (isNaN(date1.getTime()) || isNaN(date2.getTime())) {
|
||||
console.warn('getDateDiff: 유효하지 않은 날짜', d1, d2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// holidaySet이 없으면 빈 Set 사용 (방어 코드)
|
||||
const holidays = (typeof holidaySet !== 'undefined' && holidaySet instanceof Set)
|
||||
? holidaySet
|
||||
: (typeof window.holidaySet !== 'undefined' && window.holidaySet instanceof Set)
|
||||
? window.holidaySet
|
||||
: new Set();
|
||||
|
||||
let count = 0;
|
||||
const oneDay = 24 * 60 * 60 * 1000; // 하루의 밀리세컨드 수
|
||||
|
||||
// 시작일과 종료일을 포함하여 계산하기 위해 date1의 복사본 생성
|
||||
let startDate = new Date(date1);
|
||||
let endDate = new Date(date2);
|
||||
|
||||
// 시작일이 종료일보다 큰 경우 교환
|
||||
if (startDate > endDate) {
|
||||
const temp = startDate;
|
||||
startDate = endDate;
|
||||
endDate = temp;
|
||||
}
|
||||
|
||||
// 시작일부터 종료일까지 반복 (포함)
|
||||
const currentDate = new Date(startDate);
|
||||
while (currentDate <= endDate) {
|
||||
const dayOfWeek = currentDate.getDay(); // 요일 (0:일, 1:월, ..., 6:토)
|
||||
const dateString = formatDate(currentDate); // YYYY-MM-DD 형식으로 변환
|
||||
|
||||
// 주말이 아니고 휴일도 아닌 경우에만 count 증가
|
||||
if (dayOfWeek !== 0 && dayOfWeek !== 6 && !holidays.has(dateString)) {
|
||||
count++;
|
||||
}
|
||||
|
||||
currentDate.setTime(currentDate.getTime() + oneDay); // 다음 날짜로 이동
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
var viewoption = $('#viewoption').val();
|
||||
console.log(viewoption);
|
||||
if (viewoption === '1') {
|
||||
$('input').prop('readonly', true);
|
||||
$('select').prop('disabled', true);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
391
annualleave/write_form_init.php
Normal file
391
annualleave/write_form_init.php
Normal file
@@ -0,0 +1,391 @@
|
||||
<?php include $_SERVER['DOCUMENT_ROOT'] . '/session.php'; ?>
|
||||
<?php include $_SERVER['DOCUMENT_ROOT'] . '/load_header.php' ?>
|
||||
|
||||
<style>
|
||||
.table-bordered,
|
||||
.table-bordered td,
|
||||
.table-bordered th {
|
||||
border-color: #000000 !important; /* 더 진한 테두리 색상 */
|
||||
}
|
||||
</style>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/common.php");
|
||||
$num = $_REQUEST["num"] ?? '';
|
||||
|
||||
// 새로 추가: 소속 검색값 (corpSearch)
|
||||
$corpSearch = isset($_REQUEST["corpSearch"]) ? $_REQUEST["corpSearch"] : "";
|
||||
$partSearch = isset($_REQUEST["partSearch"]) ? $_REQUEST["partSearch"] : "";
|
||||
|
||||
// corp.json 파일에서 소속 목록 불러오기
|
||||
$corpFile = $_SERVER['DOCUMENT_ROOT'] . '/member/corp.json';
|
||||
$corpData = [];
|
||||
if (file_exists($corpFile)) {
|
||||
$corpJson = file_get_contents($corpFile);
|
||||
$corpData = json_decode($corpJson, true);
|
||||
if (!is_array($corpData)) { $corpData = []; }
|
||||
}
|
||||
|
||||
// part.json 파일에서 부서 목록 불러오기
|
||||
$partFile = $_SERVER['DOCUMENT_ROOT'] . '/member/part.json';
|
||||
$partData = [];
|
||||
if (file_exists($partFile)) {
|
||||
$partJson = file_get_contents($partFile);
|
||||
$partData = json_decode($partJson, true);
|
||||
if (!is_array($partData)) {
|
||||
$partData = [];
|
||||
}
|
||||
}
|
||||
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
|
||||
// almember의 기본정보 배열을 불러옴 (예, $basic_name_arr, $basic_part_arr 등)
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/almember/load_DB.php");
|
||||
|
||||
$currentYear = date("Y"); // 현재 년도 가져오기
|
||||
|
||||
// echo '<pre>';
|
||||
// print_r($dateofentry_arr);
|
||||
// echo '</pre>';
|
||||
|
||||
?>
|
||||
<form id="board_form" name="board_form" class="form-signin" method="post" >
|
||||
<div class="container-fluid" style="width:380px;">
|
||||
<div class="row d-flex justify-al_content-center align-items-center h-50">
|
||||
<div class="col-12 text-center">
|
||||
<div class="card align-middle" style="border-radius:20px;">
|
||||
<div class="card" style="padding:10px;margin:10px;">
|
||||
<h3 class="card-title text-center" style="color:#113366;"> 년초 (연차) 대량등록 </h3>
|
||||
</div>
|
||||
<div class="card-body text-center">
|
||||
<input type="hidden" id="mode" name="mode">
|
||||
<input type="hidden" id="num" name="num" value="<?=$num?>" >
|
||||
<input type="hidden" id="registdate" name="registdate" value="<?=$registdate?>" >
|
||||
<input type="hidden" id="user_name" name="user_name" value="<?=$user_name?>" >
|
||||
<input type="hidden" id="author_id" name="author_id" value="<?=$author_id?>" >
|
||||
<input type="hidden" id="htmltext" name="htmltext" >
|
||||
<div id="savetext">
|
||||
<div class="d-flex justify-content-center align-items-center mb-3">
|
||||
<!-- 해당년도 및 현재년도 input 추가 -->
|
||||
<div class="mt-1">
|
||||
<label for="current-year" class="form-label">해당년도</label>
|
||||
<input type="text" id="current-year" name="current_year" class="form-control fs-6 text-center" value="<?= $currentYear ?>" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex justify-content-center align-items-center mb-3">
|
||||
<!-- 소속 검색 select 추가 -->
|
||||
<div class="inputWrap30 mx-1">
|
||||
<select name="corpSearch" id="corpSearch" class="form-select w100px mx-1" style="font-size: 0.9rem; height: 32px;">
|
||||
<option value=""><?= "(소속)" ?></option>
|
||||
<?php foreach($corpData as $corp): ?>
|
||||
<option value="<?= htmlspecialchars($corp, ENT_QUOTES, 'UTF-8') ?>" <?= ($corpSearch === $corp) ? 'selected' : '' ?>>
|
||||
<?= htmlspecialchars($corp, ENT_QUOTES, 'UTF-8') ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<!-- 부서 검색 select 추가 -->
|
||||
<div class="inputWrap30 mx-1">
|
||||
<select name="partSearch" id="partSearch" class="form-select w120px mx-1" style="font-size: 0.9rem; height: 32px;">
|
||||
<option value=""><?= "(부서)" ?></option>
|
||||
<!-- 옵션은 JS에서 동적으로 채워짐 -->
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-center align-items-center mb-3">
|
||||
<input type="checkbox" id="select-all" class="d-flex align-items-center me-2 mb-2" >
|
||||
<label for="select-all" class="d-flex align-items-center me-2 mb-2" >
|
||||
전체 선택
|
||||
</label>
|
||||
</div>
|
||||
<div class="d-flex justify-content-center align-items-center mb-3">
|
||||
<div id="author-list" class="d-flex flex-wrap mt-2">
|
||||
<?php
|
||||
for ($i = 0; $i < count($employee_name_arr); $i++) {
|
||||
// $author 변수가 미리 설정되어 있다면 해당 직원과 비교하여 checked 처리 (없다면 생략)
|
||||
$checked = (isset($author) && $author == $employee_name_arr[$i]) ? "checked" : "";
|
||||
$dateofentry = $employee_dateofentry_arr[$i] ?? '';
|
||||
$company = $employee_company_arr[$i] ?? '';
|
||||
$part = $employee_part_arr[$i] ?? '';
|
||||
|
||||
// $fiscalYearEnd = ($referencedate - 1) . "-12-31";
|
||||
// 현재 연도를 가져온 후, 이전 연도의 마지막 날을 생성
|
||||
$fiscalYearEnd = (date('Y') - 1) . "-12-31";
|
||||
// echo '참고년도 : ' . $referencedate ;
|
||||
// echo '전년도 : ' . $fiscalYearEnd ;
|
||||
$result = calculateAnnualLeave($dateofentry, $fiscalYearEnd);
|
||||
$continueYear = $result['G'];
|
||||
$initial_less_than_one_year = $result['H'];
|
||||
$service_based = $result['I'];
|
||||
$availableday = $result['J'];
|
||||
|
||||
echo "<div class='d-flex align-items-start text-start mb-1' style='width: 33.33%;'>";
|
||||
echo " <label class='w-100'>";
|
||||
echo " <input type='checkbox' class='author-checkbox ms-3' name='author[]' value='" . htmlspecialchars($employee_name_arr[$i], ENT_QUOTES, 'UTF-8') . "' ";
|
||||
echo " data-author-id='" . htmlspecialchars($employee_id_arr[$i], ENT_QUOTES, 'UTF-8') . "' ";
|
||||
echo " data-company='" . htmlspecialchars($company, ENT_QUOTES, 'UTF-8') . "' ";
|
||||
echo " data-availableday='" . htmlspecialchars($availableday, ENT_QUOTES, 'UTF-8') . "' ";
|
||||
echo " data-initial_less_than_one_year='" . htmlspecialchars($initial_less_than_one_year, ENT_QUOTES, 'UTF-8') . "' ";
|
||||
echo " data-service_based='" . htmlspecialchars($service_based, ENT_QUOTES, 'UTF-8') . "' ";
|
||||
echo " data-part='" . htmlspecialchars($part, ENT_QUOTES, 'UTF-8') . "' ";
|
||||
echo " data-dateofentry='" . htmlspecialchars($dateofentry, ENT_QUOTES, 'UTF-8') . "' $checked>";
|
||||
echo " <span class='ms-2'>" . htmlspecialchars($employee_name_arr[$i], ENT_QUOTES, 'UTF-8') . "</span>";
|
||||
echo " </label>";
|
||||
echo "</div>";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
// "전체 선택" 체크박스 동작
|
||||
$('#select-all').on('change', function () {
|
||||
var isChecked = $(this).is(':checked');
|
||||
$('.author-checkbox').prop('checked', isChecked);
|
||||
});
|
||||
|
||||
// 개별 체크박스 동작 시 "전체 선택" 체크박스 상태 업데이트
|
||||
$('.author-checkbox').on('change', function () {
|
||||
var allChecked = $('.author-checkbox:checked').length === $('.author-checkbox').length;
|
||||
$('#select-all').prop('checked', allChecked);
|
||||
});
|
||||
</script>
|
||||
<div class="d-flex justify-content-center align-items-center mb-3">
|
||||
<button id="saveBtn" class="btn btn-sm btn-dark mx-1" type="button"> <i class="bi bi-floppy-fill"></i> (주의) 대량등록 실행 </button>
|
||||
<button class="btn btn-dark btn-sm ms-3" id="closeBtn" > × 닫기 </button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<script>
|
||||
var ajaxRequest = null;
|
||||
|
||||
$(document).ready(function(){
|
||||
var loader = document.getElementById('loadingOverlay');
|
||||
if(loader)
|
||||
loader.style.display = 'none';
|
||||
});
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
var status = $('#status').val();
|
||||
// 처리완료인 경우는 수정하기 못하게 한다.
|
||||
|
||||
$("#closeBtn").click(function(){ // 저장하고 창닫기
|
||||
window.close(); // 현재 창 닫기
|
||||
setTimeout(function(){
|
||||
if (window.opener && !window.opener.closed) {
|
||||
window.opener.location.reload(); // 부모 창 새로고침
|
||||
}
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
$("#saveBtn").click(function () {
|
||||
var authorList = [];
|
||||
var basicNameArr = <?= json_encode($employee_name_arr); ?>;
|
||||
|
||||
// 선택된 직원 정보를 배열에 추가
|
||||
$(".author-checkbox:checked").each(function () {
|
||||
var authorName = $(this).val();
|
||||
|
||||
// 기준연도: 해당연도 입력값이 있으면 해당연도 12월 31일, 없으면 오늘 날짜를 기준으로 함
|
||||
var now = new Date();
|
||||
refDateStr = now.getFullYear() + "-" + ("0" + (now.getMonth()+1)).slice(-2) + "-" + ("0" + now.getDate()).slice(-2);
|
||||
|
||||
// 연차일수 계산 후 업데이트
|
||||
console.log('성명 : ',authorName);
|
||||
|
||||
authorList.push({
|
||||
name: authorName,
|
||||
company: $(this).data("company"),
|
||||
part: $(this).data("part"),
|
||||
author_id: $(this).data("author-id"),
|
||||
availableday: $(this).data("availableday") , // 총 연차일수
|
||||
initial_less_than_one_year: $(this).data("initial_less_than_one_year") , // 1,2년 미만 연차 계산
|
||||
service_based: $(this).data("service_based") , // 기본연차
|
||||
dateofentry: $(this).data("dateofentry")
|
||||
});
|
||||
});
|
||||
|
||||
if (authorList.length === 0) {
|
||||
alert("직원을 선택하세요.");
|
||||
return;
|
||||
}
|
||||
|
||||
// 추가 데이터를 hidden 필드로 가져오기
|
||||
var registdate = $("#registdate").val();
|
||||
var currentYear = $("#current-year").val();
|
||||
var alUsedDay = '';
|
||||
|
||||
// 요청 데이터 생성
|
||||
var requestData = {
|
||||
author_list: JSON.stringify(authorList),
|
||||
current_year: currentYear
|
||||
};
|
||||
|
||||
console.log("Request Data:", requestData);
|
||||
|
||||
$.ajax({
|
||||
url: "insert_init.php",
|
||||
type: "POST",
|
||||
data: requestData,
|
||||
dataType: "json",
|
||||
success: function (response) {
|
||||
console.log(response);
|
||||
|
||||
if (response.status === "success") {
|
||||
Swal.fire({
|
||||
icon: "success",
|
||||
title: "등록 완료",
|
||||
text: "대량 등록이 성공적으로 완료되었습니다.",
|
||||
confirmButtonText: "확인"
|
||||
}).then(() => {
|
||||
// window.opener.location.reload(); // 부모 창 새로고침
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "오류 발생",
|
||||
text: response.message,
|
||||
confirmButtonText: "확인"
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
console.error("AJAX 에러:", textStatus, errorThrown);
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "저장 실패",
|
||||
text: "저장 중 오류가 발생했습니다. 다시 시도해주세요.",
|
||||
confirmButtonText: "확인"
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
}); // end of ready document
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
// PHP의 부서 JSON 데이터를 JS 변수로 저장 (각 항목은 ['corp'=> ..., 'part'=> ...] 형식)
|
||||
var partData = <?= json_encode($partData) ?>;
|
||||
|
||||
// PHP에서 전달된 부서 검색 값 (기존에 선택된 값)
|
||||
var initialPart = "<?= htmlspecialchars($partSearch, ENT_QUOTES, 'UTF-8') ?>";
|
||||
|
||||
// 부서 select 업데이트 함수
|
||||
function updatePartSelect(selectedCorp) {
|
||||
var $partSelect = $('#partSearch');
|
||||
$partSelect.empty();
|
||||
$partSelect.append('<option value=""><?= "(부서)" ?></option>');
|
||||
// 선택된 소속과 일치하는 부서 옵션만 추가
|
||||
$.each(partData, function(index, dept) {
|
||||
if(dept.corp === selectedCorp) {
|
||||
$partSelect.append('<option value="'+ dept.part +'">'+ dept.part +'</option>');
|
||||
}
|
||||
});
|
||||
// 만약 초기 부서값이 있다면 선택
|
||||
if(initialPart !== "") {
|
||||
$partSelect.val(initialPart);
|
||||
}
|
||||
renderEmployeeList() ;
|
||||
}
|
||||
|
||||
// 페이지 로드 시, 이미 소속이 선택되어 있다면 부서 옵션 업데이트
|
||||
var initialCorp = $('#corpSearch').val();
|
||||
updatePartSelect(initialCorp);
|
||||
|
||||
// 소속 select 변경 시 부서 select 업데이트
|
||||
$('#corpSearch').on('change', function(){
|
||||
var selectedCorp = $(this).val();
|
||||
updatePartSelect(selectedCorp);
|
||||
renderEmployeeList() ;
|
||||
});
|
||||
|
||||
// 페이지 로드 시 초기 직원 목록 렌더링
|
||||
renderEmployeeList();
|
||||
|
||||
// 부서 select 변경 시 직원 목록 재렌더링
|
||||
$('#partSearch').on('change', function(){
|
||||
renderEmployeeList();
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- PHP 배열들을 JS 객체 배열로 생성 (각 직원의 정보) -->
|
||||
<script>
|
||||
var employeeData = <?= json_encode(array_map(function($name, $id, $company, $part, $dateofentry) {
|
||||
return [
|
||||
'name' => $name,
|
||||
'id' => $id,
|
||||
'company' => $company,
|
||||
'part' => $part,
|
||||
'dateofentry' => $dateofentry
|
||||
];
|
||||
}, $employee_name_arr, $employee_id_arr, $employee_company_arr, $employee_part_arr, $employee_dateofentry_arr)) ?>;
|
||||
|
||||
// 동적으로 직원 목록을 생성하는 함수 (개선된 버전)
|
||||
function renderEmployeeList() {
|
||||
var selectedCorp = $('#corpSearch').val();
|
||||
var selectedPart = $('#partSearch').val();
|
||||
var $authorList = $('#author-list');
|
||||
$authorList.empty();
|
||||
|
||||
// 먼저 필터링된 직원 데이터를 배열에 저장
|
||||
var filteredEmployees = [];
|
||||
$.each(employeeData, function(index, emp) {
|
||||
// 소속 필터: 소속이 선택되어 있고 일치하지 않으면 건너뜀
|
||||
if (selectedCorp && emp.company !== selectedCorp) {
|
||||
return; // continue each
|
||||
}
|
||||
// 부서 필터: 부서가 선택되어 있고 일치하지 않으면 건너뜀
|
||||
if (selectedPart && emp.part !== selectedPart) {
|
||||
return;
|
||||
}
|
||||
filteredEmployees.push(emp);
|
||||
});
|
||||
|
||||
// 필터링된 직원 수에 따라 각 항목의 너비 결정 (3개 이상이면 33%, 2개 이하이면 각각 50% 혹은 100%)
|
||||
var itemWidth = "33.33%";
|
||||
if (filteredEmployees.length <= 3) {
|
||||
itemWidth = (100 / (filteredEmployees.length || 1)) + "%";
|
||||
}
|
||||
|
||||
// 필터링된 직원 배열을 순회하며 체크박스와 이름을 생성
|
||||
$.each(filteredEmployees, function(index, emp) {
|
||||
// 기본 체크 상태 (필요에 따라 수정)
|
||||
var checked = "";
|
||||
var employeeHTML = "<div class='d-flex align-items-center text-start mb-1' style='width:" + itemWidth + ";' data-company='" +
|
||||
emp.company + "' data-part='" + emp.part + "'>";
|
||||
employeeHTML += " <input type='checkbox' class='author-checkbox mx-1' name='author[]' value='" +
|
||||
emp.name + "' ";
|
||||
employeeHTML += " data-author-id='" + emp.id + "' ";
|
||||
employeeHTML += " data-company='" + emp.company + "' ";
|
||||
employeeHTML += " data-part='" + emp.part + "' ";
|
||||
employeeHTML += " data-dateofentry='" + emp.dateofentry + "' " + checked + ">";
|
||||
employeeHTML += " <span class='mx-1'>" + emp.name + "</span>";
|
||||
employeeHTML += "</div>";
|
||||
$authorList.append(employeeHTML);
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user