{% extends 'order_base.html' %}
{% load staticfiles %}
{% block extrastyle %}<link rel="stylesheet" href="{% static 'base/css/jquery-confirm.min.css' %}"/>{% endblock extrastyle %}
{% block order_head_menu %}
    <li><a href="{% url 'order_contract:little_smart_intro' %}">리틀 스마트 소개</a></li>
    <li class="active"><a href="{% url 'kindergarten:list' %}">영업현황</a></li>
    <li><a href="{% url 'accounts:update' %}">개인정보수정</a></li>
    <li><a href="http://smartzzang.com/kids/media/mediaList" target="_blank">보도자료</a></li>
{% endblock order_head_menu %}
{% block content%}
	<article>
		<p class="tableTitle"><span>{{ request.user }}</span> 님의 <span>{{ kindergarten.name }}</span> 오더</p>
{#		<a onclick="return littleSmartCreate();" href="{% url 'order_contract:little_smart_create' kindergarten.id %}"><div class="newProjactBtn blackBtn">새로만들기</div></a>#}
        <form method="post" action="{% url 'order_contract:little_smart_create' kindergarten.id %}" class="littleSmartCreate" >
            {% csrf_token %}
            <input type="submit" class="newProjactBtn blackBtn" value="새로만들기">
            <input type="text" class="newProjactBtn textbox" id="orderName" name="orderName" placeholder="주문명"/>
        </form>
		<table>
			<colgroup>
				<col width="5%">
				<col width="21%">
				<col width="45%">
				<col width="13%">
                <col width="10%">
				<col width="6%">
			</colgroup>
			<thead>
				<tr>
					<th>No.</th>
					<th>오더명</th>
					<th>진행단계</th>
					<th>최종진행일</th>
                    <th>사이즈현황</th>
					<th>삭제</th>
				</tr>
			</thead>
			<tbody>

                {% for object in object_list%}
                    <tr>
                        <td>{{ object.key }}</td>
                        <td><a href="{% url 'order_contract:little_smart_find_order' object.id %}">{{ object.name }}</a></td>
                        <td>
                            {% if object.order_status == 1 %}
                                <img class="progressbar" src="/static/base/image/progressbar0.gif">
                            {% elif object.order_status == 2 %}
                                <img class="progressbar" src="/static/base/image/progressbar1.gif">
                            {% elif object.order_status == 3 %}
                                <img class="progressbar" src="/static/base/image/progressbar2.gif">
                            {% elif object.order_status == 4 %}
                                <img class="progressbar" src="/static/base/image/progressbar3.gif">
                            {% else %}
                                <img class="progressbar" src="/static/base/image/progressbar4.gif">
                            {% endif %}
                        </td>
                        <td>{{ object.modify_date|date:"Y년 M d일" }}</td>
                        <td>
                            {% if object.order_status == 5 %}
                            <a href="{% url 'measurement:submission_status' object.id %}"><button class="sizeGoBtn active">보기</button></a>
                            {% else %}
                            <a href="#"><button class="sizeGoBtn">보기</button></a>
                            {% endif %}
                        </td>
                        <td>
                            <a class="littleSmartDelete" href="{% url 'order_contract:little_smart_delete' object.id %}"><button class="SmartDelete">X</button></a>
                        </td>
                    </tr>
                {% endfor %}
			</tbody>
		</table>
        {% include 'pagination/pagination.html' %}
	</article>
{% endblock content %}
{% block extrascript %}
    <script type="text/javascript" src="{% static 'base/js/jquery-confirm.min.js' %}"></script>
    <script type="text/javascript">

        $(".littleSmartCreate input[type='submit']").confirm({
            title: 'Confirm!',
            content: '새로운 주문을 생성하시겠습니까?',
            useBootstrap: false,
            buttons: {
                confirm: function () {

                    var orderName = $("#orderName").val();
                    if (!(orderName.length > 0)){
                        $.alert({
                            title: 'Alert!',
                            content: '주문명을 입력해주세요',
                            useBootstrap: false
                        });
                    }else{
                        $(".littleSmartCreate").submit();
                    }

                },
                cancel: function () {
                }
            }
        });

        $(".littleSmartDelete").confirm({
            title: 'Confirm!',
            content: '선택 주문을 삭제하시겠습니까?',
            useBootstrap: false,
            buttons: {
                confirm: function () {
                    location.href = this.$target.attr("href");
                },
                cancel: function () {
                }
            }
        });

    </script>
{% endblock extrascript %}