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

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

<!-- 설문조사 결과 시작 { -->
<div class="card border-primary mb-3 w-100">
  <div class="card-header bg-primary text-white text-center border-primary"><h6 class="w-100"><i class="fa fa-bar-chart" aria-hidden="true"></i> <?php echo $g5['title'] ?> <span class="float-right"><button type="button" onclick="window.close();" class="btn_close">창닫기</button></span></h6></div>
  <div class="card-body text-dark">
    <h6 class="text-right"><span class="badge badge-secondary">전체 <?php echo $nf_total_po_cnt ?>표</span></h6>
    <h5 class="card-title"><?php echo $po_subject ?> 결과</h5>


      <?php for ($i=1; $i<=count($list); $i++) {  ?>
        <div class="m-1 border-bottom bg-light">
        <span><?php echo $list[$i]['content'] ?>(<?php echo $list[$i]['cnt'] ?> 표)</span><br>
        <div class="progress-bar" role="progressbar" style="width: <?php echo number_format($list[$i]['rate'], 1) ?>%;" aria-valuenow="<?php echo number_format($list[$i]['rate'], 1) ?>" aria-valuemin="0" aria-valuemax="100"> <?php echo number_format($list[$i]['rate'], 1) ?>%</div>
        </div>
      <?php }  ?>

  </div>
        <!-- } 설문조사 결과 그래프 끝 -->

        <!-- 설문조사 기타의견 시작 { -->
        <?php if ($is_etc) {  ?>
  <div class="card-body text-success w-100">
    <?php for ($i=0; $i<count($list2); $i++) {  ?>
        <?php echo $list2[$i]['name'] ?>
        <span class="float-right"><i class="fa fa-clock-o" aria-hidden="true"></i> <?php echo $list2[$i]['datetime'] ?> <span class="poll_cmt_del"><?php if ($list2[$i]['del']) { echo $list2[$i]['del']."<i class=\"fa fa-times-circle\" aria-hidden=\"true\"></i><span class=\"sr-only\">삭제</span></a>"; }  ?></span></span>
        <p class="mb-2 p-2 border-bottom"><?php echo $list2[$i]['idea'] ?></p>

    <?php }  ?>

    <?php if ($member['mb_level'] >= $po['po_level']) {  ?>
      <form name="fpollresult" action="./poll_etc_update.php" onsubmit="return fpollresult_submit(this);" method="post" autocomplete="off">
      <input type="hidden" name="po_id" value="<?php echo $po_id ?>">
      <input type="hidden" name="w" value="">
      <input type="hidden" name="skin_dir" value="<?php echo urlencode($skin_dir); ?>">
      <?php if ($is_member) {  ?><input type="hidden" name="pc_name" value="<?php echo get_text(cut_str($member['mb_nick'],255)) ?>"><?php }  ?>
      <h6 class="card-title mt-3"><?php echo $po_etc ?></h6>

            <div>
                <ul id="poll_result_wcmt">
                    <?php if ($is_guest) {  ?>
                    <li>
                        <label for="pc_name" class="sr-only">이름<strong>필수</strong></label>
                        <input type="text" name="pc_name" id="pc_name" required class="form-control" placeholder="이름">
                    </li>
                    <li>
                        <?php echo captcha_html(); ?>
                    </li>
                    <?php }  ?>
                    <li>
                        <label for="pc_idea" class="sr-only">의견<strong>필수</strong></label>
                        <input type="text" id="pc_idea" name="pc_idea" required class="form-control" placeholder="의견">
                    </li>
                    <li class='float-right m-1'>
                        <input type="submit" class="btn btn-primary btn-sm" value="의견남기기">
                    </li>

                </ul>
            </div>

      </form>
    <?php }  ?>

    </div>
<?php }  ?>
<!-- } 설문조사 기타의견 끝 -->

        <!-- 설문조사 다른 결과 보기 시작 { -->
    <div class="card-footer bg-transparent border-primary w-100">
      <h6 class="card-title text-center">다른 투표 결과 보기</h6>
      <?php for ($i=0; $i<count($list3); $i++) {  ?>
      <p class="card-text w-100"><a href="./poll_result.php?po_id=<?php echo $list3[$i]['po_id'] ?>&amp;skin_dir=<?php echo urlencode($skin_dir); ?>"> <?php echo $list3[$i]['subject'] ?> </a><span class="float-right"><i class="fa fa-clock-o" aria-hidden="true"></i> <?php echo $list3[$i]['date'] ?></span></p>
      <?php }  ?>
        <!-- } 설문조사 다른 결과 보기 끝 -->

    </div>
</div>

<script>
$(function() {
    $(".poll_delete").click(function() {
        if(!confirm("해당 기타의견을 삭제하시겠습니까?"))
            return false;
    });
});

function fpollresult_submit(f)
{
    <?php if ($is_guest) { echo chk_captcha_js(); }  ?>

    return true;
}
</script>
<!-- } 설문조사 결과 끝 -->
