라이믹스

라이믹스 입력폼. 후원신청서

xemaker 2026. 7. 10. 12:52

라이믹스 후원신청서 입력폼

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>후원신청서 수정본</title>

    <!-- 외부 라이브러리 (서명 패드 및 jQuery) -->
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <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" value="정기후원" checked>
                        <label for="st_1">정기후원</label>
                    </div>
                    <div class="dm-radio-item">
                        <input type="radio" id="st_2" name="support_type" value="일시후원">
                        <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_3" name="support_category" value="지정 후원 (후원자 의도에 맞게)" checked>
                        <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>
                    <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_1" name="support_category" value="아동숙사(1인실) 리모델링 후원">
                        <label for="sc_1">아동숙사(1인실) 리모델링 후원</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" value="100000">
						<label for="sa_1">100,000원</label>
					</div>
					<div class="dm-radio-item-block">
						<input type="radio" id="sa_2" name="support_amount" value="50000">
						<label for="sa_2">50,000원</label>
					</div>
					<div class="dm-radio-item-block">
						<input type="radio" id="sa_3" name="support_amount" value="30000" checked>
						<label for="sa_3">30,000원</label>
					</div>
					<div class="dm-radio-item-block">
						<input type="radio" id="sa_4" name="support_amount" value="20000">
						<label for="sa_4">20,000원</label>
					</div>
					<div class="dm-radio-item-block">
						<input type="radio" id="sa_5" name="support_amount" value="기타">
						<label for="sa_5">기타:</label>
						<input type="text" name="support_amount_custom" class="dm-input" style="width: 150px; margin-left: 8px; display: inline-block;"> 원
					</div>
				</td>
			</tr>
            <tr id="support_period_row">
                <th>후원기간 <span style="color:red">*</span></th>
                <td class="dm-radio-group">
                    <div class="dm-radio-item">
                        <input type="radio" id="sp_1" name="support_period" value="1년" checked>
                        <label for="sp_1">1년</label>
                    </div>
                    <div class="dm-radio-item">
                        <input type="radio" id="sp_2" name="support_period" value="3년">
                        <label for="sp_2">3년</label>
                    </div>
                    <div class="dm-radio-item">
                        <input type="radio" id="sp_3" name="support_period" value="5년">
                        <label for="sp_3">5년</label>
                    </div>
                    <div class="dm-radio-item">
                        <input type="radio" id="sp_custom" name="support_period" value="직접등록">
                        <label for="sp_custom">직접등록</label>
                    </div>
                    <div id="sp_custom_wrap" style="display: none; margin-top: 8px;">
                        <input type="text" id="sp_custom_input" name="support_period_custom" class="dm-input" style="width: 180px; display: inline-block;" placeholder="예: 2년 또는 24개월">
                    </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" value="개인" checked>
                        <label for="mt_1">개인</label>
                    </div>
                    <div class="dm-radio-item">
                        <input type="radio" id="mt_2" name="member_type" value="사업자">
                        <label for="mt_2">사업자</label>
                    </div>
                </td>
            </tr>
            <tr>
                <th id="member_name_label">후원회원명 <span style="color:red">*</span></th>
                <td><input type="text" id="member_name_input" 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" value="Y">
						<label for="rr_1" id="receipt_req_label_1">발급신청 (하단 질문에 주민등록번호를 작성해주세요)</label>
					</div>
					<div class="dm-radio-item-block">
						<input type="radio" id="rr_2" name="receipt_req" value="N" checked>
						<label for="rr_2">신청안함</label>
					</div>
                </td>
            </tr>
            <tr>
                <th id="reg_num_label">주민등록번호<span style="color:red">*</span></th>
                <td>
                    <input type="text" id="reg_num_input" name="reg_num" class="dm-input" placeholder="예) 800101-1234567">
                    <span id="reg_num_help" 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" required></td>
            </tr>
            <tr>
                <th>주소 <span style="color:red">*</span></th>
                <td>
                    <input type="text" name="address" class="dm-input" placeholder="도로명 주소(새주소)를 상세히 작성해주세요" required>
                    <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="예금주 성함" name="depositor_name" required></td>
            </tr>
            <tr>
                <th id="depositor_birth_label">예금주 생년월일 <span style="color:red">*</span></th>
                <td>
                    <input type="text" id="depositor_birth_input" name="depositor_birth" class="dm-input" placeholder="예금주 생년월일 6자리" required>
                    <span id="depositor_birth_help" class="dm-help-text">(주민번호 앞 6자리)</span>
                </td>
            </tr>
            <tr>
                <th>은행 <span style="color:red">*</span></th>
                <td>
                    <input type="text" name="bank_name" class="dm-input" placeholder="은행명을 직접 작성해주세요 (예: 국민은행)" required style="max-width: 300px;">
                </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">
                신청자는 개인정보에 대해 금융결제원에게 제공하는 것을 거부할 권리가 있습니다. <br>
* 정보를 제공받는 자 : 금융결제원, 후원기관 <br>* 제공목적 : 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="btn_submit dm-btn dm-btn-submit">제출 및 서명완료</button>
        </div>

    </form>
</div>

<script>
    // 회원구분 변경 시 UI 동적 전환
    $('input[name="member_type"]').on('change', function() {
        const memberType = $(this).attr('id');
        
        if (memberType === 'mt_1') { // 개인 선택 시
            // 2. 후원회원정보 영역 변경
            $('#member_name_label').html('후원회원명 <span style="color:red">*</span>');
            $('#member_name_input').attr('placeholder', '이름을 작성하세요');
            
            $('#receipt_req_label_1').text('발급신청 (하단 질문에 주민등록번호를 작성해주세요)');
            
            $('#reg_num_label').html('주민등록번호 작성 <span style="color:red">*</span>');
            $('#reg_num_input').attr('placeholder', '예) 800101-1234567');
            $('#reg_num_help').text('국세청 연말정산간소화서비스를 통해 기부금영수증을 발급받으시려면 주민등록번호를 작성해주세요.');
            
            // 3. 출금 정보 영역 변경
            $('#depositor_birth_label').html('예금주 생년월일 <span style="color:red">*</span>');
            $('#depositor_birth_input').attr('placeholder', '예금주 생년월일 6자리');
            $('#depositor_birth_help').text('(주민번호 앞 6자리)');
            
        } else if (memberType === 'mt_2') { // 사업자 선택 시
            // 2. 후원회원정보 영역 변경
            $('#member_name_label').html('후원회원명(사업자명) <span style="color:red">*</span>');
            $('#member_name_input').attr('placeholder', '사업자명을 작성해주세요');
            
            $('#receipt_req_label_1').text('발급신청 (하단 질문에 사업자등록번호를 작성해주세요)');
            
            $('#reg_num_label').html('사업자등록번호 입력 <span style="color:red">*</span>');
            $('#reg_num_input').attr('placeholder', '예) 123-45-67890');
            $('#reg_num_help').text('기부금영수증을 발급받으시려면 사업자등록번호를 작성해주세요.');
            
            // 3. 출금 정보 영역 변경
            $('#depositor_birth_label').html('사업자등록번호 (또는 생년월일) <span style="color:red">*</span>');
            $('#depositor_birth_input').attr('placeholder', '사업자등록번호 10자리 (또는 생년월일 6자리)');
            $('#depositor_birth_help').text('(사업자등록번호 10자리 또는 생년월일 6자리를 작성해주세요)');
        }
    });

    // 후원 방식(정기/일시) 변경 시 후원기간 노출 전환
    $('input[name="support_type"]').on('change', function() {
        const supportType = $(this).attr('id');
        if (supportType === 'st_2') { // 일시후원 선택 시
            $('#support_period_row').hide();
        } else { // 정기후원 선택 시
            $('#support_period_row').show();
        }
    });

    // 후원기간 직접등록 선택 시 입력창 노출 전환
    $('input[name="support_period"]').on('change', function() {
        if ($(this).attr('id') === 'sp_custom') {
            $('#sp_custom_wrap').show();
            $('#sp_custom_input').focus();
        } else {
            $('#sp_custom_wrap').hide();
            $('#sp_custom_input').val('');
        }
    });

    // 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. 폼 제출 시 이벤트
    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: './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>

이제 껍데기(html)은 작성했으니, 실제 db에 라이믹스 구조에 맞게 넣어본다.

<?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'] ?? '미선택';
    $member_type      = $_POST['member_type'] ?? '개인';
    $phone            = $_POST['phone'] ?? '미입력';
    $email            = $_POST['email'] ?? '미입력';
    $address          = $_POST['address'] ?? '미입력';
    $bank_name        = $_POST['bank_name'] ?? '미선택';
    $account_num      = $_POST['account_num'] ?? '미입력';
    $pay_date         = $_POST['pay_date'] ?? '미지정';
    
    // 후원 금액 라디오 버튼과 기타 금액 텍스트 input 통합 처리 보완
    $support_amount = $_POST['support_amount'] ?? '0';
    if ($support_amount === '기타' || (isset($_POST['support_amount_custom']) && trim($_POST['support_amount_custom']) !== '')) {
        $support_amount = $_POST['support_amount_custom'];
    }
    $support_amount_int = (int)str_replace(',', '', $support_amount);

    // 후원 기간 처리 (일시 후원인 경우 제외)
    $support_period = '일시후원(해당없음)';
    if ($support_type === '정기후원') {
        $support_period = $_POST['support_period'] ?? '미선택';
        if ($support_period === '직접등록' && isset($_POST['support_period_custom'])) {
            $support_period = $_POST['support_period_custom'] . " (직접등록)";
        }
    }

    // [버그 수정 완료] 데이터가 넘어오지 않거나 on이 아닐 때는 확실히 '신청안함' 처리
    $receipt_req_raw  = $_POST['receipt_req'] ?? ''; 
    if ($receipt_req_raw === 'on' || $receipt_req_raw === 'Y') {
        $receipt_req = '신청함';
    } else {
        $receipt_req = '신청안함';
    }

    $reg_num          = $_POST['reg_num'] ?? '미입력'; 
    $depositor_name   = $_POST['depositor_name'] ?? '미입력'; 
    $depositor_birth  = $_POST['depositor_birth'] ?? '미입력'; 

    // 서명 데이터 (Base64)
    $signature_data = $_POST['signature_image'] ?? ''; 

    // --- 약관 동의 데이터 수집 (반복문 처리) ---
    $agreement_list_html = "";
    for ($i = 0; $i < 5; $i++) {
        $t_title   = $_POST["term_title_$i"]; 
        $t_content = $_POST["term_content_$i"]; 
        $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 = 2301; // 게시판 모듈 SRL 번호
    $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 - 폼 입력 순서 100% 일치)
    $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: 35%; 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>' . htmlspecialchars($support_type) . '</td></tr>
                <tr><th>후원종류</th><td>' . htmlspecialchars($support_category) . '</td></tr>
                <tr><th>후원금액</th><td>' . number_format($support_amount_int) . ' 원</td></tr>
                <tr><th>후원기간</th><td>' . htmlspecialchars($support_period) . '</td></tr>
            </table>

            <h3>2. 후원자 정보</h3>
            <table>
				<tr><th>회원구분</th><td>' . htmlspecialchars($member_type) . '</td></tr>
                <tr><th>성명(단체명)</th><td>' . htmlspecialchars($member_name) . '</td></tr>
                <tr><th>기부금영수증 신청 여부</th><td>' . htmlspecialchars($receipt_req) . '</td></tr>
				<tr><th>식별등록번호 (주민/사업자)</th><td>' . htmlspecialchars($reg_num) . '</td></tr>
                <tr><th>연락처</th><td>' . htmlspecialchars($phone) . '</td></tr>
                <tr><th>이메일</th><td>' . htmlspecialchars($email) . '</td></tr>
                <tr><th>주소</th><td>' . htmlspecialchars($address) . '</td></tr>

            </table>

            <h3>3. 결제 정보 (CMS)</h3>
            <table>
                <tr><th>예금주명</th><td>' . htmlspecialchars($depositor_name) . '</td></tr>
				<tr><th>예금주 생년월일 (사업자번호)</th><td>' . htmlspecialchars($depositor_birth) . '</td></tr>
				<tr><th>은행명</th><td>' . htmlspecialchars($bank_name) . '</td></tr>
                <tr><th>계좌번호</th><td>' . htmlspecialchars($account_num) . '</td></tr>
                <tr><th>자동이체 출금일</th><td>매월 ' . htmlspecialchars($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>
                ' . ($signature_data ? '<img src="' . htmlspecialchars($signature_data) . '" class="sig-image" alt="서명">' : '<p style="color:red;">(서명 유실됨)</p>') . '
            </div>
        </div>
    </body>
    </html>';

    file_put_contents($html_full_path, $saved_html_content);

    // 4. 라이믹스/XE 문서 본문에 바인딩될 HTML 구조화 (폼 입력 순서 100% 일치)
    $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>
        
        <h3 style="color:#555; font-size:15px; margin-top:20px;">1. 후원 정보</h3>
        <table style="width:100%; border-collapse:collapse; margin-bottom:15px;">
            <tr><th style="width:35%; padding:8px; border:1px solid #ddd; background:#f9f9f9; text-align:left;">후원방식</th><td style="padding:8px; border:1px solid #ddd;">' . htmlspecialchars($support_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($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($support_amount_int) . '원</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($support_period) . '</td></tr>
        </table>

        <h3 style="color:#555; font-size:15px; margin-top:20px;">2. 후원자 정보</h3>
        <table style="width:100%; border-collapse:collapse; margin-bottom:15px;">
            <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_type) . '</td></tr>
		    <tr><th style="width:35%; padding:8px; border:1px solid #ddd; background:#f9f9f9; text-align:left;">성명(단체명)</th><td style="padding:8px; border:1px solid #ddd;">' . htmlspecialchars($member_name) . '</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($receipt_req) . '</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($reg_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($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($address) . '</td></tr>
        </table>

        <h3 style="color:#555; font-size:15px; margin-top:20px;">3. 결제 정보 (CMS)</h3>
        <table style="width:100%; border-collapse:collapse; margin-bottom:15px;">
		
		    <tr><th style="padding:8px; border:1px solid #ddd; background:#f9f9f9; text-align:left;">예금주명</th><td style="padding:8px; border:1px solid #ddd;">' . htmlspecialchars($depositor_name) . '</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($depositor_birth) . '</td></tr>
			<tr><th style="width:35%; padding:8px; border:1px solid #ddd; background:#f9f9f9; text-align:left;">은행명</th><td style="padding:8px; border:1px solid #ddd;">' . htmlspecialchars($bank_name) . '</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($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>
            <tr><th style="padding:8px; border:1px solid #ddd; background:#f9f9f9; text-align:left;">온라인 증빙서 링크</th><td style="padding:8px; border:1px solid #ddd;"><a href="' . $html_web_path . '" target="_blank">증빙서 HTML 열기</a></td></tr>
        </table>

        <div style="margin-top:15px; text-align:center;">
            <p><strong>[후원자 전자 서명 이미지]</strong></p>
            <img src="' . htmlspecialchars($signature_data) . '" style="border:1px solid #ccc; max-width:200px;" alt="서명">
        </div>
    </div>';

    // 5. Rhymix / XE 표준 규격에 충족하는 데이터베이스 원장 생성 연동
    $oDocumentController = getController('document');
    $obj = new stdClass();
    $obj->document_srl = $document_srl;
    $obj->module_srl   = $module_srl;
    $obj->title        = $title;
    $obj->content      = $db_content;
    $obj->allow_comment = 'N';
    $obj->regdate      = $regdate;
    
    $output = $oDocumentController->insertDocument($obj);

    if(!$output->toBool()) {
        throw new Exception($output->getMessage());
    }

    echo json_encode([
        'error' => 0,
        'message' => '후원 신청서가 안전하게 접수되었습니다. 감사합니다.',
        'document_srl' => $document_srl
    ]);

} catch (Exception $e) {
    echo json_encode([
        'error' => -1,
        'message' => $e->getMessage()
    ]);
}
ob_end_flush();
?>