<?
$sub_menu = "200900";
include_once("./_common.php");

auth_check($auth[$sub_menu], "w");

$token = get_token();

$html_title = "투표";
if ($w == "")
    $html_title .= " 생성";
else if ($w == "u")  {
    $html_title .= " 수정";
    $sql = " select * from $g4[poll_table] where po_id = '$po_id' ";
    $po = sql_fetch($sql);
} else 
    alert("w 값이 제대로 넘어오지 않았습니다."); 

$g4[title] = $html_title;
include_once("./admin.head.php");
?>

<style>
table tr td	{ color:#414141; }
table tr td input	{ color:#3C3D3E; font-family:Dotum; padding:3px; }
table tr td textarea	{ color:#3C3D3E; font-family:Dotum; padding:3px; line-height:160%; }
table tr td.col1	{ padding:3px; color:#71777F; font-weight:bold; }
table tr td.col2	{ padding:5px; color:#868687; }
div.msg		{ font:normal 11px Dotum; padding:4px; }
</style>


<?=subtitle($html_title)?>
<div class="subtitle_msg"></div>

<form name=fpoll method=post onsubmit="return fpoll_check(this);" enctype="multipart/form-data">
<input type=hidden name=po_id value='<?=$po_id?>'>
<input type=hidden name=w     value='<?=$w?>'>
<input type=hidden name=sfl   value='<?=$sfl?>'>
<input type=hidden name=stx   value='<?=$stx?>'>
<input type=hidden name=sst   value='<?=$sst?>'>
<input type=hidden name=sod   value='<?=$sod?>'>
<input type=hidden name=page  value='<?=$page?>'>
<input type=hidden name=token value='<?=$token?>'>
<table width=100% cellpadding=0 cellspacing=0>
<colgroup width=15%>
<colgroup width=35%>
<colgroup width=15%>
<colgroup width=35%>
<tr>
    <td class="col1">투표 제목</td>
    <td class="col2" colspan=3><input type='text' class=ed name='po_subject' style='width:99%;' required itemname='투표 제목' value='<?=$po[po_subject]?>' maxlength="125"></td>
</tr>

<? 
for ($i=1; $i<=9; $i++) {
    $required = "";
    $itemname = "";
    if ($i==1 || $i==2) {
        $required = "required";
        $itemname = "itemname='항목$i'";
    }

    $po_poll = get_text($po["po_poll".$i]);

    echo <<<HEREDOC
    <tr>
        <td class='col1'>항목{$i}</td>
        <td class='col2'><input type="text" class=ed name="po_poll{$i}" {$required} {$itemname} value="{$po_poll}" style="width:90%;" maxlength="125"></td>
        <td class='col1'>투표수</td>
        <td class='col2'><input type="text" class=ed name="po_cnt{$i}" size=5 value="{$po["po_cnt".$i]}"></td>
        
    </tr>
HEREDOC;
} 
?>

<tr>
    <td class="col1">기타의견</td>
    <td class="col2" colspan=3><input type='text' class=ed name='po_etc' style='width:99%;' value='<?=get_text($po[po_etc])?>' maxlength="125"></td>
</tr>

<tr>
    <td class="col1">투표권한</td>
    <td class="col2" colspan=3><?=get_member_level_select("po_level", 1, 10, $po[po_level])?>이상 투표할 수 있음</td>
</tr>

<tr>
    <td class="col1">포인트</td>
    <td class="col2" colspan=3><input type='text' class=ed name='po_point' size='12' value='<?=$po[po_point]?>'> 점 (투표한 회원에게 부여함)</td>
</tr>


<? if ($w == "u") { ?>
<tr>
    <td class="col1">투표시작일</td>
    <td class="col2" colspan=3><input type="text" class=ed name="po_date" size=12 maxlength=10 value="<?=$po[po_date]?>"></td>
</tr>

<tr>
    <td class="col1">투표참가 IP</td>
    <td class="col2" colspan=3><textarea class=ed name="po_ips" rows=10 style='width:99%;' readonly><?=preg_replace("/\n/", " / ", $po[po_ips])?></textarea></td>
</tr>

<tr>
    <td class="col1">투표참가 회원</td>
    <td class="col2" colspan=3><textarea class=ed name="mb_ids" rows=10 style='width:99%;' readonly><?=preg_replace("/\n/", " / ", $po[mb_ids])?></textarea></td>
</tr>

<? } ?>
</table>

<p align=center>
    <input type=submit class=bttn_adj accesskey='s' value='확인'>&nbsp;
    <input type=button class=bttn_common value='목록' onclick="document.location.href='./poll_list.php?<?=$qstr?>';">
</form>

<script type='text/javascript'>
function fpoll_check(f)
{
    f.action = './poll_form_update.php';
    return true;
}
</script>

<?
include_once("./admin.tail.php");
?>
