<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
if (!$is_member) { alert("회원만 신청이 가능합니다.","/bbs/login.php?url=/lmth/08_job/job_info01.php");exit; }

// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨
// add_stylesheet('<link rel="stylesheet" href="'.$board_skin_url.'/style.css">', 0);

//1단계 값 세션 저장(by nogada,220217)=>쿠키로 변경(220222)
//set_session("ss_common_check", $_POST[common_check]);
//set_session("ss_choose_radio", $_POST[choose_radio]);
set_cookie("ck_common_check", $_POST[common_check], 86400);
set_cookie("ck_choose_radio", $_POST[choose_radio], 86400);
$ck_rent_wr_id	= get_cookie("ck_rent_wr_id");

$sql	= " select * from g5_write_{$bo_table} where wr_id = '{$ck_rent_wr_id}' ";
$row	= sql_fetch($sql);
?>
<link rel="stylesheet" type="text/css" href="<?php echo $board_skin_url; ?>/style.css" />
		<script src="//spi.maps.daum.net/imap/map_js_init/postcode.v2.js"></script>
<section id="bo_w">
    <h2 id="container_title"><?php echo $g5['title'] ?></h2>

    <!-- 게시물 작성/수정 시작 { -->
    <form name="fwrite" id="fwrite" action="<?php echo $action_url ?>" onsubmit="return fwrite_submit(this);" method="post" enctype="multipart/form-data" autocomplete="off" style="width:<?php echo $width; ?>">
    <input type="hidden" name="uid" value="<?php echo get_uniqid(); ?>">
    <input type="hidden" name="w" value="<?php echo $w ?>">
    <input type="hidden" name="bo_table" value="<?php echo $bo_table ?>">
    <input type="hidden" name="wr_id" value="<?php echo $wr_id ?>">
    <input type="hidden" name="sca" value="<?php echo $sca ?>">
    <input type="hidden" name="sfl" value="<?php echo $sfl ?>">
    <input type="hidden" name="stx" value="<?php echo $stx ?>">
    <input type="hidden" name="spt" value="<?php echo $spt ?>">
    <input type="hidden" name="sst" value="<?php echo $sst ?>">
    <input type="hidden" name="sod" value="<?php echo $sod ?>">
    <input type="hidden" name="page" value="<?php echo $page ?>">
    <input type="hidden" name="wr_subject" value="면접정장대여">
    <input type="hidden" name="wr_content" value="면접정장대여">
    <?php
    $option = '';
    $option_hidden = '';
    if ($is_notice || $is_html || $is_secret || $is_mail) {
        $option = '';
        if ($is_secret) {
            if ($is_admin || $is_secret==1) {
                $option .= "\n".'<input type="checkbox" id="secret" name="secret" value="secret" '.$secret_checked.'>'."\n".'<label for="secret">비밀글</label>';
            } else {
                $option_hidden .= '<input type="hidden" name="secret" value="secret">';
            }
        }

        if ($is_mail) {
            $option .= "\n".'<input type="checkbox" id="mail" name="mail" value="mail" '.$recv_email_checked.'>'."\n".'<label for="mail">답변메일받기</label>';
        }
    }

    echo $option_hidden;
	//기본항목 변경(by nogada,220203)
	$is_password	= false;
	$is_email		= false;
	$is_file		= true;
	$is_guest		= false;
    ?>

    <div class="tbl_frm01 tbl_wrap">
      <p class="t_tit">
        <em>신청정보작성 (모든 내용 필수기입)</em><br>
        * 제출서류와 신청정보 불일치시 신청이 반려될 수 있습니다.
    </p>
        <table>
        <tbody>
        <?php if ($is_name) { ?>
        <tr>
            <th scope="row" class="frm_tit"><label for="wr_name">성명<strong class="sound_only">필수</strong></label></th>
            <td class="frm_con"><input type="text" name="wr_name" value="<?php echo $row['wr_name']; ?>" id="wr_name" required class="frm_input" size="10" maxlength="20" placeholder="홍길동" onfocus="this.placeholder=''" onblur="this.placeholder='홍길동'"></td>
        </tr>
        <?php } ?>

        <?php if ($is_password) { ?>
        <tr>
            <th scope="row" class="frm_tit"><label for="wr_password">비밀번호<strong class="sound_only">필수</strong></label></th>
            <td class="frm_con"><input type="password" name="wr_password" id="wr_password" <?php echo $password_required ?> class="frm_input <?php echo $password_required ?>" maxlength="20"></td>
        </tr>
        <?php } ?>

        <?php if ($is_email) { ?>
        <tr>
            <th scope="row" class="frm_tit"><label for="wr_email">이메일</label></th>
            <td class="frm_con"><input type="text" name="wr_email" value="<?php echo $email ?>" id="wr_email" class="frm_input email" size="50" maxlength="80"></td>
        </tr>
        <?php } ?>

        <?php if ($option) { ?>
        <tr>
            <th scope="row" class="frm_tit">옵션</th>
            <td class="frm_con"><?php echo $option ?></td>
        </tr>
        <?php } ?>

        <?php if ($is_category) { ?>
        <tr>
            <th scope="row" class="frm_tit"><label for="ca_name">분류<strong class="sound_only">필수</strong></label></th>
            <td class="frm_con">
                <select name="ca_name" id="ca_name" required class="required" >
                    <option value="">선택하세요</option>
                    <?php echo $category_option ?>
                </select>
            </td>
        </tr>
        <?php } ?>

		<?php /* 주석처리(by nogada,220203)
        <tr>
            <th scope="row" class="frm_tit"><label for="wr_subject">제목<strong class="sound_only">필수</strong></label></th>
            <td class="frm_con">
                <input type="text" name="wr_subject" value="<?php echo $subject ?>" id="wr_subject" required class="frm_input required" size="50" maxlength="255">
            </td>
        </tr>

        <tr>
            <th scope="row" class="frm_tit"><label for="wr_content">내용<strong class="sound_only">필수</strong></label></th>
            <td class="wr_content frm_con">
                <?php if($write_min || $write_max) { ?>
                <!-- 최소/최대 글자 수 사용 시 -->
                <p id="char_count_desc">이 게시판은 최소 <strong><?php echo $write_min; ?></strong>글자 이상, 최대 <strong><?php echo $write_max; ?></strong>글자 이하까지 글을 쓰실 수 있습니다.</p>
                <?php } ?>
                <?php echo $editor_html; // 에디터 사용시는 에디터로, 아니면 textarea 로 노출 ?>
                <?php if($write_min || $write_max) { ?>
                <!-- 최소/최대 글자 수 사용 시 -->
                <div id="char_count_wrap"><span id="char_count"></span>글자</div>
                <?php } ?>
            </td>
        </tr>
		<?php */ ?>


        <tr>
            <th scope="row" class="frm_tit"><label for="wr_1">성별<strong class="sound_only">필수</strong></label></th>
            <td class="frm_con">
            <label><input type="radio" name="wr_1" value="남" <?php if($row['wr_1'] == "남") { echo "checked"; } ?> id="wr_1" required class="frm_input"> 남</label>
            <label><input type="radio" name="wr_1" value="여" <?php if($row['wr_1'] == "여") { echo "checked"; } ?> id="wr_1" required class="frm_input"> 여</label>
			</td>
        </tr>
        <tr>
            <th scope="row" class="frm_tit"><label for="wr_2">생년월일<strong class="sound_only">필수</strong></label></th>
            <td class="frm_con"><input type="text" name="wr_2" value="<?php echo $row['wr_2'] ?>" id="wr_2" required class="frm_input" size="10" maxlength="20" placeholder="ex) 1991년3월7일" onfocus="this.placeholder=''" onblur="this.placeholder='ex) 1991년3월7일'"></td>
        </tr>
        <tr class="age">
            <th scope="row" class="frm_tit"><label for="wr_twitter_user">나이<strong class="sound_only">필수</strong></label></th>
            <td class="frm_con"><input type="text" name="wr_twitter_user" value="<?php echo $row['wr_twitter_user'] ?>" id="wr_twitter_user" required class="frm_input" size="10" maxlength="20" placeholder="ex) 27세" onfocus="this.placeholder=''" onblur="this.placeholder='ex) 27세'"></td>
        </tr>
        <tr>
            <th scope="row" class="frm_tit"><label for="wr_3">최종학력<strong class="sound_only">필수</strong></label></th>
            <td class="frm_con university">
             <label><input type="radio" name="wr_3" value="고등학교 졸업(예정자포함)" <?php if($row['wr_3'] == "고등학교 졸업(예정자포함)") { echo "checked"; } ?> id="wr_3" required class="frm_input"> 고등학교 졸업(예정자포함)</label><br>
             <label><input type="radio" name="wr_3" value="대학교 재학" class="univer" <?php if($row['wr_3'] == "대학교 재학") { echo "checked"; } ?> id="wr_3" required class="frm_input"> 대학교 재학</label> &nbsp;<input type="text" name="wr_facebook_user" value="<?php echo $row['wr_facebook_user'];?>" class="wr_facebook_user"  placeholder="학교명" onfocus="this.placeholder=''" onblur="this.placeholder='학교명'"><br>
             <label><input type="radio" name="wr_3" value="대학교 졸업" <?php if($row['wr_3'] == "대학교 졸업") { echo "checked"; } ?> id="wr_3" required class="frm_input"> 대학교 졸업</label><br>
             <label><input type="radio" name="wr_3" value="검정고시 졸업" <?php if($row['wr_3'] == "검정고시 졸업") { echo "checked"; } ?> id="wr_3" required class="frm_input"> 검정고시 졸업</label>
		      	</td>
        </tr>
        <tr class="addr_wrap">
            <th scope="row" class="frm_tit"><label for="wr_4">주소지<strong class="sound_only">필수</strong></label></th>
            <td class="frm_con">
              <!-- <input type="text" name="wr_4" value="<?php echo $row['wr_4']; ?>" id="wr_4" required class="frm_input" size="20" maxlength="40" placeholder="ex) 천안시 동남구 은행길 5-4 천안시2030청년복지센터" onfocus="this.placeholder=''" onblur="this.placeholder='ex) 천안시 동남구 은행길 5-4 천안시2030청년복지센터'"><br> -->
              <!-- 2022.02.28. 주소찾기 API 추가 -->
              <input  class="frm_input addr_input" required placeholder="우편번호" type="text" name="zip"><button class="search_addr" type="button" onclick="openZipSearch()">주소찾기</button><br>
              <input  class="frm_input" required placeholder="주소" type="text" name="addr1"><br>
              <input class="frm_input" required type="text" name="addr2" placeholder="상세주소를 입력해 주세요" onfocus="this.placeholder=''" onblur="this.placeholder='상세주소를 입력해 주세요'">
            </td>
        </tr>
        <tr>
            <th scope="row" class="frm_tit"><label for="wr_5">연락처<strong class="sound_only">필수</strong></label><span class="smallest"> (-없이 숫자만 입력)</span></th>
            <td class="frm_con"><input type="text" name="wr_5" value="<?php echo $row['wr_5']; ?>" id="wr_5" required class="frm_input" size="10" maxlength="11" placeholder="ex) 01012345678" onfocus="this.placeholder=''" onblur="this.placeholder='ex) 01012345678'"></td>
        </tr>
        <tr>
            <th scope="row" class="frm_tit"><label for="wr_6">면접예정기업명<strong class="sound_only">필수</strong></label></th>
            <td class="frm_con"><input type="text" name="wr_6" value="<?php echo $row['wr_6']; ?>" id="wr_6" required class="frm_input" size="10" maxlength="20" placeholder="ex) 천안시2030행정복지센터" onfocus="this.placeholder=''" onblur="this.placeholder='ex) 천안시2030행정복지센터'"></td>
        </tr>
        <tr  class="addr_wrap">
            <th scope="row" class="frm_tit"><label for="wr_7">기업 소재지<strong class="sound_only">필수</strong></label></th>
            <td class="frm_con">
			        <!-- <input  class="frm_input" type="text" name="wr_7" value="<?php echo $row['wr_7']; ?>" id="wr_7" required class="frm_input" size="20" maxlength="40" placeholder="ex) 천안시 동남구 은행길 5-4 천안시2030청년복지센터" onfocus="this.placeholder=''" onblur="this.placeholder='ex) 천안시 동남구 은행길 5-4 천안시2030청년복지센터'"><br> -->
              <!-- 2022.02.28. 주소찾기 API 추가 -->
              <input  class="frm_input addr_input" required placeholder="우편번호" type="text" name="zip02"><button class="search_addr" type="button" onclick="openZipSearch02()">주소찾기</button><br>
              <input  class="frm_input" required placeholder="주소" type="text" name="addr3"><br>
              <input  class="frm_input" required type="text" name="addr4" placeholder="상세주소를 입력해 주세요" onfocus="this.placeholder=''" onblur="this.placeholder='상세주소를 입력해 주세요'">
                  
            </td>
        </tr>


        <!-- <?php
		for ($i=0; $is_file && $i<$file_count; $i++) {
			if($i==0) {
				$bf_title	= "<div class='txt_wrap'><p class='title'>신분증 사본 및 초본</p><p>* 1) 천안소재 학교 재학생의 경우 학생증 및 재학증명서 제출<br>* 2) 검정고시 졸업자의 경우 검정고시 졸업증명서로 제출</p></div>";
			} else {
				$bf_title	= "<p class='title title02'>면접수험표 (혹은 면접예정임을 증명할 수 있는 자료)</p>";
			}
		?>
        <tr>
            <th scope="row" class="frm_tit"><label>신청서류 </label><?php echo $i+1 ?></th>
            <td class="frm_con">
                <input type="file" name="bf_file[]" id="bf_file<?php echo $i+1;?>" title="신청서류  <?php echo $i+1 ?> : 용량 <?php echo $upload_max_filesize ?> 이하만 업로드 가능" class="frm_file frm_input"><span class="smallest"> &nbsp;(신청서류는 jpg, jpeg, png, pdf 파일만 가능합니다.)</span><?php echo $bf_title;?>
                <?php if ($is_file_content) { ?>
                <input type="text" name="bf_content[]" value="<?php echo ($w == 'u') ? $file[$i]['bf_content'] : ''; ?>" title="파일 설명을 입력해주세요." class="frm_file frm_input" size="50">
                <?php } ?>
                <?php if($w == 'u' && $file[$i]['file']) { ?>
                <input type="checkbox" id="bf_file_del<?php echo $i ?>" name="bf_file_del[<?php echo $i;  ?>]" value="1"> <label for="bf_file_del<?php echo $i ?>"><?php echo $file[$i]['source'].'('.$file[$i]['size'].')';  ?> 파일 삭제</label>
                <?php } ?>
            </td>
        </tr>
        <?php } ?> -->


        <?php if ($is_guest) { //자동등록방지  ?>
        <tr>
            <th scope="row" class="frm_tit">자동등록방지</th>
            <td class="frm_con">
                <?php echo $captcha_html ?>
            </td>
        </tr>
        <?php } ?>

        </tbody>
        </table>

        <p class="t_tit tit_second">
        <em>정장대여 장소 선택</em><br>
          * 장소 선택 후 변경이 불가능하므로 신중히 선택해주세요.
        </p>

        <table>
          <thead></thead>
          <tbody>
            <tr>
              <th scope="row" class="frm_tit"><label for="c_check">정장 지점 선택<strong class="sound_only">필수</strong></label></th>
              <td class="cloth_choose">
                <input type="radio" name="wr_8" value="슈트갤러리(신부동)" required id="c_check_01" <?php if($row['wr_8'] == "슈트갤러리(신부동)") { echo "checked"; } ?>><label for="c_check_01">&nbsp;슈트갤러리(신부동)</label><span>충청남도 천안시 동남구 중앙로 243, 101호(신부동, 더 플라츠)</span><br>
                <input type="radio" name="wr_8" value="스플랜디노(불당동)" required id="c_cehck_02" <?php if($row['wr_8'] == "스플랜디노(불당동)") { echo "checked"; } ?>><label for="c_cehck_02"> 스플랜디노(불당동)</label><span>충청남도 천안시 불당 15길 7, 1층</span>
              </td>
            </tr>

        <!-- 2022.02.03. 개인정보 이용동의 추가 -->
        <tr>
          <th scope="row" class="frm_tit"><label for="p_check">개인정보 수집 및 이용동의<strong class="sound_only">필수</strong></label></th>
          <td class="frm_con">
            <textarea name="" id="" cols="30" rows="10" readonly>
1. 개인정보 수집, 이용목적
  - 천안시2030청년복지센터 면접 스타일링 지원사업 추진을 목적으로 수집됩니다.
2. 개인정보 수집범위 : 성명, 생년월일/성별, 연락처, 이메일, 주소, 소속(대학교)
3. 개인정보 보존기간 : 5년
4. 동의거부 및 동의거부 시 불이익 내용
  - 개인정보 수집 동의를 하지 않을 경우 면접 스타일링 지원 서비스가 어렵습니다.
  - 개인정보는 면접스타일링 지원 관련 이외의 다른 목적으로 사용하지 않습니다.
          </textarea>
          <div class="p_info">
            <input type="radio" id="p_check01" name="p_check" value="yes"><label for="p_check01"> 동의</label>
            <input type="radio" id="p_check02" name="p_check" value="no"><label for="p_check02"> 비동의</label><span>(비동의시 사업 신청 불가)</span>
          </div>
        </td>
        </tr>
        
          </tbody>
        </table>
    </div>

    <div class="page_btn">
      <ul>
          <li><a class="prev" href="/lmth/08_job/job_info01.php">&lt; 이전페이지</a></li>
		  <?php
		  //중요.. 디비에 값이 등록되 있으면 업데이트(by nogada,220217)
		  if($row['wr_id']) { echo "<input type='hidden' name='w' value='u'><input type='hidden' name='wr_id' value='{$ck_rent_wr_id}'>"; }
		  ?>
		  <li><button type="submit" id="btn_submit" class="next">다음페이지 &gt;</button></li>
      </ul>
 </div>

    <!-- <div class="btn_confirm">
        <input type="submit" value="작성완료" id="btn_submit" accesskey="s" class="btn_submit">
        <a href="./board.php?bo_table=<?php echo $bo_table ?>" class="btn_cancel">취소</a>
    </div> -->
    </form>

    <script src="//t1.daumcdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js"></script>

    <script>
      // 주소 찾기
      function openZipSearch() {
	    new daum.Postcode({
		oncomplete: function(data) {
			$('[name=zip]').val(data.zonecode); // 우편번호 (5자리)
			$('[name=addr1]').val(data.address);
			$('[name=addr2]').val(data.buildingName);
		}
	}).open();
}

// 주소 찾기2
function openZipSearch02() {
	    new daum.Postcode({
		oncomplete: function(data) {
			$('[name=zip02]').val(data.zonecode); // 우편번호 (5자리)
			$('[name=addr3]').val(data.address);
			$('[name=addr4]').val(data.buildingName);
		}
	}).open();
}



      let uniCheck = document.querySelector('.univer');
      let uniInput = document.querySelector('.wr_facebook_user')
      let uniCheckAll = document.querySelectorAll('.university label .frm_input');
          console.log(uniCheckAll)

          // 대학교 재학을 체크가 되면 학교명 인풋박스에 필수 속성을 더한다.
          uniCheck.addEventListener('change', function(){
            console.log(this.value)
            if(this.value == "대학교 재학"){
              uniInput.setAttribute('required', 'required')
            }

          })

          // 대학교 재학이 아닌 다른 체크박스에 체크가 된다면 학교명 인풋박스에 필수 속성을 제거한다.
          uniCheckAll.forEach(function(e){
            e.addEventListener('change', function(){
                console.log(this.value)
                if(this.value == '검정고시 졸업' || '대학교 졸업' || '고등학교 졸업(예정자포함)'){
                  uniInput.removeAttribute('required')
                }
              })
            })



    </script>

    <script>
    <?php if($write_min || $write_max) { ?>
    // 글자수 제한
    var char_min = parseInt(<?php echo $write_min; ?>); // 최소
    var char_max = parseInt(<?php echo $write_max; ?>); // 최대
    check_byte("wr_content", "char_count");

    $(function() {
        $("#wr_content").on("keyup", function() {
            check_byte("wr_content", "char_count");
        });
    });

    <?php } ?>
    function html_auto_br(obj)
    {
        if (obj.checked) {
            result = confirm("자동 줄바꿈을 하시겠습니까?\n\n자동 줄바꿈은 게시물 내용중 줄바뀐 곳을<br>태그로 변환하는 기능입니다.");
            if (result)
                obj.value = "html2";
            else
                obj.value = "html1";
        }
        else
            obj.value = "";
    }

    function fwrite_submit(f)
    {
        <?php echo $editor_js; // 에디터 사용시 자바스크립트에서 내용을 폼필드로 넣어주며 내용이 입력되었는지 검사함   ?>

        var subject = "";
        var content = "";
        $.ajax({
            url: g5_bbs_url+"/ajax.filter.php",
            type: "POST",
            data: {
                "subject": f.wr_subject.value,
                "content": f.wr_content.value
            },
            dataType: "json",
            async: false,
            cache: false,
            success: function(data, textStatus) {
                subject = data.subject;
                content = data.content;
            }
        });

        if (subject) {
            alert("제목에 금지단어('"+subject+"')가 포함되어있습니다");
            f.wr_subject.focus();
            return false;
        }

        if (content) {
            alert("내용에 금지단어('"+content+"')가 포함되어있습니다");
            if (typeof(ed_wr_content) != "undefined")
                ed_wr_content.returnFalse();
            else
                f.wr_content.focus();
            return false;
        }

		<?php /* ?>
        if (document.getElementById("char_count")) {
            if (char_min > 0 || char_max > 0) {
                var cnt = parseInt(check_byte("wr_content", "char_count"));
                if (char_min > 0 && char_min > cnt) {
                    alert("내용은 "+char_min+"글자 이상 쓰셔야 합니다.");
                    return false;
                }
                else if (char_max > 0 && char_max < cnt) {
                    alert("내용은 "+char_max+"글자 이하로 쓰셔야 합니다.");
                    return false;
                }
            }
        }
		<?php */ ?>

        <?php //echo $captcha_js; // 캡챠 사용시 자바스크립트에서 입력된 캡챠를 검사함  ?>

		var p_check = $('input[name="p_check"]:checked').val();
		if(p_check != 'yes') {
			alert('개인정보 수집 및 이용에 동의하셔야 신청 할 수 있습니다.');
			return false;
		}

        document.getElementById("btn_submit").disabled = "disabled";

        return true;
    }
    </script>
</section>
<!-- } 게시물 작성/수정 끝 -->
