<%@ Page Title="" Language="C#" MasterPageFile="~/Styles/MasterPage/MasterPage_Edit.master" AutoEventWireup="true" CodeFile="PrintTemplate.aspx.cs" Inherits="System_GrfPrinter_PrintTemplate"%>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

    <script type="text/javascript" src="../../Scripts/jquery-1.9.1.min.js"></script>
<style> 
    body
    {
        overflow:hidden
    }
    #template_list
    {
        text-align:center;
        width:550px;height:300px;overflow:auto;
    }
    #template_list li
    {
        float:left;
        list-style:none;
        width:150px;
    }
    #template_list li img
    {
        border:0px;
    }
    #template_list li a
    {
        font-size:9pt;
        color:Black;
        text-decoration:none;
    }
    #template_list li a:hover
    {
        color:#084B8A;
    }
</style>

<script type="text/javascript">
    //打印表头用的SQL
    var module = "<%=Request.QueryString["module"]%>";
    var sql_print_main_session_id = "<%=Request.QueryString["sql_print_main_session_id"]%>";
    var sql_print_detail_session_id = "<%=Request.QueryString["sql_print_detail_session_id"]%>";
    //调用打印控件
    function print_view(prt_id,template_name, grf_file){
        var url = '../../System/GrfPrinter/PrintView.aspx?module=' + module + '&sql_print_main_session_id=' + sql_print_main_session_id
                + "&sql_print_detail_session_id=" + sql_print_detail_session_id + "&grf_file=" + grf_file;
        top.OpenWindow('Activate', "print_" + prt_id, '打印-' + template_name, url);
        CloseDivWin(); //关闭窗口
    }
    //导出excel
    function export_to_excel(){
        var url = '../../System/GrfPrinter/ExportToExcel.aspx?module=' + module + '&sql_print_main_session_id=' + sql_print_main_session_id
                + "&sql_print_detail_session_id=" + sql_print_detail_session_id;
        //window.open('Activate', "export_to_excel" + module, '导出Excel', url);
        window.open(url);
        CloseDivWin(); //关闭窗口
    }
    //新增
    function add_template(){
        window.location = "PrintTemplate_Edit.aspx?action=Add&module=" + module + "&from_url="+window.location;
    }
    //管理
    function manage_template(){
        var d = document.getElementsByName("btn_delete");
        for(var i=0;i<d.length;i++){
            d[i].style.display = "";
        }
        var m = document.getElementsByName("btn_edit");
        for(var i=0;i<m.length;i++){
            m[i].style.display = "";
        }
    }
    //执行删除
    function do_delete(id){
        asyncbox.confirm('确定要删除吗', '警告', function (buttonResult) {
            if (buttonResult == "ok") {
                ShowLoadingMask(); //显示遮罩
                $.ajax({
                    type: "POST",
                    contentType: "application/json",
                    url: "PrintTemplate_Service.asmx/Delete",
                    data: "{id:'" + id + "'}",
                    dataType: 'json',
                    success: function (result) {
                        var r = result.d;
                        if (r == "success") {
                            AlertOK('删除成功!');
                            document.getElementById("li_"+id).style.display='none';
                        } else {
                            AlertNO(r);
                        }
                        HideLoadingMask(); //关闭遮罩
                    }
                });
            }
        });
    }
    //执行修改
    function do_edit(prt_id){
        window.location = "PrintTemplate_Edit.aspx?action=Update&module=" + module + "&prt_id=" + prt_id+"&from_url="+window.location;
    }
    function trace_sql(){
        var url = "../../System/GrfPrinter/ViewPrintSql.aspx";
        top.OpenWindow('Activate', "trace_sql", '跟踪SQL', url);
    }
    //下载控件
    function down_control() {
        var url = "../../System/GrfPrinter/grinstall/grbsctl5.exe";
        window.open(url);
    }
    
</script>
    <!--工具栏-->
    <div class="list_menu_bar">
        <a plain="true" class="easyui-linkbutton" iconcls="icon-ok" onclick="add_template()" style='<%=auth.AuthView("System_CommonModule_SetPrint")%>'>新增</a>
        <a plain="true" class="easyui-linkbutton" onclick="manage_template()" style='<%=auth.AuthView("System_CommonModule_SetPrint")%>'>管理</a>
        <a plain="true" class="easyui-linkbutton" onclick="trace_sql()" style='<%=auth.AuthView("System_CommonModule_SetPrint")%>'>跟踪SQL</a>
        <a plain="true" class="easyui-linkbutton" onclick="down_control()">下载控件</a>
        <span style='color:red'>打印不了请下载控件安装</span>
    </div>
    <ul id="template_list">
        <%=html%>
    </ul>

</asp:Content>