Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Script para ler o arquivo de retorno da CEF/CNAB240
- */
- ?>
- <html>
- <body>
- <table border="1">
- <thead>
- <tr>
- <th>Numero</th>
- <th>Data Vcto</th>
- <th>Data Pgto</th>
- <th>Valor do Boleto</th>
- <th>Juros/Multa</th>
- <th>Descontos</th>
- <th>Abatimento</th>
- <th>Valor Pago</th>
- <th>Valor Liquido</th>
- </tr>
- </thead>
- <?php
- $arquivo_ret = @fopen("RETORNOCEF.RET","r");
- if (!$arquivo_ret){
- echo "Erro ao abrir o arquivo.";
- exit;
- }
- $i = 0;
- while (!feof($arquivo_ret)){
- $i++;
- $linha = fgets($arquivo_ret,9999);
- $t_u_segmento = substr($linha,13,1);
- if($t_u_segmento == 'T'){
- $num_fatura = substr($linha,58,11);
- $data_vencimento = substr($linha,73,8);
- $valor_boleto = substr($linha,81,13);
- }
- if($t_u_segmento == 'U'){
- $valor_juros_multa = substr($linha,17,15);
- $valor_desconto = substr($linha,32,15);
- $valor_abatimento = substr($linha,47,15);
- $valor_pago = substr($linha,77,15);
- $valor_liquido = substr($linha,92,15);
- $data_pagamento = substr($linha,137,8);
- }
- ?>
- <tbody>
- <tr>
- <td><?php echo $num_fatura;?></td>
- <td><?php echo $data_vencimento;?></td>
- <td><?php echo $data_pagamento;?></td>
- <td><?php echo $valor_boleto;?></td>
- <td><?php echo $valor_juros_multa;?></td>
- <td><?php echo $valor_desconto;?></td>
- <td><?php echo $valor_abatimento;?></td>
- <td><?php echo $valor_pago;?></td>
- <td><?php echo $valor_liquido;?></td>
- </tr>
- </tbody>
- <?php } fclose($arquivo_ret); ?>
- </table>
Advertisement
Add Comment
Please, Sign In to add comment