{% load i18n %}

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


<script src="/static/js/jquerydatatable/highlight1.js"></script>
<script type="text/javascript">
    $(document).ready(function(){    
        var page_length=20;


        var table=$('#tb').DataTable({
            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();
                }
            });
        });

            $('.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('&'));
                }
            });

            
        $('#tb tbody img').click(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:600px;'></img></div>";
            $.OpenCfmDlg(tt,i);       
        });

        
        $('#btn_save').click(function () {
            $.SubmitForm('#form1', '{{request.path}}', function () {
                $('.modal-backdrop').remove();
            });
        })
    });

    
    function editLevel(id) {
        $("#appeal_id").val(id);
        $('#modal1').modal('show')
    }
</script>



<ol class="breadcrumb">
        <li>{% trans '数据统计' %}</li>
        <li>{% trans '消费者申诉' %}</li>
</ol>





<form role="form"  class="form-inline" style="margin-top:0px;padding-left:10px;">
    <div class="col-sm-2 input-group">
        <span class="input-group-addon">{% trans "开始日期"%}</span>
        <input class="datepicker form-control" id="dt_fr" />
    </div>
    <div class="col-sm-2 input-group">
        <span class="input-group-addon">{% trans "结束日期"%}</span>
        <input class="datepicker form-control" id="dt_to" />
    </div>
    <div  class="col-sm-2 input-group">
        <span class='input-group-btn'>
            <a type="button" class='btn btn-primary btn-qry'>
                <span class='glyphicon glyphicon-search' style='padding-right:5px;'></span>{% trans '查找' %}
            </a>
        </span>
    </div>
</form>
<div class="clearfix"></div>




<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="modal fade" tabindex="-1" role="dialog" id="modal1">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">申诉处理</h4>
            </div>
            <div class="modal-body">
                <form role="form" method='POST' enctype="multipart/form-data" class="form-horizontal" id="form1">
                    {% csrf_token %} 
 
                    <div class="row">
                        <label class="col-sm-2 control-label">留言</label>
                        <div class="col-sm-10"> 
                            <textarea class="form-control" rows="3" name="reason"></textarea>
                        </div>
                    </div>

                    <div class="row" style="margin-top:15px">
                        <label class="col-sm-2 control-label">状态</label>
                        <div class="col-sm-10"> 
                            <select name="status" class="form-control">
                                <option value="0">审核中</option> 
                                <option value="1">通过</option> 
                                <option value="2">驳回</option> 
                            </select>
                        </div>
                    </div>


                    <input type="hidden" name="id" id="appeal_id">
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="btn_save">审核</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
 