prepare("CALL proc_get_legal_total_report(?, '', ?)"); $stmt_total->execute([$search_comp, $search_year]); $total_data = $stmt_total->fetch(PDO::FETCH_ASSOC); while ($stmt_total->nextRowset()) {} unset($stmt_total); // 만약 전체조회 등 데이터가 없을 경우 기본값 세팅 if (!$total_data) { $total_data = [ 'title01' => $search_year . '년 법정의무교육', 'title02' => '교육결과보고서', 'edu_purpose' => '', 'corp_name' => '', 'edu_term' => '', 'edu_category' => '', 'all_user_qty' => 0, 'all_completed_qty' => 0, 'rmks' => '' ]; } // 2) proc_get_legal_report_by_year_category_sum 호출 $stmt_sum = $pdo->prepare("CALL proc_get_legal_report_by_year_category_sum(?, '', ?)"); $stmt_sum->execute([$search_comp, $search_year]); $sum_rows = $stmt_sum->fetchAll(PDO::FETCH_ASSOC); while ($stmt_sum->nextRowset()) {} unset($stmt_sum); // 3) proc_get_legal_report 호출 (과정별 시트 데이터) $stmt_detail = $pdo->prepare("CALL proc_get_legal_report(?, '', ?)"); $stmt_detail->execute([$search_comp, $search_year]); $detail_rows = $stmt_detail->fetchAll(PDO::FETCH_ASSOC); while ($stmt_detail->nextRowset()) {} unset($stmt_detail); } catch (Exception $e) { die("DB Error: " . $e->getMessage()); } // HTTP Header 설정 - Excel 파일 다운로드 유도 $safe_corp_name = preg_replace('/[\/\\:*?"<>|]/', '', $total_data['corp_name'] ?? ''); $safe_corp_name = trim($safe_corp_name); if (empty($safe_corp_name)) { $safe_corp_name = '법정의무교육'; } $download_filename = $safe_corp_name . "_교육결과보고서_" . date('Ymd') . ".xls"; header("Content-Type: application/vnd.ms-excel; charset=utf-8"); header("Content-Disposition: attachment; filename=\"" . $download_filename . "\"; filename*=UTF-8''" . rawurlencode($download_filename)); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Pragma: public"); // XML Spreadsheet 2003 양식 작성 시작 echo '' . "\n"; echo '' . "\n"; ?> Baron Consultant Baron Consultant 16.00 9000 13600 0 0 False False 1. 교육목적 2. 교육 운영 개요 사업장명 교육일시 교육구분 참석인원 대상인원 실시인원 미실시인원 비고 3. 과정별 교육 이수 현황 과정별 교육인원 수료인원 수료율 데이터가 없습니다. % 서울시 송파구 오금로 554 한맥B/D TEL | 02-1234-5600 FAX | 02-1234-5600