<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가

//////경매정보///////
include_once("$board_skin_path/auction.lib.php");
//////경매정보///////

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


//////경매정보///////
$s = isset($_REQUEST['s']) ? $_REQUEST['s'] : '';
$pcnum = isset($_REQUEST['pcnum']) ? $_REQUEST['pcnum'] : '';
$stat = isset($_REQUEST['stat']) ? $_REQUEST['stat'] : '';

if ($w == '') {

    // 관리자여도 입찰이 진행중인 경매라는 사실을 알려줘서 관리에 참고토록 함 JSLEE
    $admin_warning_msg = "<br>※ 내용확인 후 신규등록 버튼을 누르기 전까지는 적용되지 않습니다.";

    //////품번//////
    $write[pcnum] = $pcnum;

    /////하드웨어 스텍/////
    $sql_rt_now = " select * from `smart_rental_comspec` where no='{$pcnum}' order by no desc limit 1 ";
    $res_rt_now = sql_query($sql_rt_now);

    for($k=0; $row_rt_now=sql_fetch_array($res_rt_now); $k++) {

        // 서버위치
        $storename = $row_rt_now['M_storename'];

        // 서버실ID
        $storeid = $row_rt_now['M_storeid'];

        // 추천
        $purpose = preg_replace("/Œ/", ",", mb_substr($row_rt_now['purpose'],0,-1,'utf8'), 999999);

        // 운영체제
        $OperatingSystem = $row_rt_now['OperatingSystem'];
        $OperatingSystem = trim(str_replace("Microsoft","",$OperatingSystem));

        // CPU
        $CPU = "";
        $CpuName_arr = explode("Ž",$row_rt_now['CpuName']);
        if (count($CpuName_arr) > 1) {
            for ($i=0; $i<count($CpuName_arr); $i++) {
                if ($CpuName_arr[$i] == "") continue;
                if ($i==0) {
                    $CPU = ($i+1) . ") " . $CpuName_arr[$i];
                } else {
                    $CPU .=  " + " . ($i+1) . ") " . $CpuName_arr[$i];
                }
            }
        } else {
            $CPU = $CpuName_arr[0];
        }

        // RAM
        $RAM = $row_rt_now['RAM']."GB";

        // SSD
        $SSD = "";
        $SSDinfo = preg_replace("/SSD/", "",$row_rt_now['SSDinfo']);
        $SSDinfoArr = explode(",",$SSDinfo);
        $cnt=0;
        for ($i=0; $i<count($SSDinfoArr); $i++) {
            if ($SSDinfoArr[$i] == "") continue;
            if (strpos(strtoupper($SSDinfoArr[$i]),"SAMSUNG") === false) {
                $SSDinfoDispArr = explode(" ",trim($SSDinfoArr[$i]));
                if ($cnt==0) {
                    $SSD = trim($SSDinfoDispArr[0]);
                    $cnt++;
                } else {
                    $SSD .= " + " . trim($SSDinfoDispArr[0]);
                }
            } else {
                if ($cnt==0) {
                    $SSD = trim($SSDinfoArr[$i]);
                    $cnt++;
                } else {
                    $SSD .= " + " . trim($SSDinfoArr[$i]);
                }
            }
        }

        // HDD
        $HDD = "0GB";
        $HDDinfo = preg_replace("/HDD/", "",$smart_rental_comspec['HDDinfo']);
        $HDDinfoArr = explode(",",$HDDinfo);
        $cnt=0;
        for ($i=0; $i<count($HDDinfoArr); $i++) {
            if ($HDDinfoArr[$i] == "") continue;
            if (strpos(strtoupper($HDDinfoArr[$i]),"SAMSUNG") === false) {
                $HDDinfoDispArr = explode(" ",trim($HDDinfoArr[$i]));
                if ($cnt==0) {
                    $HDD = trim($HDDinfoDispArr[0]);
                    $cnt++;
                } else {
                    $HDD .= " + " . trim($HDDinfoDispArr[0]);
                }
            } else {

                if ($cnt==0) {
                    $HDD = trim($HDDinfoArr[$i]);
                    $cnt++;
                } else {
                    $HDD .= " + " . trim($HDDinfoArr[$i]);
                }
            }
        }

        // VideoController , GPU
        $VideoController = $row_rt_now['VideoController'];
        // if ($row_rt_now['gpu_ram']) {
        //     $VideoController .= " (" . $row_rt_now['gpu_ram'] . " GB)";
        // }

        // 게임
        $game_name = preg_replace("/Œ/", ",", mb_substr($row_rt_now['game_name'],0,-1,'utf8'), 999999);

        // 렌탈요금합계(렌탈료+세팅비)
        $rental_fee_total = (double)$row_rt_now['rental_fee'] + (double)$row_rt_now['rental_setting_fee'];

    }

    if ($k == 0) {
        alert("존재하지 않는 상품이거나 비정상적인 경로로 접속되었습니다.\\n매니저를 통하여 접속하여 주십시오.");
    }

    $tender_unit = "1000"; // [입찰금액단위] 1, 10, 100, 1000, 10000 ...
    $tender_method = "공개"; // [입찰방식] 공개, 비공개
    $auction_off_method = "최고가"; // [낙찰방식] 최저가, 최고가
    $tender_possible_count = $tender_possible_count; // [입찰참여횟수] 1 ~ 10
    $auction_off_member_count = "1"; // [낙찰위한 위한 최소 입찰자수] 1 ~
    $delivery_method = "기타"; // 배송방법
    $delivery_price = "0"; // 배송비용

    //$write[wr_1] = date("Y-m-d 00:00:00", G5_SERVER_TIME + 86400 * 1);  // 내일 0시부터 시작할 때
    $write[wr_1] = date("Y-m-d H:i:s", G5_SERVER_TIME); // 등록시 즉시 시작할 때
    $write[wr_2] = date("Y-m-d 12:00:00", strtotime($write[wr_1]) + 86400 * 1);//$write[wr_2] = date("Y-m-d H:i:s", strtotime($write[wr_1]) + 86400 * 7);

    //$write[wr_3] = $board[bo_1]; // 참여 포인트 기본값 - wr_3은 사용하면 안됨. 서버실ID로 대체했음
    $write[wr_3] = $storeid;

    //$write[wr_4] = $board[bo_2]; // 입찰 최소 포인트 기본값
    $write[wr_4] = floor($rental_fee_total * 0.3); // 입찰 최소 포인트 기본값
    //$write[wr_4] = "10000"; // 입찰 최소 포인트 기본값

    //$write[wr_5] = $board[bo_3]; // 입찰 최대 포인트 기본값
    $write[wr_5] = $rental_fee_total; // 입찰 최대 포인트 기본값

    //$write[wr_6] = $board[bo_4]; // 하루 참여 횟수 기본값
    $write[wr_6] = 10; // 하루 참여 횟수 기본값

    $write[wr_7] = "0";
    $write[wr_8] = "0";
    $tender_possible_count=20; //한사람 총 입찰참여 가능한 회수
    $auction_off_member_count=1;  //입찰 후 낙찰되기 위한 최소 입찰자 수(입찰횟수가 아니라 입찰한 사람(회원)수)
    //상품등록 가능한 포인터
    if ($member[mb_point] < $auction_possible_point) {alert("회원의 포인트가 {$auction_possible_point}점 이상이어야 포인트경매 상품등록이 가능합니다.");}
    //상품등록 가능한 포인터

    $auction_company = $storename; // 서버실위치
    if ($OperatingSystem=="" && $CPU=="" && $RAM=="" && $SSD=="" && $HDD=="" && $VideoController=="") {
        $auction_product = ""; // PC사양
    } else {
        $auction_product = "[OS]{$OperatingSystem} [CPU]{$CPU} [RAM]{$RAM} [SSD]{$SSD} [HDD]{$HDD} [GPU]{$VideoController}"; // PC사양
    }



} else if ($w == 'u') {////$w == 'u'


    if (!$is_admin) {////!$is_admin
        $sql = " select count(*) as cnt from $tender_table where wr_id = '$wr_id' ";
        $row = sql_fetch($sql);
        if ($row[cnt] >= $auction_impossible_modify){alert("입찰이 ".$auction_impossible_modify."회 이상이 존재하는 경매상품은 수정이 불가합니다.");}
    } else { ////!$
        $sql = " select count(*) as cnt from $tender_table where wr_id = '$wr_id' ";
        $row = sql_fetch($sql);
        if ($row[cnt] >= $auction_impossible_modify){alert_only_no_exit("입찰이 ".$auction_impossible_modify."회 이상이 존재하는 경매상품은 수정이 불가합니다.\\n관리자 권한인 경우 꼭 필요한 경우에만 수정하시기 바랍니다..");}
    }

    // 관리자여도 입찰이 진행중인 경매라는 사실을 알려줘서 관리에 참고토록 함 JSLEE
    $sql_warning = " select count(*) as cnt from $tender_table where wr_id = '$wr_id' ";
    $row_warning = sql_fetch($sql_warning);
    if ($row_warning[cnt] >= $auction_impossible_modify) {
        $admin_warning_msg = "<br>※ 입찰이 ".$auction_impossible_modify."회 이상이 존재하는 경매상품입니다.";
    }
    $admin_warning_msg .= "<br>※ 내용확인 후 수정등록 버튼을 누르기 전까지는 적용되지 않습니다.";

    //경매정보
    $info = get_info_auction($wr_id);
    //경매정보

    if ($info[status] == '2') {
        // 0: "시작전"
        // 1: "진행중"
        // 2: "종료[낙찰]"
        // 3: "종료[유찰]"
        if (!$is_admin) {
            alert(auction_status($info[status])."된 경매상품은 수정이 불가합니다.");
        } else {
            alert_only_no_exit(auction_status($info[status])."된 경매상품은 원칙적으로 수정이 불가합니다.\\n관리자 권한인 경우 꼭 필요한 경우에만 수정하시기 바랍니다.");
        }
        // 참고사항 : 위에서 입찰자가 있는지 체크해서 수정여부를 체크했므로, 여기서는 종료된 경매상품인지만 체크함
    }

    if ($info[status] == '3') {
        // 0: "시작전"
        // 1: "진행중"
        // 2: "종료[낙찰]"
        // 3: "종료[유찰]"
        if (!$is_admin) {
            alert(auction_status($info[status])."된 경매상품은 수정이 불가합니다.");
        } else {
            alert_only_no_exit(auction_status($info[status])."된 경매상품은 원칙적으로 수정이 불가합니다.\\n관리자 권한인 경우 꼭 필요한 경우에만 수정하시기 바랍니다.");
        }
        // 참고사항 : 위에서 입찰자가 있는지 체크해서 수정여부를 체크했므로, 여기서는 종료된 경매상품인지만 체크함
    }

    $auction_company = $info[company];
    $auction_product = $info[product];
    $tender_unit = $info[tender_unit];
    $tender_method = $info[tender_method];
    $auction_off_method = $info[auction_off_method];
    $tender_possible_count=$info[tender_possible_count];
    $auction_off_member_count = $info[auction_off_member_count];
    $delivery_method = $info[delivery_method];
    $delivery_price = $info[delivery_price];
}////$w == 'u'

    $tender_unit_list=explode("|",$board['bo_6']);//입찰금액단위 리스트
    $tender_method_list=explode("|",$board['bo_7']);//입찰방식 리스트
    $auction_off_method_list=explode("|",$board['bo_8']);//낙찰방식 리스트
    $delivery_method_list=explode("|",$board['bo_9']);//배송방법 리스트
    $delivery_price_list=explode("|",$board['bo_10']);//배송비용 리스트
//////경매정보///////
?>

<?php if ($s!="" && ($stat=="0" || $stat=="1") && $pcnum!="") { ?>
    <section id="bo_w" style="margin-top:30px;">
<?php } else { ?>
    <section id="bo_w">
<?php } ?>

<?php
    if ($s!="" && ($stat=="0" || $stat=="1") && $pcnum!="") {
        $readonly_flag = "readonly";
    } else {
        $readonly_flag = "readonly";
    }
?>

<?php
    $g5['title'] = str_replace(array("글쓰기","글수정"),array("등록","수정"),$g5['title']);
?>

    <h2 id="container_title" style="margin-bottom:20px;"><?php echo $g5['title'] ?>&nbsp;★&nbsp;품번 <?php echo $pcnum ?>&nbsp; &nbsp;<b style="color:red; font-size:0.8em;"><?php echo $admin_warning_msg;?></b><?php //echo "#####S=".$s;?><?php //echo "@@@stat=".$stat;?></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" id="wr_subject" value="<?php echo $write[wr_subject]?>" />
    <input type="hidden" name="wr_7" value="<?php echo $write[wr_7]?>" /> <!-- 입찰횟수 -->
    <input type="hidden" name="wr_8" value="<?php echo $write[wr_8]?>" /> <!-- 경매상태 -->
    <input type="hidden" name="wr_9" value="<?php echo $write[wr_9]?>" /> <!-- 낙찰포인터 -->
    <input type="hidden" name="wr_10" value="<?php echo $write[wr_10]?>" /> <!-- 낙찰회원 -->
    <input type="hidden" name="wr_pcnum" value="<?php echo $write[pcnum]?>" /> <!-- 품번 -->
    <!--//경매정보//-->

    <?php
    $option = '';
    $option_hidden = '';
    if ($is_notice || $is_html || $is_secret || $is_mail) {
        $option = '';
        if ($is_notice=0) {//$is_notice=0 -  처리
            $option .= "\n".'<input type="checkbox" id="notice" name="notice" value="1" '.$notice_checked.'>'."\n".'<label for="notice">공지</label>';
        }

        if ($is_html) {
            if ($is_dhtml_editor) {
                $option_hidden .= '<input type="hidden" value="html1" name="html">';
            } else {
                $option .= "\n".'<input type="checkbox" id="html" name="html" onclick="html_auto_br(this);" value="'.$html_value.'" '.$html_checked.'>'."\n".'<label for="html">html</label>';
            }
        }

        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;
    ?>

    <div class="tbl_frm01 tbl_wrap">
        <table>
        <tbody>
        <?php if ($is_name) { ?>
        <tr>
            <th scope="row"><label for="wr_name">이름<strong class="sound_only"> 필수</strong></label></th>
            <td><input type="text" name="wr_name" value="<?php echo $name ?>" id="wr_name" required class="frm_input required" size="10" maxLength="32"></td>
        </tr>
        <?php } ?>

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

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

        <?php if ($is_homepage) { ?>
        <tr>
            <th scope="row"><label for="wr_homepage">홈페이지</label></th>
            <td><input type="text" name="wr_homepage" value="<?php echo $homepage ?>" id="wr_homepage" class="frm_input" size="50"></td>
        </tr>
        <?php } ?>

        <?php if ($option) { ?>
        <tr style="display:none;">
            <th scope="row">옵션</th>
            <td><?php echo $option ?></td>
        </tr>
        <?php } ?>

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

        <!--//경매정보//-->
        <tr>
            <th scope="row"><label for="auction_company">서버실명<strong class="sound_only">필수</strong></label></th>
            <td>
            <input <?php echo $readonly_flag?> type="text" name="auction_company" value="<?php echo($auction_company);?>" id="auction_company" required class="frm_input required" size="50" maxlength="50" style="background:#eeeeee;"> &nbsp; ※ 서버실ID : <?php echo($write[wr_3]);?>
            </td>
        </tr>

        <!-- 참여포인터
        <tr>
            <th scope="row"><label for="wr_3">참여포인터<strong class="sound_only">필수</strong></label></th>
            <td><input type="number" name="wr_3" value="<?php echo($write[wr_3]);?>" id="wr_3" required class="frm_input required" size="15" step="1" min="0" max="10000"></td>
        </tr>
        참여포인터 -->

        <tr style="display:none;">
            <th scope="row"><label for="wr_3">서버실ID<strong class="sound_only">필수</strong></label></th>
            <td><input type="text" name="wr_3" value="<?php echo($write[wr_3]);?>" id="wr_3" required class="frm_input required" size="50" ></td>
        </tr>

        <tr>
            <th scope="row"><label for="auction_product">PC사양<strong class="sound_only">필수</strong></label></th>
            <td>
            <input type="text" name="auction_product" value="<?php echo($auction_product);?>" id="auction_product" required class="frm_input required" size="100%" maxlength="180" placeholder="자동으로 등록된 정보가 없습니다. 직접입력 해 주십시요." style="width:100%;">
            </td>
        </tr>

        <tr>
            <th scope="row"><label for="wr_1">경매시작일시<strong class="sound_only">필수</strong></label></th>
            <td>
            <input type="text" name="wr_1" value="<?php echo($write[wr_1]);?>" id="wr_1" required readonly  class="frm_input required" size="21" maxlength="19">&nbsp;&nbsp;&nbsp;
            &nbsp;날짜&nbsp;<select name="wr_1_list" id="wr_1_list"  onchange="this.form.wr_1.value=this.value;" class="frm_input">
                    <option value="<?php echo($write[wr_1]);?>">선택하세요</option>
                    <?php
                        if($is_admin){?><option value="<?php echo(date("Y-m-d H:i:s", G5_SERVER_TIME));?>">현재시각</option>
                    <?php } else { ?>
                        <option value="<?php echo(date("Y-m-d H:i:s", G5_SERVER_TIME));?>">현재시각</option>
                    <?php } ?>
                    <option value="<?php echo(date("Y-m-d 00:00:00", G5_SERVER_TIME));?>">오늘0시</option>
                    <option value="<?php echo(date("Y-m-d 00:00:00", G5_SERVER_TIME+43200));?>">오늘12시</option>
                    <?php for($i=1;$i<=30;$i++){?>
                    <option value="<?php echo(date("Y-m-d 00:00:00", G5_SERVER_TIME+86400*${i}));?>">+<?php echo($i."일");?></option>
                    <?php } ?>
                </select>

            &nbsp;시간&nbsp;<select name="wr_1_list_time" id="wr_1_list_time" onchange="end_hour(this.form.wr_1,this.form.wr_1_list_time_30,this.value);" class="frm_input">
                    <option value="0">선택하세요</option>
                    <option value="0">0시</option>
                    <?php for($i=1;$i<=23;$i++){?>
                    <option value="<?php echo($i);?>"><?php echo($i."시");?></option>
                    <?php } ?>
                </select>
            <input type="checkbox" name="wr_1_list_time_30" id="wr_1_list_time_30" value="30" onchange="end_hour(this.form.wr_1,this,this.form.wr_1_list_time.value);">&nbsp;30분
            </td>
        </tr>

        <tr>
            <th scope="row"><label for="wr_2">경매종료일시<strong class="sound_only">필수</strong></label></th>
            <td>
            <input type="text" name="wr_2" value="<?php echo($write[wr_2]);?>" id="wr_2" required readonly class="frm_input required" size="21" maxlength="19">&nbsp;&nbsp;&nbsp;
            &nbsp;날짜&nbsp;<select name="wr_2_list_date" id="wr_2_list_date" onchange="end_date(this.form.wr_1,this.form.wr_2,this.value);" class="frm_input">
                    <option value="0">선택하세요</option>
                    <option value="0">오늘</option>
                    <?php for($i=0;$i<=60;$i++){?>
                    <option value="<?php echo($i);?>">+<?php echo($i."일");?></option>
                    <?php } ?>
                </select>

            &nbsp;시간&nbsp;<select name="wr_2_list_time" id="wr_2_list_time"  onchange="end_hour(this.form.wr_2,this.form.wr_2_list_time_30,this.value);" class="frm_input">
                    <option value="0">선택하세요</option>
                    <option value="0">0시</option>
                    <?php for($i=1;$i<=23;$i++){?>
                    <option value="<?php echo($i);?>"><?php echo($i."시");?></option>
                    <?php } ?>
                </select>
            <input type="checkbox" name="wr_2_list_time_30" id="wr_2_list_time_30" value="30" onchange="end_hour(this.form.wr_2,this,this.form.wr_2_list_time.value);">&nbsp;30분
            </td>
        </tr>

        <tr>
            <th scope="row"><label for="tender_unit">입찰금액 단위<strong class="sound_only">필수</strong></label></th>
            <td>
                <select name="tender_unit" id="tender_unit" required class="frm_input required" onchange="this.form.wr_4.step=this.value;this.form.wr_5.step=this.value;">
                    <option value="">선택하세요</option>
                <?php
                      for($i=0;$i<count($tender_unit_list);$i++){
                        if($tender_unit_list[$i]==$tender_unit){$selected="selected";}else{$selected="";}
                ?>
                    <option value="<?php echo($tender_unit_list[$i]);?>" <?php echo($selected);?>><?php echo(number_format($tender_unit_list[$i]));?></option>
                <?php } ?>
                </select>&nbsp;Point&nbsp;단위
                <br><span style="color:red;">※ 입찰금액 단위로 </span><span style="color:blue;">입찰금액과, 입찰</span>은 이루어집니다.
            </td>
        </tr>

        <tr>
            <th scope="row"><label for="tender_method">입찰방식<strong class="sound_only">필수</strong></label></th>
            <td>
                <select name="tender_method" id="tender_method" required class="frm_input required">
                    <option value="">선택하세요</option>
                <?php
                      for($i=0;$i<count($tender_method_list);$i++){
                        if($tender_method_list[$i]==$tender_method){$selected="selected";}else{$selected="";}
                ?>
                    <option value="<?php echo($tender_method_list[$i]);?>" <?php echo($selected);?>><?php echo($tender_method_list[$i]);?></option>
                <?php } ?>
                </select>
                <br><span style="color:red;">※ 비공개 : </span>경매 진행중 입찰 정보<span style="color:blue;">[입찰자, 입찰금액]을 "*****"</span>로 나타냅니다.
            </td>
        </tr>

        <tr>
            <th scope="row"><label for="auction_off_method">낙찰방식<strong class="sound_only">필수</strong></label></th>
            <td>
                <select name="auction_off_method" id="auction_off_method" required class="frm_input required" onchange='if(this.value=="최고가"){document.getElementById("lower_label").innerHTML="시작가";document.getElementById("higher_label").innerHTML="상한가";} else {document.getElementById("lower_label").innerHTML="하한가";document.getElementById("higher_label").innerHTML="시작가";}'>
                    <option value="">선택하세요</option>
                <?php
                      for($i=0;$i<count($auction_off_method_list);$i++){
                        if($auction_off_method_list[$i]==$auction_off_method){$selected="selected";}else{$selected="";}
                ?>
                    <option value="<?php echo($auction_off_method_list[$i]);?>" <?php echo($selected);?>><?php echo($auction_off_method_list[$i]);?></option>
                <?php } ?>
                </select>
            </td>
        </tr>

        <tr>
            <th scope="row"><label for="wr_4 wr_5">입찰금액<strong class="sound_only">필수</strong></label></th>
            <td>
            <span id="lower_label" style="color:green;">시작가</span>&nbsp;<input type="number" name="wr_4" value="<?php echo($write[wr_4]);?>" id="wr_4" required  class="frm_input required" size="15" step="<?php echo($tender_unit);?>" min="0" max="100000000">
            &nbsp;~&nbsp;
            <span id="higher_label" style="color:green;">상한가</span>&nbsp;<input type="number" name="wr_5" value="<?php echo($write[wr_5]);?>" id="wr_5" required  class="frm_input required" size="15" step="<?php echo($tender_unit);?>" min="0" max="100000000">&nbsp;Point
            <br><br><span style="color:red;">※ 최고가 낙찰</span><span style="color:blue;">[최고 입찰금액 낙찰]</span>
            <br>- 시작가 : 반드시 0 보다 크야 합니다, 입찰 시작가(최소가)
            <br>- 상한가 : 0 보다 크면 "시작가 ~ 상한가" 범위에서 입찰 가능, 0 이면 상한 한계값이 없이 입찰 가능
            <br><br><span style="color:red;">※ 최저가 낙찰</span><span style="color:blue;">[최저 입찰금액 낙찰]</span>
            <br>- 하한가 : 0 보다 크면 "하한가 ~ 시작가" 범위에서 입찰 가능, 0 이면 하한가(한계값)이 없이 입찰 가능
            <br>- 시작가 : 반드시 0 보다 크야 합니다, 입찰 시작가(최대가)
            <br><br><span style="color:red;">※ 입찰 금액은 반드시 0보다 커야 합니다.</span>
            </td>
        </tr>

        <tr>
            <th scope="row"><label for="tender_possible_count">입찰 참여회수<strong class="sound_only">필수</strong></label></th>
            <td>
            <input type="number" name="tender_possible_count" value="<?php echo($tender_possible_count);?>" id="tender_possible_count" required class="frm_input required" size="15" step="1" min="1" max="100">&nbsp;회 제한
            <br>※ 이 경매에 대하여 한사람이 참여할 수 있는 입찰 가능 수를 입력합니다.
            </td>
        </tr>

        <tr>
            <th scope="row"><label for="wr_6">하루 참여횟수<strong class="sound_only">필수</strong></label></th>
            <td>
            <input type="number" name="wr_6" value="<?php echo($write[wr_6]);?>" id="wr_6" required class="frm_input required" size="15" step="1" min="1" max="100">&nbsp;회 제한
            <br>※ 이 경매에 대하여 한사람이 하루에 참여할 수 있는 입찰 가능 수를 입력합니다.
            </td>
        </tr>

        <tr>
            <th scope="row"><label for="auction_off_member_count">낙찰확정 위한<br>최소 입찰자수<strong class="sound_only">필수</strong></label></th>
            <td>
            <input type="number" name="auction_off_member_count" value="<?php echo($auction_off_member_count);?>" id="auction_off_member_count" required class="frm_input required" size="15" step="1" min="1" max="100">&nbsp;명
            <br>※ 이 경매에 대하여 낙찰확정 위한 최소 입찰자 수를 입력합니다.
            <br>※ 입찰자 수가 입력된 값보다 미만일 때는 유찰됩니다. (예: 최소입찰자수가 2로 설정되어 있는데 입찰자수가 1명뿐인 경우에는 유찰됨)
            </td>
        </tr>

        <tr style="display:none;">
            <th scope="row"><label for="delivery_method">배송방법<strong class="sound_only">필수</strong></label></th>
            <td>
                <select name="delivery_method" id="delivery_method" required class="frm_input">
                    <option value="">선택하세요</option>
                <?php
                      for($i=0;$i<count($delivery_method_list);$i++){
                        if($delivery_method_list[$i]==$delivery_method){$selected="selected";}else{$selected="";}
                ?>
                    <option value="<?php echo($delivery_method_list[$i]);?>" <?php echo($selected);?>><?php echo($delivery_method_list[$i]);?></option>
                <?php } ?>
                </select>
            </td>
        </tr>

        <tr style="display:none;">
            <th scope="row"><label for="delivery_price">배송비용<strong class="sound_only">필수</strong></label></th>
            <td>
            <input type="text" name="delivery_price" value="<?php echo($delivery_price);?>" id="delivery_price" required class="frm_input required"  size="30" step="1">&nbsp;Point&nbsp;&nbsp;&nbsp;

                <select name="delivery_price_list" id="delivery_price_list" onchange="this.form.delivery_price.value=this.value;" class="frm_input">
                    <option value="">선택하세요(직접입력)</option>
                <?php
                      for($i=0;$i<count($delivery_price_list);$i++){
                        if($delivery_price_list[$i]==$delivery_price){$selected="selected";}else{$selected="";}
                ?>
                    <option value="<?php echo($delivery_price_list[$i]);?>" <?php echo($selected);?>><?php echo(number_format($delivery_price_list[$i]));?></option>
                <?php } ?>
                <option value="0" selected>0</option>
                </select>&nbsp;※&nbsp;배송비용이 없을 때는 직접입력하세요.
            </td>
        </tr>
        <!--//경매정보//-->
        <tr style="display:none;">
            <th scope="row"><label for="wr_content">내용<strong class="sound_only">필수</strong></label></th>
            <td class="wr_content">
                <?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 로 노출 ?>
                <textarea name="wr_content" id="wr_content">ABCDEFGHIJKLMNOPQRSTUVWXYZ</textarea>
                <?php if($write_min || $write_max) { ?>
                <!-- 최소/최대 글자 수 사용 시 -->
                <div id="char_count_wrap"><span id="char_count"></span>글자</div>
                <?php } ?>
            </td>
        </tr>
<!--//경매정보//-->
<?php
$link_title[1]="업체 URL";$link_title[2]="상품 URL";
$link_title_explain[1]="홍보하시려는 회사의 주소(URL)를 입력하세요.";
$link_title_explain[2]="홍보하시려는 상품의 주소(URL)를 입력하세요.";
?>
<!--//경매정보//-->
        <?php for ($i=1; $is_link && $i<=count($link_title); $i++) { ?>
        <tr style="display:none;">
            <th scope="row"><label for="wr_link<?php echo $i ?>"><?php echo($link_title[$i]);?></label></th>
            <td>
            <input type="text" name="wr_link<?php echo $i ?>" value="<?php if($w=="u"){echo$write['wr_link'.$i];} ?>" id="wr_link<?php echo $i ?>" class="frm_input" size="50">
            <br><?php echo($link_title_explain[$i]);?>
            </td>
        </tr>
        <?php } ?>

<!--//경매정보//-->
<?php
$file_title[1]="목록 이미지";$file_title[2]="내용 이미지";
$file_title_explain[1]="목록 이미지 사이즈 ${board[bo_gallery_width]}px x ${board[bo_gallery_height]}px 정도";
$file_title_explain[2]="게시판에 출력되는 이미지 폭 사이즈 ${board[bo_image_width]}px 정도";
?>
<!--//경매정보//-->
        <?php for ($i=0; $is_file && $i<$file_count; $i++) { ?>
        <tr style="display:none;">
            <th scope="row"><?php echo($file_title[$i+1]);?></th>
            <td>
                <input type="file" name="bf_file[]" title="파일첨부 <?php echo $i+1 ?> :  용량 <?php echo $upload_max_filesize ?> 이하만 업로드 가능" class="frm_file frm_input">
                <?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 } ?>
                <br><?php echo($file_title_explain[$i+1]);?>
            </td>
        </tr>
        <?php } ?>

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

        </tbody>
        </table>
    </div>

    <div class="btn_confirm" style="margin-bottom:50px;">
        <?php if ($s=="") { ?>
            <input type="submit" value="수정등록" id="btn_submit" accesskey="s" class="btn_submit btn">
        <?php } else { ?>
            <input type="submit" value="신규등록" id="btn_submit" accesskey="s" class="btn_submit btn">
        <?php } ?>
        <!-- <a href="./board.php?bo_table=<?php echo $bo_table ?>" class="btn_cancel btn">취소</a> -->
        <?php if ($s=="") { ?>
            <a href="./board.php?bo_table=<?php echo $bo_table ?>&s=<?php echo $s?>&pcnum=<?php echo $pcnum?>" class="btn_b01 btn">목록</a>
        <?php } ?>
    </div>
    </form>

    <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 wr_4 = parseInt(f.wr_4.value); //입찰시작가
    var wr_5 = parseInt(f.wr_5.value); //입찰최대가

    var auction_company = f.auction_company.value.replace("/|/gi", "/");
    var auction_product = f.auction_product.value.replace("/|/gi", "/");
    var tender_unit = f.tender_unit.value.replace("/|/gi", "");//정수형
    var tender_method = f.tender_method.value.replace("/|/gi", "/");
    var auction_off_method = f.auction_off_method.value.replace("/|/gi", "/");
    var tender_possible_count = f.tender_possible_count.value.replace("/|/gi", "/");
    var auction_off_member_count = f.auction_off_member_count.value.replace("/|/gi", "/");
    var delivery_method = f.delivery_method.value.replace("/|/gi", "/");
    var delivery_price = f.delivery_price.value.replace("/|/gi", "");//정수형

    // 입찰금액 단위 확인
    if (wr_4 < 0){alert(document.getElementById("lower_label").innerHTML + " 금액은 " + " 0보다 크거나 같아야 합니다."); f.wr_4.focus(); return false;}
    if (wr_5 < 0){alert(document.getElementById("higher_label").innerHTML + " 금액은 " + " 0보다 크거나 같아야 합니다."); f.wr_5.focus(); return false;}

    if (auction_off_method=="최고가" && wr_4 <= 0){alert(document.getElementById("lower_label").innerHTML + " 금액은 " + " 0보다 크야 합니다."); f.wr_4.focus(); return false;}
    if (auction_off_method=="최저가" && wr_5 <= 0){alert(document.getElementById("higher_label").innerHTML + " 금액은 " + " 0보다 크야 합니다."); f.wr_5.focus(); return false;}

    if (wr_4 > 0 && wr_5 > 0){if(wr_4 >= wr_5){alert(document.getElementById("higher_label").innerHTML + " 금액은 " + document.getElementById("lower_label").innerHTML + " 금액보다 크야 합니다."); f.wr_4.focus(); return false;}}

    if ((wr_4 % parseInt(tender_unit)) != 0){alert(document.getElementById("lower_label").innerHTML + " 금액은 " + tender_unit +" 단위로 입력해주세요."); f.wr_4.focus(); return false;}
    if ((wr_5 % parseInt(tender_unit)) != 0){alert(document.getElementById("higher_label").innerHTML + " 금액은 " + tender_unit +" 단위로 입력해주세요."); f.wr_5.focus(); return false;}
    // 입찰금액 단위 확인

    var sum_subject = auction_company + "|" + auction_product + "|" + tender_unit + "|" + tender_method + "|" + auction_off_method + "|" + tender_possible_count + "|" + auction_off_member_count + "|" + delivery_method + "|" + delivery_price;
    document.getElementById("wr_subject").value = sum_subject;
////경매 정보////

        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;
        }

        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 echo $captcha_js; // 캡챠 사용시 자바스크립트에서 입력된 캡챠를 검사함  ?>

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

        return true;
    }

////경매 정보////
function end_date(wr_1,wr_2,day) { //wr_1-기준, wr_2-변경할 객체
    var tmp = wr_1.value.split(" ");
    var date = tmp[0].split("-");
    var time = tmp[1].split(":");

    var yyyy = date[0];
    var mm = --date[1];
    var dd = Number(date[2]) + Number(day);
    var hh = Number(date[3]) + Number(day);
    var ii = Number(date[4]) + Number(day);
    var ss = Number(date[5]) + Number(day);

    var hh = time[0];
    var ii = time[1];
    var ss = time[2];

    oDate = new Date(yyyy, mm, dd)

    yyyy = oDate.getFullYear();
    mm = oDate.getMonth() + 1;
    dd = oDate.getDate();

    if (String(mm).length == 1) mm = "0" + mm;
    if (String(dd).length == 1) dd = "0" + dd;

    wr_2.value = yyyy + "-" + mm + "-" + dd + " " + hh + ":" + ii + ":" + ss;
}

function end_hour(wr,wr_30,hour) {//wr-변경할 객체, wr_30-30분단위 체크
    hour=parseInt(hour)<10?'0'+hour:hour;

    if(wr_30.checked)
    {wr.value = wr.value.substring(0,10) + ' ' + hour + ':30:00';}
    else
    {wr.value = wr.value.substring(0,10) + ' ' + hour + ':00:00';}
}
////경매 정보////
    </script>
</section>
<!-- } 게시물 작성/수정 끝 -->