collection.html 10.9 KB
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>单据打印</title>
    <style>
        body {
            font-size: 14px;
            color: #000;
        }

        ul, li, table, td, th, tr, a{
            margin: 0;
            padding: 0;
        }

        .main {
            width: 790px;
            margin: auto;
        }

        .title {
            font-size: 16px;
            text-align: center;
        }
        .company{
            font-size: 16px;
            text-align: center;
            font-weight: bold;
        }

        .type {
            padding: 5px 10px;
        }

        .type0 {
            float: left;
            width: 30%;
            text-align: left;
        }

        .type1 {
            float: left;
            width: 25%;
            text-align: left;
        }
        .type11 {
            float: right;
            width: 30%;
            text-align: left;
        }

        .type2 {
            float: left;
            width: 15%;
            text-align: right;
        }

        .clear {
            clear: both;
        }

        table {
            border: 1px solid #000;
            width: 100%;
            border-collapse: collapse
        }

        td {
            border: 1px solid #000;
            padding: 1px 5px;
        }

        .t1 {
            font-weight: bold;
            text-align: center;
        }

        .text-center {
            text-align: center;
        }

        .text-right {
            text-align: right;
        }
        .type3{
            float: left;
            width: 25%;
            text-align: left;
        }
        .infos{
            padding: 5px 10px;
        }
        .border1{
            position: relative;
        }
        .border1 span{
            position: absolute;
            bottom: 0;
            left: 80px;
            width: 100px;

            border-bottom: 1px solid #000;
        }
    </style>
    <style>
        /*纯CSS写法*/
        .checkbox-group input{display:none;opacity:0;}
        .checkbox-group input[type=checkbox]+label, .checkbox-group input[type=radio]+label {
            line-height: 1;
            position: relative;
            margin:2px;
        }
        .checkbox-group input[type=checkbox]+label:before, .checkbox-group input[type=radio]+label:before {
            line-height: 20px;
            display: inline-block;
            width: 18px;
            height: 18px;
            margin-right: 8px;
            content: '';
            color: #fff;
            border: 1px solid #dce4e6;
            background-color: #f3f6f8;
            border-radius: 3px;
        }
        .checkbox-group input[type=checkbox]:checked+label:before,.checkbox-group input[type=radio]:checked+label:before{
            content:'\2713';
            color:#fff;
            background-color: #31b968;
            border-radius: 3px;
            font-size:23px;
            text-align: center;
            border-color: #000000;
        }
        .noprint { display:none;}
        .print_btn,#close_btn{ display:none; }
        @page {
            margin-bottom: 0mm;
            margin-top: 0mm
        }
    </style>
</head>
<body>
<div>
    <input type="button" class="print_btn" onclick="preview(1)" value="打印">
    <a id="close_btn" href="javascript:window.opener=null;window.open('','_self');window.close();">关闭</a>
</div>
<!--startprint-->
<div>
    {volist name="list" id="vo"}
    <div class="main" {if condition='$i<sizeof($list)'}style="page-break-after: always"{/if}>
        <div class="company">{$company_name|default=''}</div>
        <div class="title">付款单</div>
        <div class="type">
            <div class="type0">销货单位:{$vo.customers.customer_name|default=''}</div>
            <div class="type1">单据日期:{$vo.purchase_time|date='Y-m-d',###}</div>
            <div class="type11">单据编号:{$vo.purchase_code|default=''}</div>
            <div class="clear"></div>
        </div>
        <div>
            <table>
                <tr class="t1">
                    <td width="50px">序号</td>
                    <td width="150px">结算账户</td>
                    <td width="100px">收款金额</td>
                    <td width="100px">结算方式</td>
                    <td width="100px">结算号</td>
                    <td width="100px">备注</td>
                </tr>
                {foreach name="vo.payment_account" item="info" key="k"}
                <tr>
                    <td width="50px" class="text-center">{$k+1}</td>
                    <td width="150px">{$info.accounts.account_name|default=''}</td>
                    <td width="100px">{$info.money|default=''}</td>
                    <td width="100px">{$info.settlementtype|default=''}</td>
                    <td width="100px">{$info.number|default=''}</td>
                    <td width="100px">{$info.remark|default=''}</td>
                </tr>
                {/foreach}
                {php}for($a=$k+2;$a<5;$a++){ {/php}
                <tr>
                    <td width="50px" class="text-center">{$a}</td>
                    <td width="150px"></td>
                    <td width="100px"></td>
                    <td width="100px" class="text-right"></td>
                    <td width="100px" class="text-right"></td>
                    <td width="100px" class="text-right"></td>
                </tr>
                {php}}{/php}
                <tr>
                    <td colspan="2" class="text-right">合计:</td>
                    <td width="100px" class="text-right">{$vo.print_money|default=''}</td>
                    <td width="100px" class="text-right"></td>
                    <td width="100px" class="text-right"></td>
                    <td width="100px" class="text-right"></td>
                </tr>
                <tr>
                    <td colspan="6">合计 大写金额:{$vo.print_money_c|default=''}</td>
                </tr>
            </table>
            {if condition="!empty($vo.payment_sale)"}
            <div style="margin: 15px 0 5px 0;">源单信息:</div>
            <table>
                <tr class="t1">
                    <td width="50px">序号</td>
                    <td width="150px">源单编号</td>
                    <td width="100px">业务类别</td>
                    <td width="100px">单据日期</td>
                    <td width="80px">单据金额</td>
                    <td width="100px">已核销金额</td>
                    <td width="100px">未核销金额</td>
                    <td width="120px">本次核销金额</td>
                    <td width="150px">备注</td>
                </tr>
                {foreach name="vo.payment_sale" item="info" key="k"}
                <tr>
                    <td width="50px" class="text-center">{$k+1}</td>
                    <td width="150px">{$info.purchase_code|default=''}</td>
                    <td width="100px">{$info.business_name|default=''}</td>
                    <td width="100px">{$info.times|date='Y-m-d',###}</td>
                    <td width="80px">{$info.money|default=''}</td>
                    <td width="100px">{$info.write_off|default=''}</td>
                    <td width="100px">{$info.write_off_money|default=''}</td>
                    <td width="120px">{$info.write_off_price|default=''}</td>
                    <td width="150px">{$info.remark|default=''}</td>
                </tr>
                {/foreach}
                {php}for($a=$k+2;$a<5;$a++){ {/php}
                <tr>
                    <td width="50px" class="text-center">{$a}</td>
                    <td width="150px"></td>
                    <td width="100px"></td>
                    <td width="100px" class="text-right"></td>
                    <td width="80px" class="text-right"></td>
                    <td width="100px" class="text-right"></td>
                    <td width="100px" class="text-right"></td>
                    <td width="120px" class="text-right"></td>
                    <td width="150px" class="text-right"></td>
                </tr>
                {php}}{/php}
            </table>
            {/if}
        </div>
        <div class="type">
            <div class="type3 border1">付款人签名:<span></span></div>
            <div class="type3" style="float: right">制单人:{$vo.preparation.username|default=''}</div>
            <div class="clear"></div>
        </div>
    </div>
    {/volist}
</div>
<!--endprint-->
<script>
    bdhtml=window.document.body.innerHTML;
    // 打印开始的标志
    sprnstr="<!--startprint-->";
    // 打印结束的标志
    eprnstr="<!--endprint-->";
    // 从打印开始的位置截取到末尾
    prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr)+17);
    // 从开始截取到打印结束的位置
    prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
    // 替换html
    window.document.body.innerHTML=prnhtml;
    // 打印
    HKEY_Root="HKEY_CURRENT_USER";
    HKEY_Path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
    try{
        var Wsh=new ActiveXObject("WScript.Shell");
        HKEY_Key="header";
        //设置页眉(为空) 根据你自己要设置的填入
        Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"");
        HKEY_Key="footer";
        //设置页脚(为空) 根据你自己要设置的填入
        Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"");
        HKEY_Key="margin_bottom";
        //设置下页边距(0) 根据你自己要设置的填入
        Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"0");
        HKEY_Key="margin_left";
        //设置左页边距(0) 根据你自己要设置的填入
        Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"1");
        HKEY_Key="margin_right";
        //设置右页边距(0)
        Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"0");
        HKEY_Key="margin_top";
        //设置上页边距(8)
        Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"1");
    }catch(e){}
    window.print();
    window.document.body.innerHTML = bdhtml;
    var beforePrint = function() {
        //window.print监听打印确认取消
        console.log('Functionality to run before printing.');
    };
    var afterPrint = function() {
        console.log('Functionality to run after printing');
        document.getElementById('close_btn').click();
    };
    if (window.matchMedia) {
        var mediaQueryList = window.matchMedia('print');
        mediaQueryList.addListener(function(mql) {
            if (mql.matches) {
                beforePrint();
            } else {
                afterPrint();
            }
        });
    }
    window.onbeforeprint = beforePrint;
    window.onafterprint = afterPrint;
</script>
</body>
</html>