<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<title>Recibo <?php echo htmlspecialchars($recibo->numero)?></title>
<link href="<?php echo base_url('assets/css/bootstrap.min.css')?>" rel="stylesheet">
<link href="<?php echo base_url('assets/css/font-awesome.min.css')?>" rel="stylesheet">
<style>
body{font-family:Arial,sans-serif;font-size:14px;background:#f4f4f4}
.page{max-width:750px;margin:20px auto;padding:30px;background:#fff;border:2px solid #333}
.header{text-align:center;border-bottom:2px solid #333;padding-bottom:12px;margin-bottom:12px}
.header h2{margin:0 0 4px;font-size:20px}
.header p{margin:2px 0;font-size:12px;color:#555}
.recibo-title{text-align:center;font-size:24px;font-weight:bold;letter-spacing:4px;border:2px solid #333;padding:7px;margin-bottom:14px}
.via-label{text-align:right;font-size:11px;color:#888;margin-bottom:5px}
.numero{font-size:13px;margin-bottom:12px;text-align:right}
.valor-box{border:3px double #333;padding:10px 20px;font-size:22px;font-weight:bold;text-align:center;margin-bottom:12px;background:#f9f9f9}
.valor-extenso{font-size:12px;text-align:center;font-style:italic;margin-bottom:14px;color:#444}
table.campos{width:100%;border-collapse:collapse}
table.campos td{padding:6px 4px;border-bottom:1px solid #ddd;font-size:13px}
table.campos td.lbl{font-weight:bold;color:#555;width:34%}
.assinatura{text-align:center;margin-top:40px}
.assinatura .linha{border-top:1px solid #333;width:280px;margin:0 auto 5px}
.rodape{font-size:10px;text-align:center;color:#aaa;margin-top:14px;border-top:1px solid #ddd;padding-top:8px}
.separador{border-top:2px dashed #bbb;margin:22px 0}
.no-print{text-align:center;padding:15px;background:#f4f4f4;border-bottom:1px solid #ddd}
@media print{.no-print{display:none!important}.page{margin:0;border:none;max-width:100%}}
</style>
</head>
<body>

<div class="no-print">
    <button onclick="window.print()" class="btn btn-primary"><i class="fa fa-print"></i> Imprimir</button>
    <a href="<?php echo site_url('admin/financeiro/pdf_recibo/'.$recibo->id)?>" class="btn btn-danger"><i class="fa fa-file-pdf-o"></i> Baixar PDF</a>
    <a href="<?php echo site_url('admin/financeiro/recibos')?>" class="btn btn-default"><i class="fa fa-arrow-left"></i> Voltar</a>
</div>

<?php foreach([['1ª Via','Cliente'],['2ª Via','Escritório']] as $i=>[$n,$dest]): ?>
<?php if($i>0): ?><div class="separador"></div><?php endif; ?>
<div class="page">
    <div class="via-label"><?php echo $n?> — <?php echo $dest?></div>

    <?php if(!empty($setting->name)): ?>
    <div class="header">
        <?php if(!empty($setting->image)): ?>
        <img src="<?php echo base_url('assets/uploads/images/'.$setting->image)?>" height="48" style="margin-bottom:5px"><br>
        <?php endif; ?>
        <h2><?php echo htmlspecialchars($setting->name)?></h2>
        <?php if(!empty($setting->address)): ?><p><?php echo htmlspecialchars($setting->address)?></p><?php endif; ?>
        <?php if(!empty($setting->contact)): ?><p><?php echo htmlspecialchars($setting->contact)?></p><?php endif; ?>
    </div>
    <?php endif; ?>

    <div class="recibo-title">R E C I B O</div>
    <div class="numero">Nº <strong><?php echo htmlspecialchars($recibo->numero)?></strong></div>

    <div class="valor-box">R$ <?php echo number_format($recibo->valor,2,',','.')?></div>
    <div class="valor-extenso">(<?php echo htmlspecialchars($recibo->valor_extenso)?>)</div>

    <table class="campos">
        <tr>
            <td class="lbl">Recebi(emos) de:</td>
            <td>
                <strong><?php echo htmlspecialchars($recibo->pagador_nome)?></strong>
                <?php if($recibo->pagador_cpf_cnpj): ?> — CPF/CNPJ: <?php echo htmlspecialchars($recibo->pagador_cpf_cnpj)?><?php endif; ?>
            </td>
        </tr>
        <?php if($recibo->pagador_endereco): ?>
        <tr><td class="lbl">Endereço:</td><td><?php echo htmlspecialchars($recibo->pagador_endereco)?></td></tr>
        <?php endif; ?>
        <tr><td class="lbl">A importância de:</td><td><?php echo htmlspecialchars($recibo->referente)?></td></tr>
        <?php if(!empty($recibo->case_no)): ?>
        <tr><td class="lbl">Processo nº:</td><td><?php echo htmlspecialchars($recibo->case_no)?></td></tr>
        <?php endif; ?>
        <tr>
            <td class="lbl">Data de emissão:</td>
            <td><?php echo (!empty($recibo->local_emissao)?htmlspecialchars($recibo->local_emissao).', ':'')?><?php echo date('d \d\e F \d\e Y',strtotime($recibo->data_emissao))?></td>
        </tr>
    </table>

    <div class="assinatura">
        <div class="linha"></div>
        <div><strong><?php echo htmlspecialchars($recibo->recebedor_nome)?></strong></div>
        <?php if(!empty($recibo->recebedor_oab)): ?>
        <div style="font-size:12px;color:#555">OAB nº <?php echo htmlspecialchars($recibo->recebedor_oab)?></div>
        <?php endif; ?>
    </div>
    <div class="rodape">Emitido em <?php echo date('d/m/Y \à\s H:i')?> — Sistema Breno Paiva Advocacia</div>
</div>
<?php endforeach; ?>

</body>
</html>
