{% load i18n %}
<style>

    .highlight {
        background-color: limegreen;
    }
</style>



<script type="text/javascript">
    $(document).ready(function () {
        var page_length = 10;
        {% if request.user.company.cfg_company.product_photo %}
            page_length = 5;
        {% endif %}

        var table = $('#tb').DataTable({
            {#"scrollY":        200,#}
            {#"scrollCollapse": true,#}
            {#"jQueryUI":       true,#}

            dom: 'Bfrtip',
            autoWidth: true,
            pageLength: page_length,
            buttons: [{extend: 'excelHtml5', text: '导出到Excel'}],
            language: lng,
            data:{{data|safe}}
        });
        table.on('draw', function () {
            var body = $(table.table().body());
            body.unhighlight();
            body.highlight(table.search());
        });

        table.columns().every(function () {
            var that = this;
            $('input', this.footer()).on('keyup change clear', function () {
                if (that.search() !== this.value) {
                    that.search(this.value).draw();
                }
            });
        });


        $('#data-content .btn-obj-add').click(function () {
            event.preventDefault();
            $.RefreshContent($(this).attr('href'));
        });
        $('#tb td a').click(function () {
            event.preventDefault();
            $.RefreshContent($(this).attr('href'));
        });


        $('#tb tbody').on('click', 'img', function () {
            var src = $(this).attr('src');
            var tt = $(this).closest('tr').find('a').text();
            if (tt == '') {
                tt = $(this).attr('tt');
            }
            ;
            var i = "<div style='text-align:center;'><img src='" + src + "' style='height:400px;'></img></div>";
            $.OpenCfmDlg(tt, i);
        });

        {% if dt %}
            $('.datepicker').datepicker({dateFormat: 'yy-mm-dd'});
            $('.datepicker').datepicker('setDate', new Date());
            setDatePickerZh();

            $('#dt_fr').val('{{date_from}}');
            $('#dt_to').val('{{date_to}}');

            $('.btn-qry').click(function () {
                var date_fr, date_to;
                date_fr = $('#dt_fr').val();
                date_to = $('#dt_to').val();
                var params = [];
                if (date_fr != '') {
                    params.push('date_from=' + date_fr)
                }
                ;
                if (date_to != '') {
                    params.push('date_to=' + date_to)
                }
                ;

                if (params.length == 0) {
                    bootbox.alert("{% trans '请先输入查询条件！'%}");
                } else {
                    $.RefreshContent('{{request.path}}?' + params.join('&'));
                }
            });
        {% endif %}

        $('.btn-save').click(function () {
            $.ajax({
                type: 'POST',
                dataType: "json",
                contentType: "application/json",
                url: "/inventory/period/config/set/",
                data: JSON.stringify({'dt': $("#id_stkperiod").val()}),
                success:function (data) {
                    alert(data.msg)
                }
            })

        })

    });
</script>


<ol class="breadcrumb">
    <li>{% trans '销售报表' %}</li>
    <li>{% trans '库存期结期设置' %}</li>
</ol>
  


<div class="col-md-12 col-sm-12 col-xs-12">
    <div class="x_panel">
        <div class="table-responsive">
            <table id='tb' class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
                <thead>
                {% for c in clmns %}
                    <th>{{ c }}</th>
                {% endfor %}
                </thead>
                <tbody></tbody>
                <tfoot>
                {% for c in clmns %}
                    <th><input type="text" placeholder="{{ c }}"></th>
                {% endfor %}
                </tfoot>
            </table>
        </div>
    </div>
</div>


<div class="col-md-12 col-sm-12 col-xs-12">
    <div id="obj_form" class="container">
        <form role="form" method='POST' enctype="multipart/form-data" class="form-horizontal"> {% csrf_token %}
            <div class="x_panel">
                <br/>
                <div class="edit_panel">
                    <div class="form-group ">
                        <label class="col-sm-2 control-label ">当前会计期：</label>
                        <div class="col-sm-10">

                            <select name="stkperiod" class="form-control" required id="id_stkperiod">
                                {% ifequal now.0  null %}
                                    <option value="" selected>请选择以添加</option>
                                {% else %}
                                    <option value="{{ now.0.1 }}" selected>{{ now.0.0 }}</option>

                                {% endifequal %}

                                {% for i in  kjq %}
                                    <option value="{{ i.1 }}">{{ i.0 }}</option>
                                {% endfor %}
                            </select>
                        </div>
                    </div>
                    {#            <div class="form-group ">#}
                    {#                <label class="col-sm-2 control-label ">备注：</label>#}
                    {#                <div class="col-sm-10"><input placeholder=""></div>#}
                    {#            </div>#}
                    <div>
                        <a class="btn btn-primary btn-save" type="submit" style="float:right;">{% trans '保存' %}</a>
                    </div>
                </div>
            </div>

            <div class="clearfix"></div>
        </form>
    </div>
</div>

