{% extends "bee_django_crm/base.html" %}
{% load static %}

{% block content %}
    {% include 'bee_django_crm/logo.html' %}
    {% include 'bee_django_crm/nav.html' %}
    <h4 class="text-center">{{ poster.source.name }}</h4>
    <table class="table">
        <tr>
            <td class="col-xs-3">预览图</td>
            <td><img src="{% url 'bee_django_crm:user_poster_image' poster.id '0' %}" alt="" style="max-width: 90%">
            </td>
        </tr>
        <tr>
            <td class="col-xs-3">是否显示</td>
            <td>{{ poster.get_is_show }}</td>
        </tr>
        <tr>
            <td class="col-xs-3">二维码坐标</td>
            <td>[ {{ poster.qrcode_pos_x }} , {{ poster.qrcode_pos_y }} ]</td>
        </tr>
        <tr>
            <td class="col-xs-3">二维码大小</td>
            <td>{{ poster.qrcode_width }} * {{ poster.qrcode_height }}</td>
        </tr>
        <tr>
            <td class="col-xs-3">二维码颜色</td>
            <td>
                <div style="width: 30px;height: 30px;background-color: {{ poster.qrcode_color }};display: inline-block"></div>
                {{ poster.qrcode_color }}</td>
        </tr>
        <tr>
            <td class="col-xs-3">操作</td>
            <td>
                {#                <button onclick="generate_poster()" class="btn btn-default" id="generate_btn">生成</button>#}
                <a href="{% url "bee_django_crm:source_detail" poster.source.id %}" class="btn btn-default">返回</a>
                <a href="{% url 'bee_django_crm:poster_update' poster.id %}" class="btn btn-default">修改</a>
                <a href="#" id="delete_{{ poster.id }}"
                   data-confirm="{% url "bee_django_crm:poster_delete" poster.id %}"
                   onclick="click_del(this)" class="btn btn-danger">删除</a>

            </td>
        </tr>
    </table>

{% endblock %}


{% block scripts %}
    <script>
        $(document).ready(function () {

        });
        {#        function generate_poster() {#}
        {#            var btn = $("#generate_btn");#}
        {#            btn.addClass("active");#}
        {#            btn.attr("onclick", "");#}
        {#            btn.html("生成中");#}
        {#            $.post("{% url 'bee_django_crm:poster_generate' poster.id %}", {}, function (res) {#}
        {#                if (res.error == 0) {#}
        {#                    alert("成功生成" + res.count + "张海报");#}
        {#                    location.href = "{% url 'bee_django_crm:poster_list' %}";#}
        {#                }#}
        {#            });#}
        {#        }#}
        function click_del(_this) {
            if (!confirm('确认要执行这个操作？')) {
                return false;
            }
            var url = $(_this).attr('data-confirm');
            $.post(url).done(function (data) {
                alert('删除成功!');
                location.href = '{% url "bee_django_crm:source_detail" poster.id %}';
            });
        }
    </script>
{% endblock %}