티스토리 뷰

<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>후원신청하기 완벽 연동본 (서명 포함)</title>

<script src="https://cdn.jsdelivr.net/npm/signature_pad@4.0.0/dist/signature_pad.umd.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js"></script>

<style>
    /* 1. 전체 래퍼 */
    .dm-form-wrap {
        max-width: 800px;
        margin: 0 auto;
        padding: 40px 20px;
        font-family: 'Noto Sans KR', sans-serif;
        color: #333;
    }

    /* 2. 타이틀 영역 */
    .dm-form-title {
        font-size: 26px;
        font-weight: 700;
        margin-bottom: 15px;
        padding-bottom: 15px;
        border-bottom: 2px solid #333;
        color: #111;
    }

    .dm-sub-title {
        font-size: 19px;
        font-weight: 700;
        margin-top: 50px;
        margin-bottom: 15px;
        color: #007aff;
        position: relative;
        padding-left: 12px;
    }

    .dm-sub-title::before {
        content: '';
        display: block;
        width: 4px;
        height: 18px;
        background: #007aff;
        position: absolute;
        left: 0;
        top: 5px;
    }

    /* 3. 입력 테이블 스타일 */
    .dm-form-table {
        width: 100%;
        border-top: 2px solid #333;
        border-collapse: collapse;
    }

    .dm-form-table th, .dm-form-table td {
        padding: 15px;
        border-bottom: 1px solid #ddd;
        font-size: 15px;
        vertical-align: middle;
        line-height: 1.5;
    }

    .dm-form-table th {
        background: #f7f9fb;
        width: 180px;
        font-weight: 700;
        text-align: left;
        color: #333;
        word-break: keep-all;
    }

    /* 입력창 공통 스타일 */
    .dm-input, .dm-select {
        width: 100%;
        padding: 10px;
        border: 1px solid #ccc;
        border-radius: 4px;
        box-sizing: border-box;
        font-size: 15px;
        position: relative;
        z-index: 10;
    }

    .dm-input:focus, .dm-select:focus {
        border-color: #007aff;
        outline: none;
    }

    /* 라디오/체크박스 클릭 오류 해결 (철벽 방어) */
    .dm-radio-group .dm-radio-item {
        display: inline-block;
        margin-right: 20px;
        margin-bottom: 8px;
    }
    
    .dm-radio-group .dm-radio-item-block {
        display: block;
        margin-bottom: 10px;
    }

    .dm-radio-group input[type="radio"], 
    .dm-radio-group input[type="checkbox"] { 
        margin-right: 6px; 
        width: 18px;
        height: 18px;
        vertical-align: middle;
        cursor: pointer;
        position: relative;
        z-index: 10; 
    }

    .dm-radio-group label {
        cursor: pointer;
        vertical-align: middle;
        word-break: keep-all;
        position: relative;
        z-index: 10;
    }

    /* 부가 설명 텍스트 */
    .dm-help-text {
        display: block;
        font-size: 13px;
        color: #666;
        margin-top: 5px;
    }

    /* 4. 약관 동의 그룹 */
    .dm-term-group { margin-bottom: 25px; }
    .dm-term-title { font-weight: 700; margin-bottom: 8px; font-size: 15px; color: #222; }
    .dm-term-box {
        border: 1px solid #ddd;
        background: #f9f9f9;
        padding: 15px;
        font-size: 14px;
        color: #555;
        line-height: 1.6;
        border-radius: 4px;
        margin-bottom: 10px;
    }
    .dm-agree-check { text-align: left; font-size: 15px; font-weight: 700; }

    /* 5. 스마트폰 서명란 전용 스타일 */
    .dm-signature-wrap {
        border: 2px dashed #007aff;
        border-radius: 8px;
        background: #fdfdfd;
        position: relative;
        margin-top: 15px;
    }
    .dm-signature-pad {
        width: 100%;
        height: 200px;
        touch-action: none;
    }
    .dm-sig-clear-btn {
        position: absolute;
        top: 10px;
        right: 10px;
        background: #fff;
        border: 1px solid #ccc;
        padding: 5px 10px;
        font-size: 12px;
        border-radius: 4px;
        cursor: pointer;
    }

    /* 6. 버튼 영역 */
    .dm-btn-wrap { margin-top: 50px; text-align: center; }
    .dm-btn {
        display: inline-block;
        min-width: 160px;
        padding: 15px 30px;
        font-size: 18px;
        font-weight: 700;
        text-align: center;
        border: none;
        cursor: pointer;
        border-radius: 5px;
    }
    .dm-btn-submit { background: #007aff; color: #fff; }
    .dm-btn-cancel { background: #666; color: #fff; margin-left: 10px; }

    /* 모바일 반응형 처리 */
    @media screen and (max-width: 768px) {
        .dm-form-table th, .dm-form-table td { display: block; width: 100%; border-bottom: none; padding: 10px 15px; }
        .dm-form-table th { background: none; padding-bottom: 0; padding-top: 20px; font-size: 15px; color: #007aff; }
        .dm-form-table td { border-bottom: 1px solid #eee; padding-bottom: 20px; }
        .dm-radio-group .dm-radio-item { display: block; margin-bottom: 10px; }
        .dm-btn { width: 100%; margin-left: 0; margin-bottom: 10px; }
    }
</style>
</head>
<body>

<div class="dm-form-wrap" id="pdf-content-area">
    
    <div class="dm-form-title">후원신청서</div>
    <p style="margin-bottom: 30px; color: #555; line-height: 1.6;">
        아이들의 꿈을 응원해주셔서 감사합니다.<br>
        <span style="color:red">*</span> 표시는 필수 질문입니다.
    </p>

    <input type="hidden" id="agency_email" name="agency_email" value="dongmyeong@example.com">

    <form id="sponsorship_form" action="#" method="post">
        
        <div class="dm-sub-title">1. 후원 방식 및 종류</div>
        <table class="dm-form-table">
            <tr>
                <th>후원 방식 <span style="color:red">*</span></th>
                <td class="dm-radio-group">
                    <div class="dm-radio-item">
                        <input type="radio" id="st_1" name="support_type" checked>
                        <label for="st_1">정기후원</label>
                    </div>
                    <div class="dm-radio-item">
                        <input type="radio" id="st_2" name="support_type">
                        <label for="st_2">일시후원</label>
                    </div>
                </td>
            </tr>
            <tr>
                <th>후원 종류 <span style="color:red">*</span></th>
                <td class="dm-radio-group">
                    <div class="dm-radio-item-block">
                        <input type="radio" id="sc_1" name="support_category" value="아동숙사(1인실) 리모델링 후원" checked>
                        <label for="sc_1">아동숙사(1인실) 리모델링 후원</label>
                    </div>
                    <div class="dm-radio-item-block">
                        <input type="radio" id="sc_2" name="support_category" value="아동 결연 후원 (아동에게만 후원)">
                        <label for="sc_2">아동 결연 후원 (아동에게만 후원)</label>
                    </div>
                    <div class="dm-radio-item-block">
                        <input type="radio" id="sc_3" name="support_category" value="지정 후원 (후원자 의도에 맞게)">
                        <label for="sc_3">지정 후원 (후원자 의도에 맞게)</label>
                    </div>
                    <div class="dm-radio-item-block">
                        <input type="radio" id="sc_4" name="support_category" value="비지정 후원 (기관 용도에 맞게)">
                        <label for="sc_4">비지정 후원 (기관 용도에 맞게)</label>
                    </div>
                </td>
            </tr>
            <tr>
                <th>후원 금액 <span style="color:red">*</span></th>
                <td class="dm-radio-group">
                    <div class="dm-radio-item-block">
                        <input type="radio" id="sa_1" name="support_amount">
                        <label for="sa_1">100,000원</label>
                    </div>
                    <div class="dm-radio-item-block">
                        <input type="radio" id="sa_2" name="support_amount">
                        <label for="sa_2">50,000원</label>
                    </div>
                    <div class="dm-radio-item-block">
                        <input type="radio" id="sa_3" name="support_amount" checked>
                        <label for="sa_3">30,000원</label>
                    </div>
                    <div class="dm-radio-item-block">
                        <input type="radio" id="sa_4" name="support_amount">
                        <label for="sa_4">20,000원</label>
                    </div>
                    <div class="dm-radio-item-block">
                        <input type="radio" id="sa_5" name="support_amount">
                        <label for="sa_5">기타:</label>
                        <input type="text" class="dm-input" style="width: 150px; margin-left: 8px; display: inline-block;"> 원
                    </div>
                </td>
            </tr>
        </table>

        <div class="dm-sub-title">2. 후원회원정보</div>
        <table class="dm-form-table">
            <tr>
                <th>회원구분 <span style="color:red">*</span></th>
                <td class="dm-radio-group">
                    <div class="dm-radio-item">
                        <input type="radio" id="mt_1" name="member_type" checked>
                        <label for="mt_1">개인</label>
                    </div>
                    <div class="dm-radio-item">
                        <input type="radio" id="mt_2" name="member_type">
                        <label for="mt_2">단체</label>
                    </div>
                </td>
            </tr>
            <tr>
                <th>후원회원명(단체명) <span style="color:red">*</span></th>
                <td><input type="text" name="member_name" class="dm-input" placeholder="이름을 입력하세요" required></td>
            </tr>
            <tr>
                <th>기부금영수증<br>발급여부 <span style="color:red">*</span></th>
                <td class="dm-radio-group">
                    <div class="dm-radio-item-block">
                        <input type="radio" id="rr_1" name="receipt_req">
                        <label for="rr_1">발급신청 (하단 질문에 주민등록번호를 입력해주세요)</label>
                    </div>
                    <div class="dm-radio-item-block">
                        <input type="radio" id="rr_2" name="receipt_req" checked>
                        <label for="rr_2">신청안함</label>
                    </div>
                </td>
            </tr>
            <tr>
                <th>주민등록번호 입력 <span style="color:red">*</span></th>
                <td>
                    <input type="text" class="dm-input" placeholder="예) 800101-1234567">
                    <span class="dm-help-text">국세청 연말정산간소화서비스를 통해 기부금영수증을 발급받으시려면 주민등록번호를 입력해주세요.</span>
                </td>
            </tr>
            <tr>
                <th>연락처 (휴대전화) <span style="color:red">*</span></th>
                <td><input type="text" name="phone" class="dm-input" placeholder="예) 010-0000-0000" required></td>
            </tr>
            <tr>
                <th>이메일 <span style="color:red">*</span></th>
                <td><input type="email" name="email" class="dm-input" placeholder="example@email.com"></td>
            </tr>
            <tr>
                <th>주소 <span style="color:red">*</span></th>
                <td>
                    <input type="text" class="dm-input" placeholder="우편물 수령 주소를 입력해주세요">
                    <span class="dm-help-text">(기부금 영수증 발송 등에 활용)</span>
                </td>
            </tr>
        </table>

        <div class="dm-sub-title">3. 출금 정보</div>
        <table class="dm-form-table">
            <tr>
                <th>예금주명 <span style="color:red">*</span></th>
                <td><input type="text" class="dm-input" placeholder="예금주 성함"></td>
            </tr>
            <tr>
                <th>예금주 생년월일 <span style="color:red">*</span></th>
                <td>
                    <input type="text" class="dm-input" placeholder="예금주 생년월일 6자리">
                    <span class="dm-help-text">(주민번호 앞 6자리)</span>
                </td>
            </tr>
            <tr>
                <th>은행 <span style="color:red">*</span></th>
                <td>
                    <select class="dm-select" name="bank_name" style="max-width: 300px;">
                        <option>은행을 선택해주세요</option>
                        <option>SC제일은행</option>
                        <option>국민은행</option>
                        <option>우리은행</option>
                        <option>하나은행</option>
                        <option>농협</option>
                        <option>기타은행</option>
                    </select>
                </td>
            </tr>
            <tr>
                <th>계좌번호 <span style="color:red">*</span></th>
                <td>
                    <input type="text" class="dm-input" name="account_num" required>
                </td>
            </tr>
            <tr>
                <th>자동이체 출금일 <span style="color:red">*</span></th>
                <td class="dm-radio-group">
                    <div class="dm-radio-item">
                        <input type="radio" id="pd_1" name="pay_date" value="1일" checked>
                        <label for="pd_1">1일</label>
                    </div>
                    <div class="dm-radio-item">
                        <input type="radio" id="pd_2" name="pay_date" value="5일">
                        <label for="pd_2">5일</label>
                    </div>
                    <div class="dm-radio-item">
                        <input type="radio" id="pd_3" name="pay_date" value="10일">
                        <label for="pd_3">10일</label>
                    </div>
                    <div class="dm-radio-item">
                        <input type="radio" id="pd_4" name="pay_date" value="15일">
                        <label for="pd_4">15일</label>
                    </div>
                </td>
            </tr>
        </table>

        <div class="dm-sub-title">4. 이용 동의서 및 서명</div>
		
		<div class="dm-term-group">
			<div class="dm-term-title">[전자기부금영수증 안내] <span style="color:red">*</span></div>
			<div class="dm-term-box">
				* 우리 기관은 기부금에 대해 전자기부금영수증을 발급합니다.<br>
				* 발급된 영수증은 국세청 연말정산 간소화 서비스에 자동 반영되며, 별도의 종이 영수증은 제공되지 않습니다.<br>
				* 기부금 내역은 국세청 홈택스(www.hometax.go.kr)에서 확인하실 수 있습니다.
			</div>
			<input type="hidden" name="term_title_0" value="전자기부금영수증 안내">
			<input type="hidden" name="term_content_0" value="우리 기관은 기부금에 대해 전자기부금영수증을 발급합니다. 발급된 영수증은 국세청 연말정산 간소화 서비스에 자동 반영되며, 별도의 종이 영수증은 제공되지 않습니다. 기부금 내역은 국세청 홈택스에서 확인하실 수 있습니다.">
			<div class="dm-agree-check dm-radio-group">
				<input type="checkbox" id="ag_0" name="agree_0" value="Y" required> <label for="ag_0">확인했습니다.</label>
			</div>
		</div>

		<div class="dm-term-group">
			<div class="dm-term-title">[CMS자동이체 안내사항] <span style="color:red">*</span></div>
			<div class="dm-term-box">
				CMS 자동이체 신청을 위해 후원신청 완료 후 ARS를 통해 '출금동의 증빙자료' 제출 과정이 진행됩니다.
			</div>
			<input type="hidden" name="term_title_1" value="CMS자동이체 안내사항">
			<input type="hidden" name="term_content_1" value="CMS 자동이체 신청을 위해 후원신청 완료 후 ARS를 통해 '출금동의 증빙자료' 제출 과정이 진행됩니다.">
			<div class="dm-agree-check dm-radio-group">
				<input type="checkbox" id="ag_1" name="agree_1" value="Y" required> <label for="ag_1">확인했습니다.</label>
			</div>
		</div>

		<div class="dm-term-group">
			<div class="dm-term-title">[금융거래 정보 제공 동의서] <span style="color:red">*</span></div>
			<div class="dm-term-box">
				본 신청과 관련하여 본인은 위 금융거래정보(거래은행명, 계좌번호)를 출금이체 신규 신청하는 때로부터 해지 신청할 때까지 (사)비영리아이티지원센터와 CMS 출금이체 계약을 체결한 수납기관에 제공하는 것에 대하여 '금융실명거래 및 비밀보장에 관한 법률'의 규정에 따라 동의합니다.
			</div>
			<input type="hidden" name="term_title_2" value="금융거래 정보 제공 동의서">
			<input type="hidden" name="term_content_2" value="본 신청과 관련하여 본인은 위 금융거래정보를 출금이체 신규 신청 시부터 해지 시까지 수납기관에 제공하는 것에 대하여 금융실명거래 및 비밀보장에 관한 법률에 따라 동의합니다.">
			<div class="dm-agree-check dm-radio-group">
				<input type="checkbox" id="ag_2" name="agree_2" value="Y" required> <label for="ag_2">동의합니다.</label>
			</div>
		</div>

		<div class="dm-term-group">
			<div class="dm-term-title">[개인정보 이용 동의서] <span style="color:red">*</span></div>
			<div class="dm-term-box">
				1. 수집 및 이용목적 : CMS출금이체를 통한 요금 수납<br>
				2. 수집항목 : 성명, 휴대전화, 금융기관명, 계좌번호<br>
				3. 보유 및 이용기간 : 수집 및 이용동의일로부터 CMS출금이체 종료일(해지일)후 5년
			</div>
			<input type="hidden" name="term_title_3" value="개인정보 이용 동의서">
			<input type="hidden" name="term_content_3" value="1. 수집 및 이용목적 : CMS출금이체를 통한 요금 수납 2. 수집항목 : 성명, 휴대전화, 금융기관명, 계좌번호 3. 보유 및 이용기간 : 수집 및 이용동의일로부터 CMS출금이체 종료일후 5년">
			<div class="dm-agree-check dm-radio-group">
				<input type="checkbox" id="ag_3" name="agree_3" value="Y" required> <label for="ag_3">동의합니다.</label>
			</div>
		</div>

		<div class="dm-term-group">
			<div class="dm-term-title">[개인정보 3자 제공 동의서] <span style="color:red">*</span></div>
			<div class="dm-term-box">
				신청자는 개인정보에 대해 금융결제원에게 제공하는 것을 거부할 권리가 있습니다. * 정보를 제공받는 자 : 금융결제원, 후원기관 * 제공목적 : CMS 출금이체 서비스 제공 및 출금동의확인
			</div>
			<input type="hidden" name="term_title_4" value="개인정보 3자 제공 동의서">
			<input type="hidden" name="term_content_4" value="정보를 제공받는 자 : 금융결제원, 후원기관 / 제공목적 : CMS 출금이체 서비스 제공 및 출금동의확인, 출금이체 신규등록 및 해지 사실통지">
			<div class="dm-agree-check dm-radio-group">
				<input type="checkbox" id="ag_4" name="agree_4" value="Y" required> <label for="ag_4">동의합니다.</label>
			</div>
		</div>

        <div class="dm-term-group" style="margin-top:40px;">
            <div class="dm-term-title">후원자 서명 <span style="color:red">*</span></div>
            <p style="font-size:14px; color:#666; margin-bottom:10px;">아래 네모 박스 안에 마우스나 손가락으로 서명해 주세요.</p>
            <div class="dm-signature-wrap">
                <canvas id="signature-pad" class="dm-signature-pad"></canvas>
                <button type="button" class="dm-sig-clear-btn" id="clear-signature">다시 쓰기</button>
            </div>
        </div>

        <div class="dm-btn-wrap">
            <button type="submit" class="dm-btn dm-btn-submit">제출 및 서명완료</button>
        </div>

    </form>
</div>

<script>
    // 1. 도화지(Canvas) 세팅
    const canvas = document.getElementById('signature-pad');
    
    function resizeCanvas() {
        const ratio =  Math.max(window.devicePixelRatio || 1, 1);
        canvas.width = canvas.offsetWidth * ratio;
        canvas.height = canvas.offsetHeight * ratio;
        canvas.getContext("2d").scale(ratio, ratio);
    }
    window.addEventListener("resize", resizeCanvas);
    resizeCanvas();

    // 2. 서명 패드 라이브러리 실행
    const signaturePad = new SignaturePad(canvas, {
        penColor: "rgb(0, 0, 0)",
        backgroundColor: "rgb(255, 255, 255)"
    });

    // 3. 다시 쓰기 버튼
    document.getElementById('clear-signature').addEventListener('click', function () {
        signaturePad.clear();
    });

    // 4. 폼 제출 시 이벤트

       

        //const emailAddress = document.getElementById('agency_email').value;
        
        //alert(`완벽합니다! 서명이 확인되었습니다.\n\n실제 서버가 연동되면, 이 신청서 내용 전체가 PDF로 변환되어 [ ${emailAddress} ](으)로 즉시 발송됩니다.`);
	
	
	document.getElementById('sponsorship_form').addEventListener('submit', function (event) {
    event.preventDefault();

    if (signaturePad.isEmpty()) {
        alert("후원자 서명을 작성해 주세요.");
        return;
    }
	
	// 모든 체크박스 동의 여부 재검증 (브라우저 validation 지원용)
    if(!this.checkValidity()) {
        alert("모든 필수 항목에 동의해 주세요.");
        return;
    }

    // 서명 데이터를 Base64 문자열로 추출
    const signatureImage = signaturePad.toDataURL();

    // 폼 데이터를 가져와서 서명 데이터 추가
    const formData = new FormData(this);
    formData.append('signature_image', signatureImage);
    
    // AJAX 전송
    $.ajax({
        url: '/rx/insert_form/insert_proc.php',
        type: 'POST',
        data: formData,
        processData: false,
        contentType: false,
        success: function(response) {
            if(response.error === 0) {
                alert(response.message);
                location.reload();
            } else {
                alert("오류: " + response.message);
            }
        }
    });
});

</script>

</body>
</html>

 

<?php
ob_start();
error_reporting(0);
ini_set('display_errors', 0);

define('__XE__', true);
require_once('../config/config.inc.php');
$oContext = &Context::getInstance();
$oContext->init();

header('Content-Type: application/json');

try {
    // 1. 데이터 수집
    $title = "후원신청서 - " . ($_POST['member_name'] ?: '무명후원자');
    $member_name = $_POST['member_name'] ?? '미입력';
    $support_type = $_POST['support_type'] ?? '정기후원';
    $support_category = $_POST['support_category'] ?? '미선택';
    $support_amount = $_POST['support_amount'] ?? '0';
    $member_type = $_POST['member_type'] ?? '개인';
    $phone = $_POST['phone'] ?? '미입력';
    $email = $_POST['email'] ?? '미입력';
    $bank_name = $_POST['bank_name'] ?? '미선택';
    $account_num = $_POST['account_num'] ?? '미입력';
    $pay_date = $_POST['pay_date'] ?? '미지정';
    
    // 서명 데이터 (Base64)
    $signature_data = $_POST['signature_image'] ?? ''; 

    // --- 추가: 약관 동의 데이터 수집 (반복문 처리) ---
    $agreement_list_html = "";
    for ($i = 0; $i < 5; $i++) {
        $t_title   = $_POST["term_title_$i"]; // HTML hidden 필드에서 전달됨
        $t_content = $_POST["term_content_$i"]; // HTML hidden 필드에서 전달됨
        $t_agree   = ($_POST["agree_$i"] == 'Y') ? '동의/확인함' : '미동의';

        if($t_title) {
            $agreement_list_html .= "
                <div style='margin-bottom:12px; border-bottom:1px dashed #ccc; padding-bottom:8px;'>
                    <div style='font-weight:bold; font-size:13px; color:#333;'>▣ {$t_title}</div>
                    <div style='font-size:11px; color:#666; margin:4px 0; line-height:1.4;'>{$t_content}</div>
                    <div style='font-size:12px;'>결과: <span style='color:#007aff; font-weight:bold;'>{$t_agree}</span></div>
                </div>";
        }
    }

    $module_srl = 51; 
    $oDB = DB::getInstance();
    $document_srl = getNextSequence();
    $regdate = date('YmdHis');

    // 2. 정적 HTML 파일 생성 경로 설정
    $html_save_dir = '../files/saved_html/';
    if(!is_dir($html_save_dir)) mkdir($html_save_dir, 0777, true);

    $html_filename = "support_{$document_srl}.html";
    $html_web_path = '/rx/files/saved_html/' . $html_filename;
    $html_full_path = $html_save_dir . $html_filename;

    // 3. 서류 디자인 (증빙용 HTML)
    $saved_html_content = '
    <!DOCTYPE html>
    <html lang="ko">
    <head>
        <meta charset="UTF-8">
        <title>후원신청서 증빙 - ' . htmlspecialchars($member_name) . '</title>
        <style>
            body { font-family: "Malgun Gothic", sans-serif; padding: 30px; line-height: 1.5; color: #333; }
            .doc-wrap { max-width: 700px; margin: 0 auto; border: 1px solid #000; padding: 30px; }
            h1 { text-align: center; font-size: 24px; text-decoration: underline; margin-bottom: 30px; }
            table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
            th, td { border: 1px solid #ccc; padding: 10px; font-size: 14px; }
            th { background: #f4f4f4; width: 30%; text-align: left; }
            .sig-box { text-align: center; margin-top: 40px; border-top: 2px solid #333; padding-top: 20px; }
            .sig-image { border: 1px solid #eee; width: 250px; height: 100px; margin-top: 10px; }
            .term-area { margin-top:30px; border:1px solid #eee; padding:15px; background:#fafafa; page-break-before: always; }
            @media print { .no-print { display: none; } }
        </style>
    </head>
    <body>
        <div class="no-print" style="text-align:right;"><button onclick="window.print()">PDF 저장 / 인쇄</button></div>
        <div class="doc-wrap">
            <h1>후 원 신 청 서</h1>
            <p style="text-align:right;">접수번호: ' . $document_srl . '</p>
            
            <h3>1. 후원 정보</h3>
            <table>
                <tr><th>후원방식/종류</th><td>' . $support_type . ' / ' . $support_category . '</td></tr>
                <tr><th>후원금액</th><td>' . number_format((int)$support_amount) . ' 원</td></tr>
            </table>

            <h3>2. 후원자 정보</h3>
            <table>
                <tr><th>성명(단체명)</th><td>' . htmlspecialchars($member_name) . ' (' . $member_type . ')</td></tr>
                <tr><th>연락처</th><td>' . htmlspecialchars($phone) . '</td></tr>
                <tr><th>이메일</th><td>' . htmlspecialchars($email) . '</td></tr>
            </table>

            <h3>3. 결제 정보 (CMS)</h3>
            <table>
                <tr><th>은행명</th><td>' . htmlspecialchars($bank_name) . '</td></tr>
                <tr><th>계좌번호</th><td>' . htmlspecialchars($account_num) . '</td></tr>
                <tr><th>출금희망일</th><td>매월 ' . $pay_date . '</td></tr>
            </table>

            <div class="term-area">
                <h3>4. 이용 약관 및 동의 기록</h3>
                ' . $agreement_list_html . '
            </div>

            <div class="sig-box">
                <p>본인은 위와 같이 정기 후원을 신청하며, 개인정보 활용 및 약관에 동의합니다.</p>
                <p>' . date('Y년 m월 d일') . '</p>
                <p style="font-size:18px; font-weight:bold;">신청인: ' . htmlspecialchars($member_name) . ' (인)</p>
                <img src="' . $signature_data . '" class="sig-image" alt="서명">
            </div>
        </div>
    </body>
    </html>';

    file_put_contents($html_full_path, $saved_html_content);

    // 4. 게시판 본문에 저장될 상세 내용 구성
    $db_content = '
    <div class="sponsorship-detail" style="font-family:sans-serif; line-height:1.6; max-width:600px; border:1px solid #ddd; padding:20px;">
        <h2 style="border-bottom:2px solid #007aff; padding-bottom:10px; color:#333;">후원 신청 상세 정보</h2>
        
        <table style="width:100%; border-collapse:collapse; margin-top:15px;">
            <tr><th style="width:30%; padding:8px; border:1px solid #ddd; background:#f9f9f9; text-align:left;">후원방식/종류</th><td style="padding:8px; border:1px solid #ddd;">' . htmlspecialchars($support_type) . ' / ' . htmlspecialchars($support_category) . '</td></tr>
            <tr><th style="padding:8px; border:1px solid #ddd; background:#f9f9f9; text-align:left;">후원금액</th><td style="padding:8px; border:1px solid #ddd;"><strong>' . number_format((int)$support_amount) . '원</strong></td></tr>
            <tr><th style="padding:8px; border:1px solid #ddd; background:#f9f9f9; text-align:left;">성명(단체명)</th><td style="padding:8px; border:1px solid #ddd;">' . htmlspecialchars($member_name) . ' (' . htmlspecialchars($member_type) . ')</td></tr>
            <tr><th style="padding:8px; border:1px solid #ddd; background:#f9f9f9; text-align:left;">연락처</th><td style="padding:8px; border:1px solid #ddd;">' . htmlspecialchars($phone) . '</td></tr>
            <tr><th style="padding:8px; border:1px solid #ddd; background:#f9f9f9; text-align:left;">이메일</th><td style="padding:8px; border:1px solid #ddd;">' . htmlspecialchars($email) . '</td></tr>
            <tr><th style="padding:8px; border:1px solid #ddd; background:#f9f9f9; text-align:left;">은행/계좌</th><td style="padding:8px; border:1px solid #ddd;">' . htmlspecialchars($bank_name) . ' / ' . htmlspecialchars($account_num) . '</td></tr>
            <tr><th style="padding:8px; border:1px solid #ddd; background:#f9f9f9; text-align:left;">출금희망일</th><td style="padding:8px; border:1px solid #ddd;">매월 ' . htmlspecialchars($pay_date) . '</td></tr>
        </table>

        <div style="margin-top:20px; padding:15px; border:1px solid #e1e1e1; background:#fcfcfc;">
            <h4 style="margin:0 0 10px 0; color:#007aff;">[약관 동의 기록]</h4>
            ' . $agreement_list_html . '
        </div>

        <div style="margin-top:20px; text-align:center; background:#f5f5f5; padding:10px;">
            <p style="font-size:12px; color:#666; margin-bottom:5px;">[후원자 서명 확인]</p>
            <img src="' . $signature_data . '" style="width:200px; height:80px; border:1px solid #ccc; background:#fff;" alt="서명">
        </div>

        <div style="margin-top:20px; padding:15px; border:2px solid #007aff; background:#f0f8ff; text-align:center;">
            <strong style="color:#007aff;">[증빙용 문서 다운로드]</strong><br>
            <a href="' . $html_web_path . '" target="_blank" style="font-size:15px; font-weight:bold; color:#d9534f; text-decoration:underline;">
                ▶ 서명 포함된 후원신청서(HTML) 열기
            </a>
        </div>
    </div>';

    // 5. DB 저장
    $password = $_POST['password'] ?: '1111';
    $hash_password = getModel('member')->hashPassword($password);

    $query = "INSERT INTO documents (document_srl, module_srl, title, content, nick_name, password, regdate, last_update, list_order, update_order, status) 
              VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'SECRET')";
    
    $args = array($document_srl, $module_srl, $title, $db_content, $member_name, $hash_password, $regdate, $regdate, $document_srl*-1, $document_srl*-1);
    $oDB->prepare($query)->execute($args);

    ob_end_clean();
    echo json_encode(array('error' => 0, 'message' => '후원 신청이 정상적으로 완료되었습니다.'));

} catch (Exception $e) {
    ob_end_clean();
    echo json_encode(array('error' => -1, 'message' => $e->getMessage()));
}
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2026/03   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
글 보관함