'; // print_r($employee_json); // echo ''; if (intval($level) == 1 ) $admin = 1; else $admin = 2; $tablename = "eworks"; // 변수 초기화 $mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : ''; $search = isset($_REQUEST['search']) ? $_REQUEST['search'] : ''; // 새로 추가: 소속 검색값 (corpSearch) $corpSearch = isset($_REQUEST["corpSearch"]) ? $_REQUEST["corpSearch"] : $mycompany ; $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 = []; } } // 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(intval($level) !== 1) { $AndisDeleted = " AND is_deleted IS NULL AND eworks_item='연차' "; $WhereisDeleted = " where is_deleted IS NULL AND eworks_item='연차' "; if ($search == "") { if ($admin == 1) { $sql = "SELECT * FROM " . $DB . "." . $tablename . $WhereisDeleted . " ORDER BY al_askdatefrom DESC, registdate DESC"; } else { $sql = "SELECT * FROM " . $DB . "." . $tablename . " WHERE author LIKE '%$user_name%' " . $AndisDeleted . " ORDER BY al_askdatefrom DESC, registdate DESC"; } } else { if ($admin == 1) { $sql = "SELECT * FROM " . $DB . "." . $tablename . " WHERE (author LIKE '%$search%') " . $AndisDeleted . " ORDER BY al_askdatefrom DESC, registdate DESC"; } else { $sql = "SELECT * FROM " . $DB . "." . $tablename . " WHERE (author = '$user_name') AND (author LIKE '%$search%') " . $AndisDeleted . " ORDER BY al_askdatefrom DESC, registdate DESC"; } } $stmt = $pdo->prepare($sql); } else // 관리자인 경우 { // 기본 SQL 쿼리 (검색조건 미포함) $sql = "SELECT * FROM {$DB}.{$tablename} ORDER BY num DESC"; // print '관리자'; // 검색 조건 구성: 검색어와 소속 및 부서 검색 조건을 모두 고려 $conditions = [" eworks_item='연차' ", " is_deleted IS NULL "]; $bindParams = []; if ($mode == "search" or !empty($corpSearch) ) { if (!empty($search)) { // member 테이블의 모든 컬럼에 대해 LIKE 검색 (예제) $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)) { // 소속(division) 검색 조건 추가 $conditions[] = "al_company LIKE :corpSearch"; $bindParams[":corpSearch"] = "%$corpSearch%"; } if (!empty($partSearch)) { // 부서(part) 검색 조건 추가 $conditions[] = "al_part LIKE :partSearch"; $bindParams[":partSearch"] = "%$partSearch%"; } if (!empty($conditions)) { $sql = "SELECT * FROM {$DB}.{$tablename} WHERE " . implode(" AND ", $conditions) . " ORDER BY num DESC"; } } $stmt = $pdo->prepare($sql); if (!empty($bindParams)) { foreach ($bindParams as $paramName => $paramValue) { $stmt->bindValue($paramName, $paramValue, PDO::PARAM_STR); } } } // print $sql ; // echo '
';
// print_r($conditions);
// echo '
'; // 여기서 execute() $stmt->execute(); // 실행 후 결과를 fetchAll()하거나 rowCount() 확인 $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); $total_row = count($rows); // print $total_row ; // print $eworks_level; ?>
    
년도  
발생일 전년도 선사용 사용일 잔여일
결재완료 후 삭제 불가
   
번호 접수일 회사 부서 성명 시작일 종료일 사용일수 사유 결재권자 결재상태