Advertisement
nenhumdeucerto

Rel

Apr 19th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.40 KB | None | 0 0
  1. <?php
  2. session_start();
  3. ob_start();
  4. require 'conexao.php';
  5. require 'class/usuario.class.php';
  6. require 'class/registro.class.php';
  7. require 'class/tipoabono.class.php';
  8. require 'class/periodoapuracao.class.php';
  9. require 'class/calculadora.class.php';
  10. require "class/extratobanco.class.php";
  11. require 'class/saldo.class.php';
  12. require 'class/abono.class.php';
  13. require 'vendor/autoload.php';
  14.  
  15. if (empty($_SESSION['id'])) {
  16.     header('Location: login.php');
  17. }
  18. $dados_post = filter_input_array(INPUT_GET, FILTER_SANITIZE_MAGIC_QUOTES);
  19.  
  20. $calculadora = new Calculadora();
  21. $colaborador = new Usuario();
  22. $registro = new Registro();
  23. $periodoApuracao = new PeriodoApuracao();
  24. $extrato = new Extrato();
  25. $saldo = new Saldo();
  26. $abono = new Abono();
  27. $periodoApuracao->definePeriodoApuracao($dados_post['periodoapuracao_id']);
  28. $data_final = $periodoApuracao->getDatafinal();
  29. $colaborador->defineUsuario($dados_post['colaborador_id']);
  30. $saldoAnt = $saldo->getSaldoAnterior($dados_post['colaborador_id'], date('Y-m-d', strtotime($data_final)));
  31. $saldo = $extrato->getLancPeriodoApuracao($dados_post['colaborador_id'], $dados_post['periodoapuracao_id']);
  32. $saldoATranferir = $calculadora->saldoATransferir($saldoAnt, $saldo);
  33.  
  34. $dataInical = strtotime($periodoApuracao->getDataInicial());
  35. $dataFinal = strtotime($periodoApuracao->getDatafinal());
  36. ?>
  37. <html>
  38.     <head>
  39.         <title>Relatório de Ponto</title>
  40.         <style>
  41.             *{
  42.                 margin: 0px;
  43.                 padding: 0px;
  44.             }
  45.             img{
  46.                 margin: 5px;
  47.             }
  48.             table{
  49.                 border-collapse: collapse;
  50.                 width: 100%;
  51.                 border: 1px solid rgba(34, 36, 38, 0.15);
  52.                 border-radius: 0.28571429rem;
  53.             }
  54.             tr{
  55.                 border-top: 1px solid rgba(34, 36, 38, 0.15);
  56.             }
  57.             td{
  58.                 width: 11%;
  59.                 padding: 3px;
  60.             }
  61.             table tbody tr:nth-child(odd){ background: #CCC; }
  62.         </style>
  63.     </head>
  64.     <body>
  65.         <table>
  66.             <thead>
  67.                 <tr>
  68.                     <th colspan="2">
  69.                         <img alt='Logo 90ti' width="80px" src='<?php echo BASE; ?>assets/img/logo2.png'>
  70.                     </th>
  71.                     <th colspan="7">
  72.                         90 Tecnologia da Informação Ltda <br>
  73.                         Av. do Contorno, 2090, 4º andar <br>
  74.                         Belo Horizonte, MG <br>
  75.                         CEP 30110-012 <br>
  76.                     </th>
  77.                 </tr>
  78.                 <tr>
  79.                     <th colspan="4" style="text-align:left;">
  80.                         <br/>
  81.                         <strong> Colaborador: </strong> <?php echo $colaborador->getNome(); ?>
  82.                         <br/> <br/>
  83.                     </th>
  84.                     <th colspan="5">
  85.                         <br/>
  86.                         <strong> Competência: </strong> <?php echo $periodoApuracao->getMesCompetencia(); ?>
  87.                     </th>
  88.                 </tr>
  89.                 <tr>
  90.                     <th> Dia </th>
  91.                     <th> Sem </th>
  92.                     <th> 1ª Ent. </th>
  93.                     <th> 1ª Sai. </th>
  94.                     <th> 2ª Ent. </th>
  95.                     <th> 2ª Sai. </th>
  96.                     <th> Sai. Interm. </th>
  97.                     <th> Ent. Interm. </th>
  98.                     <th> Motiv. Abono </th>
  99.                 </tr>
  100.             </thead>
  101.             <tbody>
  102.                 <?php for ($dia = $dataInical; $dia <= $dataFinal; $dia += 86400) { ?>
  103.                     <tr><td style="text-align: center;"><?php echo date('d/m/Y', $dia); ?></td>
  104.                         <td style="text-align: center;"><?php echo $calculadora->diaDaSemana($dia); ?></td>
  105.                         <?php for ($x = 1; $x <= 6; $x++) { ?>
  106.                             <td style="text-align: center;"><?php
  107.                                 $reg = $registro->getRegistro($dados_post['colaborador_id'], $x, date('Y-m-d', $dia));
  108.                                 echo $reg[0]['hora_informada'];
  109.                                 ?>
  110.                             </td>
  111.                         <?php } ?>
  112.                         <td>
  113.                             <?php
  114.                             $abonos = $abono->getTipoAbonoDoDia(date('Y-m-d', $dia), $dados_post['colaborador_id']);
  115.                             if ($abonos != '-') {
  116.                                 foreach ($abonos as $value) {
  117.                                     $res = $value['nome'] . " ";
  118.                                     echo $res;
  119.                                 }
  120.                             } else {
  121.                                 echo $abonos;
  122.                             }
  123.                             ?>
  124.                         </td>
  125.                     </tr>
  126.                 <?php } ?>
  127.             </tbody>
  128.             <tfoot>
  129.                 <tr>
  130.                     <td colspan="9">
  131.                         <?php
  132.                         echo "Saldo Anterior: ";
  133.                         if ($saldoAnt[0] == '0:00:00') {
  134.                             echo $saldoAnt[1] . " C";
  135.                         } else {
  136.                             echo $saldoAnt[0] . ' D';
  137.                         }
  138.                         ?>
  139.                         <br>
  140.                         Total Positivo: <?php echo $saldo[1]; ?>
  141.                         <br>
  142.                         Total Negavivo: <?php echo $saldo[0]; ?>
  143.                         <br>
  144.                         Saldo Final: <?php echo $saldoATranferir; ?>
  145.                     </td>
  146.                 </tr>
  147.                 <tr>
  148.                     <td colspan="9" style="text-align: center;">
  149.                         <br><br>
  150.                         ______________________________________________________________<br>
  151.                         <?php echo $colaborador->getNome(); ?> <br><br>
  152.                     </td>
  153.                 </tr>
  154.             </tfoot>
  155.         </table>
  156.     </body>
  157. </html>
  158. <?php
  159. $html = ob_get_clean();
  160. ob_end_clean();
  161.  
  162. $Mpdf = new Mpdf\Mpdf([
  163.     'default_font_size' => 7,
  164.     'default_font' => 'dejavusans'
  165.         ]);
  166.  
  167. //$nomearq = implode("_", explode(" ", $colaborador->getNome())) . "_fechamento" . date('Ymd');
  168. $Mpdf->WriteHTML($html);
  169. //$Mpdf->Output("arquivos/$nomearq.pdf", "F");
  170. $Mpdf->Output('relatorio', "I");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement