{% extends 'checkIn/layout.html' %}
{% load staticfiles %}

{% block script %}
<script src="{% static '/JS/luckydraw.js' %}"></script>
{% endblock %}

{% block body %}
<div class="container">
    {% if totalQty == 0 %}
    <div class="alert alert-warning" style="text-align:center">
        <h3 style="text-align:center">还没有抽奖名单，请生成。</h3>
        <button class="btn btn-default" onClick="window.location.href='/addon/createLuckyDrawList/?c_ID={{c_ID}}'">生成抽奖名单</button>
        <button class="btn btn-default" onClick="window.location.href='/checkIn/checkInStatus/?ID={{c_ID}}'">返回</button>
    </div>
    {% else %}
        <form name="luckydraw" method="post">
        {% csrf_token %}
            <input type="hidden" name="c_ID" value="{{c_ID}}" />
            <div class="form-group">
                <label >抽奖名（例如一等奖，鼓励奖，阳光普照）:</label>
                <input type="text" name="award" class="form-control" placeholder="抽奖名"/>
            </div>
            <div class="form-group">
                <label >中奖人数：</label>
                <input type="number" name="qty" min="1" max="{{unluckyQty}}" class="form-control" placeholder="中奖人数"/>
            </div>
            <input type="submit" value="抽奖" class="btn btn-default"/>
        </form> 
            <button value="返回" onClick="window.location.href='/checkIn/checkInDetail/?ID={{c_ID}}'" class="btn btn-default">返回</button>
        <table class="table table-striped">
            <caption>
                <p><small>抽奖名单截至时间:{{cutoffTime}}</small></p><br />
                <h4>目前抽奖名单，共<u>{{ totalQty }}</u>参与者。 <u>{{luckyQty}}</u>已经中奖，还有<u>{{unluckyQty}}</u>未中奖。&nbsp;&nbsp;
                <button value="刷新中奖名单" onclick="javascript: window.location.reload()" class="btn btn-default">刷新中奖名单</button></h4><br />
                <button value="重置抽奖" onclick="resetLuckydraw('{{c_ID}}')" class="btn btn-default">重置抽奖</button>
            </caption>
            <tr>
                {% for k in keys %}
                    <th>{{k}}</th>
                {% endfor %}
                <th>中奖状态</th>
            </tr>
            {% for r in result %}
                <tr>
                    {% for k in r %}
                        <th>{{k}}</th>
                    {% endfor %}
                </tr>
            {% endfor %}
        </table>
    {% endif %}
 </div>
{% endblock %}