<!DOCTYPE html>
<!--[if IE 8]>
<html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]>
<html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html>
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
    <base href="#springUrl('/assets/adminlte/')"/>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>工作台</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.5 -->
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="plugins/font-awesome/css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="plugins/ionicons/css/ionicons.min.css">

    <!-- DataTables -->
    <link rel="stylesheet" href="plugins/datatables/dataTables.bootstrap.css">

    <!-- Theme style -->
    <link rel="stylesheet" href="dist/css/AdminLTE.min.css">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" href="dist/css/skins/_all-skins.min.css">
    <!-- iCheck -->
    <link rel="stylesheet" href="plugins/iCheck/flat/blue.css">
    <!-- Morris chart -->
    <link rel="stylesheet" href="plugins/morris/morris.css">
    <!-- jvectormap -->
    <link rel="stylesheet" href="plugins/jvectormap/jquery-jvectormap-1.2.2.css">
    <!-- Date Picker -->
    <link rel="stylesheet" href="plugins/datepicker/datepicker3.css">
    <!-- Daterange picker -->
    <link rel="stylesheet" href="plugins/daterangepicker/daterangepicker-bs3.css">
    <link rel="stylesheet"
          href="plugins\bootstrap-fileinput\fileinput.min.css">
    <!-- bootstrap wysihtml5 - text editor -->
    <link rel="stylesheet" href="plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
    <link rel="stylesheet" href="plugins/bootstrap-star-rating/css/star-rating.min.css">
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        .dropdown-menu1 {
            position: absolute;
            top: 100%;
            left: 0;
            z-index: 1000;
            display: none;
            float: left;
            min-width: 160px;
            padding: 5px 0;
            margin: 2px 0 0;
            font-size: 14px;
            text-align: left;
            list-style: none;
            background-color: #fff;
            -webkit-background-clip: padding-box;
            background-clip: padding-box;
            border: 1px solid #ccc;
            border: 1px solid rgba(0, 0, 0, .15);
            border-radius: 4px;
            -webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, .175);
            box-shadow: 0 6px 12px rgba(0, 0, 0, .175);
        }
    </style>
</head>
<body class="hold-transition skin-blue sidebar-mini">


<div class="wrapper">
    <div class="content-wrapper" style="margin-left:0;">
        <div id="importExcelDiv"></div>

        <section class="content-header">
            <h1>
                展厅申请单管理1111
                <small>展厅申请单</small>
            </h1>
            <ol class="breadcrumb">
                <li><a><i class="fa fa-dashboard"></i>首页</a></li>
                <li><a class="active">展厅申请单管理列表</a></li>
            </ol>
        </section>
        <div id="myModal" class="modal fade" data-backdrop="static">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        选择年份下载报表
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                    </div>
                    <!-- dialog body -->
                    <div class="modal-body">
                        <select class="form-control valid" aria-invalid="false" name="year"></select>
                    </div>
                    <div class="modal-footer">
                        <a href="javascript:void(0)" id="downloadData" class="btn btn-primary">下载</a>
                    </div>
                    <!-- dialog buttons -->
                </div>
            </div>
        </div>

        <div id="remarksModal" class="modal fade" data-backdrop="static">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title">修改管理员备注</h4>
                    </div>
                    <div class="modal-body">
                        <textarea id="orderRemarks" style="width: 100%"></textarea>
                        <input id="orderId" style="display: none;">
                    </div>
                    <div class="modal-footer">
                        <a href="javascript:void(0)" data-dismiss="modal" aria-hidden="true"
                           class="btn btn-primary">取消</a>
                        <a href="javascript:void(0)" id="submitRemarks" class="btn btn-primary">确定</a>
                    </div>
                    <!-- dialog buttons -->
                </div>
            </div>
        </div>

        <div id="evaluateModal" class="modal fade" data-backdrop="static">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <font color="red">以下是评分信息</font>
                    </div>
                    <div class="modal-body">
                        <div class="col-xs-12" style="float: none;">
                            <label>1.本次参观，让您的客人加深了对舍弗勒品牌及技术专长的了解。
                                My guests have gained a better understanding of the Schaeffler brand and its technical
                                expertise during this visit.:</label>
                            <input id="brand" class="rating" readonly>
                        </div>
                        <div class="col-xs-12" style="float: none;">
                            <label>2.此次参观时，展厅内的展品及多媒体设施已处于良好可用状态。
                                The exhibits and multimedia were in a good condition.:</label>
                            <input id="mediaDevice" class="rating" readonly>
                        </div>
                        <div class="col-xs-12" style="float: none;">
                            <label>3.此次品牌大使（如有）My Brand Ambassador (if applicable)…:</label>
                            <label>A.讲解专业，内容丰富 was professional and knowledgeable.:</label>
                            <input id="explainMajor" class="rating" readonly>
                        </div>
                        <div class="col-xs-12" style="float: none;">
                            <label>B.着装规范，仪态得体 was well groomed and respectful.</label>
                            <input id="clothing" class="rating" readonly>
                        </div>
                        <div class="col-xs-12" style="float: none;">
                            <label>您的建议或反馈Your comments or suggestions:</label>
                            <textarea style="width: 100%;" id="proposal" readonly></textarea>
                        </div>
                    </div>
                    <!-- dialog buttons -->
                </div>
            </div>
        </div>

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <div class="box">
                        <div class="box-header">
                            <form id="seachTableForm" action="#springUrl('/a/appForm/exportExcel')" method="get">
                                <div class="col-xs-2">
                                    <input type="text" class="form-control required"
                                           name="name" placeholder="申请人姓名">
                                </div>
                                <div class="col-xs-3">
                                    <input type="text" class="form-control required" readonly
                                           name="reservationDateStr" id="reservationDateStr" placeholder="预约日期">
                                </div>
                                <div class="col-xs-3">
                                    <input type="text" class="form-control required" readonly
                                           name="createTimeStr" id="createTimeStr" placeholder="申请时间">
                                </div>
                                <div class="col-xs-12" style="margin-top:8px;">
                                    <a href="javascript:void(0)" class="btn btn-primary search">搜索</a>
                                    <a href="#springUrl('/a/appForm/calendar')" class="btn btn-primary">日历方式查看</a>
                                    <a href="#springUrl('/a/appForm/downloadcode')" class="btn btn-primary">展厅预约二维码</a>
                                    <button class="btn btn-primary">导出申请单明细</button>
                                    <a href="javascript:void(0)" id="downloadDataOpen"
                                       class="btn btn-primary">导出统计报表</a>
                                    <a href="javascript:void(0)"
                                       class="btn btn-primary export-evaluate">导出评分统计报表</a>
                                </div>
                            </form>


                        </div><!-- /.box-header -->
                        <div class="box-body">
                            <table id="table" class="table table-bordered table-striped">
                                <thead>
                                <tr>
                                    <td hidden="true">Id</td>
                                    <th>申请单号</th>
                                    <th>申请人</th>
                                    <th>申请人部门</th>
                                    <th>预约时间段开始时间</th>
                                    <th>预约时间段结束时间</th>
                                    <th>来访者类别</th>
                                    <th>来访者人数</th>
                                    <th>申请事由</th>
                                    <th>品牌大使</th>
                                    <th>预约状态</th>
                                    <th>申请时间</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody id="tablebody">
                                </tbody>

                            </table>
                        </div><!-- /.box-body -->
                    </div><!-- /.box -->
                </div><!-- /.col -->
            </div><!-- /.row -->
        </section><!-- /.content -->
    </div><!-- /.content-wrapper -->


    <!-- Add the sidebar's background. This div must be placed
         immediately after the control sidebar -->
    <div class="control-sidebar-bg"></div>
</div><!-- ./wrapper -->
<!-- jQuery 2.1.4 -->
<script src="plugins/jQuery/jQuery-2.1.4.min.js"></script>
<!-- Bootstrap 3.3.5 -->
<script src="bootstrap/js/bootstrap.min.js"></script>
<!-- DataTables -->
<script src="plugins/datatables/jquery.dataTables.min.js"></script>
<script src="plugins/datatables/extensions/i18n/lanauage_ch.js"></script>
<script src="plugins/datatables/dataTables.bootstrap.min.js"></script>
<!-- SlimScroll -->
<script src="plugins/slimScroll/jquery.slimscroll.min.js"></script>
<script src="plugins/datepicker/bootstrap-datepicker.js"></script>
<script src="plugins/datepicker/locales/bootstrap-datepicker.zh-CN.js"></script>
<!-- FastClick -->
<script src="plugins/fastclick/fastclick.min.js"></script>
<!--fileinput js-->
<script src="plugins\bootstrap-fileinput\fileinput.js"></script>
<script src="plugins/bootstrap-fileinput/zh.js"></script>
<script src="plugins/bootstrap-fileinput/zh2.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/app.min.js"></script>
<script type="text/javascript"
        src="plugins/jquery-validation/js/jquery.validate.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="common/js/cfapp.js"></script>
<script type="text/javascript"
        src="plugins/daterangepicker/moment.js"></script>
<script type="text/javascript"
        src="plugins/daterangepicker/daterangepicker.js"></script>
<script type="text/javascript"
        src="plugins/bootstrap-star-rating/js/star-rating.min.js"></script>
<script>
    var csrfheader = {name: '_csrf_header', value: '${_csrf.headerName}'};
    var csrftoken = {name: '_csrf', value: '${_csrf.token}'};
</script>
<script>

    var evaliuateText = {
        1: '不好 poor',
        2: '不是很好 below average',
        3: '一般 average',
        4: '很好above average',
        5: '非常好exceptional'
    };

    var starCaptionClasses = {
        1: 'text-success',
        2: 'text-success',
        3: 'text-success',
        4: 'text-success',
        5: 'text-success'
    };

    $('#brand').rating({
        step: 1,
        size: 'sm',//星星大小可选lg,sm,xl,xs
        stars: 5,
        showClear: false,
        starCaptions: evaliuateText,
        starCaptionClasses: starCaptionClasses

    });
    $('#mediaDevice').rating({
        step: 1,
        size: 'sm',//星星大小可选lg,sm,xl,xs
        stars: 5,
        showClear: false,
        starCaptions: evaliuateText,
        starCaptionClasses: starCaptionClasses
    });
    $('#explainMajor').rating({
        step: 1,
        size: 'sm',//星星大小可选lg,sm,xl,xs
        stars: 5,
        showClear: false,
        starCaptions: evaliuateText,
        starCaptionClasses: starCaptionClasses
    });

    $('#clothing').rating({
        step: 1,
        size: 'sm',//星星大小可选lg,sm,xl,xs
        stars: 5,
        showClear: false,
        starCaptions: evaliuateText,
        starCaptionClasses: starCaptionClasses
    });

    // $("#brand").val(5);

    function formatDates(now) {
        var now = new Date(now);
        var year = now.getFullYear();
        var month = now.getMonth() + 1;
        var date = now.getDate();
        var hour = now.getHours();
        var minute = now.getMinutes();
        var second = now.getSeconds();
        return year + "-" + month + "-" + date + "   " + hour + ":"
            + minute + ":" + second;
    }


    function seachTable() {
        var sSource = "#springUrl('/a/appForm/listData')";
        var aoData = {
            iDisplayStart: 1,
            iDosplayLength: 10
        }
        var retrieveData = function (sSource, aoData, fnCallback) {

            $("#seachTableForm input").each(function () {
                var params = {
                    name: $(this).attr("name"),
                    value: $(this).val()
                };
                aoData.push(params);
            })

            $.ajax({
                "type": "GET",
                "url": sSource,
                "dataType": "json",
                "data": aoData, //以json格式传递
                "success": fnCallback
            });
        };

        $('#table').DataTable({
            "lengthChange": false,
            "searching": false,
            "ordering": false,
            "bFiltered": false,
            "bStateSave": true, // save datatable state(pagination, sort, etc) in cookie.
            "bProcessing": true,
            "bServerSide": true,
            "sAjaxSource": sSource,
            "fnServerData": retrieveData,
            "pagingType": "full_numbers",
            "aoColumns": [
                {
                    "mData": "id"
                },
                {
                    "mData": "number"
                },
                {
                    "mData": "name"
                },
                {
                    "mData": "dname"
                },
                {
                    "mData": "reservationBeginTime"
                },
                {
                    "mData": "reservationEndTime"
                },
                {
                    "mData": "vname"
                },
                {
                    "mData": "visitorNum"
                },
                {
                    "mData": "applyContent"
                },
                {
                    "mData": "ename"
                }, {
                    "mData": "statusName"
                },
                {
                    "mData": "createTime"
                }, {
                    "mData": "id"
                }],
            "aoColumnDefs": [
                { // set default column settings
                    'visible': false,
                    'targets': [0]
                },

                {
                    "aTargets": [1],
                    "mData": "number",
                    "mRender": function (a, b, c, d) {
                        return a;

                    }
                },


                {
                    "aTargets": [4],
                    "mData": "reservationBeginTime",
                    "mRender": function (a, b, c, d) {//a表示createtime对应的值，c表示当前记录行对象
                        return formatDates(a, "yyyy-MM-dd HH:mm");
                    }
                },
                {
                    "aTargets": [5],
                    "mData": "reservationEndTime",
                    "mRender": function (a, b, c, d) {//a表示createtime对应的值，c表示当前记录行对象
                        return formatDates(a, "yyyy-MM-dd HH:mm");
                    }
                }, {
                    "aTargets": [10],
                    "mData": "statusName",
                    "mRender": function (a, b, c, d) {//a表示createtime对应的值，c表示当前记录行对象
                        if (c.status == '0') {
                            return '<font color="green">' + a + '</font>';
                        } else {
                            return '<font color="red">' + a + '</font>';
                        }
                    }
                },

                {
                    "aTargets": [11],
                    "mData": "createTime",
                    "mRender": function (a, b, c, d) {//a表示createtime对应的值，c表示当前记录行对象
                        return formatDates(a, "yyyy-MM-dd HH:mm:ss");
                    }
                }
                ,
                {
                    "aTargets": [12],
                    "mData": "id",
                    "mRender": function (a, b, c, d) {//a表示id对应的值，c表示当前记录行对象
                        var html = '#if($shiro.hasPermission("qy:appForm:edit"))';//
                        html += '<a href="javascript:void(0);" data-id="' + a + '" data-action="remove" onclick="removeData(' + a + ')" class="btn red">删除</a>';
                        html += '<a href="javascript:void(0);" data-id="' + a + '" data-action="remove" onclick="urlView(' + a + ')" class="btn red">取消申请单链接地址</a>';
                        if (c.remarks && c.remarks != null && c.remarks != '') {
                            html += '<a href="javascript:void(0);" data-id="' + a + '" data-action="remove" onclick="submitRemarks(' + a + ',\'' + c.remarks + '\')" class="btn red">管理员备注<font color="green">(已设置)</font></a>';
                        } else {
                            html += '<a href="javascript:void(0);" data-id="' + a + '" data-action="remove" onclick="submitRemarks(' + a + ',\'' + c.remarks + '\')" class="btn red">管理员备注<font style="color:#cccccc">(未设置)</font></a>';
                        }
                        if (c.evaluateId && c.evaluateId != null && c.evaluateId != '') {
                            html += '<a href="javascript:void(0);" data-id="' + a + '" data-action="remove" onclick="evaluateShow(' + c.brand + ',' + c.mediaDevice + ',' + c.explainMajor + ',' + c.clothing + ',\'' + c.proposal + '\')" class="btn red">查看评分</a>';

                        }

                        html += '#end';
                        return html;
                    }
                }

            ]
        });
    }

    jQuery(document).ready(function () {
        $("#downloadData").click(function () {
            var year = $("select[name=year]").val();
            location.href = "#springUrl('/a/appForm/exportDataReportingExcel')?year=" + year;
        })

        $("#submitRemarks").click(function () {
            var text = $("#orderRemarks").val();
            var id = $("#orderId").val();
            $.ajax({
                type: "POST",
                url: "#springUrl('/a/appForm/submitRemarks')",
                data: {text: text, _csrf_header: csrfheader.value, _csrf: csrftoken.value, id: id},
                dataType: "json",
                success: function (data) {
                    if (data.errorNo == 0) {
                        Cfapp.alert({
                            message: "更新成功",
                            btntext: "确定",
                            success: function () {
                                location.href = "#springUrl('/a/appForm/list')";
                            }
                        });
                    }
                },
                error: function () {
                }
            })
        })

        $("#downloadDataOpen").click(function () {
            $("#myModal").modal("show");
        })
        seachTable();
        $('.datepicker').datepicker({
            show: true,
            format: 'yyyy-mm-dd',
            autoclose: true,
            language: 'zh-CN',
            todayBtn: 'linked',
            clearBtn: 'linked'

        });

        var html = "";

        for (var i = 2019; i <= new Date().getFullYear(); i++) {
            html += "<option>" + i + "</option>";
        }
        $("select[name='year']").append(html);

        $('.search').click(function () {
            $("#table").dataTable().fnClearTable();
        });

        $("input[name='reservationDateStr']").daterangepicker({
            format: "YYYY-MM-DD",
            timePicker: false,
            timePickerIncrement: 5,
            timePicker12Hour: false,
            locale: {
                applyLabel: '确定',
                cancelLabel: '清除',
                fromLabel: '起始时间',
                toLabel: '结束时间',
                customRangeLabel: '手动选择',
                daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'],
                monthNames: ['一月', '二月', '三月', '四月', '五月', '六月',
                    '七月', '八月', '九月', '十月', '十一月', '十二月'
                ],
                firstDay: 1
            }
        });
        $("input[name='reservationDateStr']").on('cancel.daterangepicker', function (ev, picker) {
            $("input[name='reservationDateStr']").val('');
        });
        $("input[name='createTimeStr']").daterangepicker({
            format: "YYYY-MM-DD hh:mm",
            timePicker: true,
            timePickerIncrement: 5,
            timePicker12Hour: false,
            locale: {
                applyLabel: '确定',
                cancelLabel: '清除',
                fromLabel: '起始时间',
                toLabel: '结束时间',
                customRangeLabel: '手动选择',
                daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'],
                monthNames: ['一月', '二月', '三月', '四月', '五月', '六月',
                    '七月', '八月', '九月', '十月', '十一月', '十二月'
                ],
                firstDay: 1
            }
        });
        $("input[name='createTimeStr']").on('cancel.daterangepicker', function (ev, picker) {
            $("input[name='createTimeStr']").val('');
        });
    });

    Cfapp.init();

    function urlView(id) {
        var pathName = window.document.location.pathname;
        var domain = "https://" + window.location.host;
        var appid = "wx7ded418de1ccae07";
        if (domain == "https://www.michang-tech.com.cn") {
            appid = "wxe1a76a00bf7c1461";
        }
        var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);//项目名称
        Cfapp.alert({
            message: "取消申请按链接地址:<br/><p style='border: #cccccc 1px solid;padding:5px;border-radius: 5px;'>" + domain + projectName + "/static/mp/schaeffler/process/form.html?appid=" + appid + "&id=" + id + "</p>",
            btntext: "确定",
            success: function () {

            }
        });
    }

    function submitRemarks(id, text) {
        if (text == null || text == 'null') {
            text = '';
        }
        $("#orderId").val(id);
        $("#orderRemarks").val(text);
        $("#remarksModal").modal("show");
    }

    function removeData(data) {
        Cfapp.confirm({
            message: "确定要删除吗",
            btnoktext: "确定",
            btncanceltext: "取消",
            success: function () {
                $.ajax({
                    type: "POST",
                    url: "#springUrl('/a/appForm/delete')",
                    data: {id: data, _csrf_header: csrfheader.value, _csrf: csrftoken.value},
                    dataType: "json",
                    success: function (data) {
                        if (data.errorNo == 0) {
                            Cfapp.alert({
                                message: "删除成功",
                                btntext: "确定",
                                success: function () {
                                    location.href = "#springUrl('/a/appForm/list')";
                                }
                            });
                        }
                    },
                    error: function () {
                    }
                })
            },
            cancel: function () {
                $(".modal-backdrop").fadeOut();
            }
        });
    }

    var evaliuateId = "";

    function evaluateShow(brand, mediaDevice, explainMajor, clothing, proposal) {
        // evaliuateId=id;
        $('#brand').rating({}).rating('update', brand);
        $('#mediaDevice').rating({}).rating('update', mediaDevice);
        $('#explainMajor').rating({}).rating('update', explainMajor);
        $('#clothing').rating({}).rating('update', clothing);
        $('#proposal').val(proposal);
        $("#evaluateModal").modal("show");
    }


    $('.export-evaluate').on('click', function () {
        let reservationDateStr = $('#reservationDateStr').val();
        let createTimeStr = $('#createTimeStr').val();
        location.href="#springUrl('/a/appForm/exportDataEvaluateExcel')?reservationDateStr="+reservationDateStr+"&createTimeStr="+createTimeStr;
        // $.ajax({
        //     type: "POST",
        //     url: "#springUrl('/a/appForm/exportDataEvaluateExcel')",
        //     data: {reservationDateStr:reservationDateStr,createTimeStr: createTimeStr, _csrf_header: csrfheader.value, _csrf: csrftoken.value},
        //     dataType: "json",
        //     success: function (data) {
        //         if (data.errorNo == 0) {
        //
        //         }
        //     },
        //     error: function () {
        //     }
        // })
    })
    function exportEvaluate() {

    }


</script>

</body>
</html>
