query($car_sql); $car_list = $car_stmh->fetchAll(PDO::FETCH_ASSOC); $title_message = ($mode === 'modify') ? '차량운행일지 수정' : (($mode === 'copy') ? '차량운행일지 복사' : '차량운행일지 신규 등록'); if ($mode === 'modify' && $num) { try { $sql = "SELECT * FROM ". $DB . "." . $tablename . " WHERE num=?"; $stmh = $pdo->prepare($sql); $stmh->bindValue(1, $num, PDO::PARAM_INT); $stmh->execute(); $row = $stmh->fetch(PDO::FETCH_ASSOC); include '_row.php'; } catch (PDOException $Exception) { echo "오류: ".$Exception->getMessage(); exit; } } // 출발지↔도착지 변경 복사 else if ($mode === 'copyDestination' && $num) { try { $sql = "SELECT * FROM ". $DB . "." . $tablename . " WHERE num=?"; $stmh = $pdo->prepare($sql); $stmh->bindValue(1, $num, PDO::PARAM_INT); $stmh->execute(); $row = $stmh->fetch(PDO::FETCH_ASSOC); include '_row.php'; $mode = 'copyDestination'; $num = null; // 출발지 도착지 변경해줌 // 출발지와 도착지 값을 서로 바꾸기 위해 임시 변수 사용 $temp = $row['departure']; $departure = $row['destination']; $destination = $temp; // 출근/퇴근 서로 바꾸기 if($usage_purpose == '출근') { $usage_purpose = '퇴근'; } else if($usage_purpose == '퇴근') { $usage_purpose = '출근'; } } catch (PDOException $Exception) { echo "오류: ".$Exception->getMessage(); exit; } } else if ($mode === 'copy' && $num) { try { $sql = "SELECT * FROM ". $DB . "." . $tablename . " WHERE num=?"; $stmh = $pdo->prepare($sql); $stmh->bindValue(1, $num, PDO::PARAM_INT); $stmh->execute(); $row = $stmh->fetch(PDO::FETCH_ASSOC); include '_row.php'; $mode = 'copy'; $num = null; } catch (PDOException $Exception) { echo "오류: ".$Exception->getMessage(); exit; } } else { include '_request.php'; $mode = 'insert'; $use_date = date('Y-m-d'); // 🔹 신규 작성 시 현재 사용자 정보 불러오기 $user_name = $_SESSION["name"] ?? ''; // print $user_name; if (!empty($user_name)) { $member_sql = "SELECT part, position, name FROM " . $DB . ".member WHERE name = ?"; $member_stmh = $pdo->prepare($member_sql); $member_stmh->bindValue(1, $user_name, PDO::PARAM_STR); $member_stmh->execute(); $member_info = $member_stmh->fetch(PDO::FETCH_ASSOC); if ($member_info) { $department = $member_info['part'] ?? ''; $position = $member_info['position'] ?? ''; $caruser_name = $member_info['name'] ?? ''; } } // 차량관리에 정보가 있으면 불러오기 if (!empty($user_name)) { $juilcar_sql = "SELECT vehicle_number FROM " . $DB . ".juilcar WHERE responsible_person = ?"; $juilcar_stmh = $pdo->prepare($juilcar_sql); $juilcar_stmh->bindValue(1, $user_name, PDO::PARAM_STR); $juilcar_stmh->execute(); $juilcar_info = $juilcar_stmh->fetch(PDO::FETCH_ASSOC); if ($juilcar_info) { $car_number = $juilcar_info['vehicle_number'] ?? ''; } } } ?>
#
사용일자 차량번호
부서 직책
사용자 사용목적
출발지 도착지
운행내역
주행거리 (km) 월간 누적거리(km)
비고