function renderHTML()
 {
     $relatorio = new relatorios("Relatório de Patch de Software", 210, false, "Patch de Software", "A4", "Prefeitura de Itajaí\nServidores\nRua Tijucas, 511 - Centro\nCEP. 88304-020 - Itajaí - SC");
     //tamanho do retangulo, tamanho das linhas.
     $relatorio->novaPagina();
     $this->cod_software_patch = $_GET['cod_software_patch'];
     $obj_patch = new clsPmicontrolesisSoftwarePatch($this->cod_software_patch);
     $det_patch = $obj_patch->detalhe();
     if (!$det_patch) {
         die("<center>Não foi possível encontrar o Patch solicitado</center>");
     }
     $obj_soft = new clsPmicontrolesisSoftware($det_patch['ref_cod_software']);
     $det_soft = $obj_soft->detalhe();
     $data_patch = dataFromPgToBr($det_patch['data_patch'], 'Y-d-m');
     $data_patch_ = dataFromPgToBr($det_patch['data_patch'], 'd/m/Y');
     $db = new clsBanco();
     $consulta = " SELECT data_patch\n\t\t\t\t        FROM pmicontrolesis.software_patch\n\t\t\t   \t       WHERE ativo = true\n\t\t\t\t         AND ref_cod_software = 1\n\t\t\t\t\t\tORDER BY data_patch DESC\n\t\t\t\t\t\t      OFFSET 1\n\t\t\t\t\t\t      LIMIT 1";
     $data_patch_anterior = $db->CampoUnico($consulta);
     $data_patch_anterior_ = dataFromPgToBr($data_patch_anterior, 'm/d/Y');
     $data_patch_anterior = dataFromPgToBr($data_patch_anterior, 'Y-d-m');
     $where_and = "";
     if ($data_patch_anterior) {
         $where_and = "  AND ( to_char(data_cadastro,'yyyy-mm-dd') > '{$data_patch_anterior}'\n\t\t\t\t\t         OR to_char(data_exclusao,'yyyy-mm-dd')   > '{$data_patch_anterior}'\n\t\t\t\t\t\t    )";
     }
     $consulta = "SELECT *\n\t\t\t\t\t   FROM pmicontrolesis.software_alteracao\n\t\t\t\t\t  WHERE ativo = true\n\t\t\t\t\t    AND ( to_char(data_cadastro,'yyyy-mm-dd')    <= '{$data_patch}'\n\t\t\t\t\t          OR to_char(data_exclusao,'yyyy-mm-dd') <= '{$data_patch}'\n\t\t\t\t\t\t    )\n\t\t\t\t\t\t{$where_and}";
     $db->Consulta($consulta);
     $periodo = $data_patch_ ? "      ALTERAÇÕES:{$data_patch_anterior_}-{$data_patch_}" : "";
     $opcoes_motivo = array('i' => 'Inserção', 'a' => 'Alteração', 'e' => 'Exclusão');
     $opcoes_tipo = array('s' => 'Script', 'b' => 'Banco');
     if ($db->Num_Linhas()) {
         $i = 0;
         $total = $db->Num_Linhas();
         $relatorio->novalinha(array("SISTEMA:  {$det_soft['nm_software']}{$periodo}        DATA PATCH:  {$data_patch_}"), 0, 13, true, "arial", false, "#d3d3d3", "#d3d3d3", "#000000");
         while ($db->ProximoRegistro()) {
             $registro = $db->Tupla();
             $registro['motivo'] = $opcoes_motivo[$registro['motivo']];
             $registro['tipo'] = $opcoes_tipo[$registro['tipo']];
             $num_linhas = 6 + (int) strlen($registro['descricao']) / 85;
             $data = $registro['data_exclusao'] ? dataFromPgToBr($registro['data_exclusao']) : dataFromPgToBr($registro['data_cadastro']);
             $relatorio->novalinha(array("Descrição de alterações:  {$registro['descricao']}\nMotivo Alteração: {$registro['motivo']}\nTipo Alteração:{$registro['tipo']}\nScript/Banco:{$registro['script_banco']}\nData: {$data}"), 0, $num_linhas * 10, false, "arial", false, "#ffffff", "#ffffff", "#ffffff", false, false, null, null, 'justify');
             $i++;
             if ($i < $total) {
                 $relatorio->novalinha(array(""), 0, 5, false, false, false, false, false, false, true);
             }
         }
         $link = $relatorio->fechaPdf();
     } else {
         $this->campoRotulo("aviso", "Aviso", "Nenhuma Registro neste relat&oacute;rio.");
     }
     echo "<script>window.onload=function(){parent.EscondeDiv('LoadImprimir');window.location='download.php?filename=" . $link . "'}</script>";
     echo "<html><center>Se o download não iniciar automaticamente <br /><a target='_blank' href='" . $link . "' style='font-size: 16px; color: #000000; text-decoration: underline;'>clique aqui!</a><br><br>\n\t\t\t<span style='font-size: 10px;'>Para visualizar os arquivos PDF, é necessário instalar o Adobe Acrobat Reader.<br>\n\n\t\t\tClique na Imagem para Baixar o instalador<br><br>\n\t\t\t<a href=\"http://www.adobe.com.br/products/acrobat/readstep2.html\" target=\"new\"><br><img src=\"imagens/acrobat.gif\" width=\"88\" height=\"31\" border=\"0\"></a>\n\t\t\t</span>\n\t\t\t</center>";
 }
 function Novo()
 {
     if ($this->data_inicial != "" || $this->data_final != "") {
         $AND = '';
         if ($this->data_inicial) {
             $data = explode("/", $this->data_inicial);
             $dia_i = $data[0];
             $mes_i = $data[1];
             $ano_i = $data[2];
             $data_inicial = $ano_i . "/" . $mes_i . "/" . $dia_i . " 00:00:00";
             $AND = " AND a.data_pedido >= '{$data_inicial}'";
         }
         if ($this->data_final) {
             $data_ = explode("/", $this->data_final);
             $dia_f = $data_[0];
             $mes_f = $data_[1];
             $ano_f = $data_[2];
             $data_final = $ano_f . "/" . $mes_f . "/" . $dia_f . " 23:59:59";
             $AND .= " AND a.data_pedido <= '{$data_final}'";
         }
         $sql = "SELECT a.ref_funcionario,\n\t\t\t\t\t\t\t\tb.nome,\n\t\t\t\t\t\t\t\ta.data_partida,\n\t\t\t\t\t\t\t\ta.data_chegada,\n\t\t\t\t\t\t\t\tsum( COALESCE(vl100,0) + COALESCE(vl75,0) + COALESCE(vl50,0) + COALESCE(vl25,0) ) as valor,\n\t\t\t\t\t\t\t\ta.objetivo,\n\t\t\t\t\t\t\t\ta.destino,\n\t\t\t\t\t\t\t\ta.ref_cod_setor\n\t\t\t\t\t\t   FROM cadastro.pessoa b,\n\t\t\t\t\t\t   \t\tpmidrh.diaria a,\n\t\t\t\t\t\t   \t\tportal.funcionario f\n\t\t\t\t\t\t  WHERE a.ref_funcionario = b.idpes\n\t\t\t\t\t\t    AND b.idpes = f.ref_cod_pessoa_fj {$AND} \n\t\t\t\t\t\t    AND a.ativo = 't' \n\t\t\t\t\t   GROUP BY a.ref_funcionario,\n\t\t\t\t\t\t\t\tb.nome,\n\t\t\t\t\t\t\t\ta.data_partida,\n\t\t\t\t\t\t\t\ta.data_chegada,\n\t\t\t\t\t\t\t\ta.objetivo,\n\t\t\t\t\t\t\t\ta.destino,\n\t\t\t\t\t\t\t\ta.ref_cod_setor\n\t\t\t\t\t   ORDER BY a.ref_cod_setor,\n\t\t\t\t\t   \t\t\tb.nome";
         if ($this->data_inicial) {
             $data = explode("/", $this->data_inicial);
             $dia_i = $data[0];
             $mes_i = $data[1];
             $ano_i = $data[2];
             $data_inicial = $dia_i . "/" . $mes_i . "/" . $ano_i;
         }
         if ($this->data_final) {
             $data_ = explode("/", $this->data_final);
             $dia_f = $data_[0];
             $mes_f = $data_[1];
             $ano_f = $data_[2];
             $data_final = $dia_f . "/" . $mes_f . "/" . $ano_f;
         }
         $titulo = "Relatório de Diárias";
         if (is_string($data_inicial) && $data_inicial != '' && is_string($data_final) && $data_final != '') {
             $titulo .= " - De {$data_inicial} até {$data_final}";
         } else {
             if (is_string($data_inicial) && $data_inicial != '') {
                 $titulo .= " - A partir de {$data_inicial}";
             } else {
                 if (is_string($data_final) && $data_final != '') {
                     $titulo .= " - Até {$data_final}";
                 }
             }
         }
         $relatorio = new relatorios("{$titulo}", 200, false, "SEGPOG - Departamento de Logística", "A4", "Prefeitura de Itajaí\nSEGPOG - Departamento de Logística\nRua Alberto Werner, 100 - Vila Operária\nCEP. 88304-053 - Itajaí - SC");
         //tamanho do retangulo, tamanho das linhas.
         $relatorio->novaPagina();
         $db = new clsBanco();
         $db->Consulta($sql);
         if ($db->Num_Linhas()) {
             $old_funcionario = 0;
             $soma_valores = 0;
             $this->cod_setor = 0;
             $this->val_tot_sec = "Primeiro";
             $old_sigla = "";
             while ($db->ProximoRegistro()) {
                 list($cod_funcionario, $nome_funcionario, $data_partida, $data_chegada, $valor_total, $objetivo, $destino, $secretaria, $setor) = $db->Tupla();
                 if ($this->cod_setor != $setor) {
                     $this->cod_setor = $setor;
                     if (is_numeric($setor)) {
                         $db2 = new clsBanco();
                         $db2->Consulta("SELECT sgl_setor, nm_setor FROM pmidrh.setor WHERE cod_setor = '{$setor}' AND nivel = 0");
                         $db2->ProximoRegistro();
                         list($sigla, $nm_secretaria) = $db2->Tupla();
                     }
                     $det_setor["sgl_setor"] = $sigla;
                     if (is_null($det_setor['sgl_setor'])) {
                         $det_setor['sgl_setor'] = "Nenhuma";
                     }
                     if ($this->val_tot_sec != "Primeiro") {
                         $relatorio->novalinha(array("Total da Secretaria ( {$old_sigla} ): " . number_format($this->val_tot_sec, 2, ',', '.') . ""), 250, 13, true);
                         $relatorio->novalinha(array(""));
                     }
                     $relatorio->novalinha(array("Secretaria: {$det_setor['sgl_setor']}"), 0, 13, true);
                     $old_sigla = $det_setor['sgl_setor'];
                     $this->val_tot_sec = 0;
                 }
                 if ($old_funcionario != $cod_funcionario) {
                     $relatorio->novalinha(array("Funcionário: {$nome_funcionario}"));
                     $old_funcionario = $cod_funcionario;
                     $relatorio->novalinha(array("Data Partida", "Data Chegada", "Valor Total"), 25);
                 }
                 $data_partida = date("d/m/Y H:i", strtotime(substr($data_partida, 0, 19)));
                 $data_chegada = date("d/m/Y H:i", strtotime(substr($data_chegada, 0, 19)));
                 $relatorio->novalinha(array($data_partida, $data_chegada, number_format($valor_total, 2, ',', '.')), 25, 13);
                 $relatorio->novalinha(array("Destino", $destino), 25);
                 $relatorio->novalinha(array("Objetivo", $objetivo), 25);
                 $relatorio->novalinha(array(""));
                 $this->val_tot_sec += $valor_total;
                 $soma_valores += $valor_total;
             }
             $relatorio->novalinha(array("Total da Secretaria ( {$old_sigla} ): " . number_format($this->val_tot_sec, 2, ',', '.') . ""), 250, 13, true);
             $relatorio->novalinha(array(""));
             $relatorio->novalinha(array("Valor total do período: " . number_format($soma_valores, 2, ',', '.') . ""), 300, 13, true);
             // pega o link e exibe ele ao usuario
             $link = $relatorio->fechaPdf();
             $this->campoRotulo("arquivo", "Arquivo", "<a href='" . $link . "'>Visualizar Relatório</a>");
         } else {
             $this->campoRotulo("aviso", "Aviso", "Nenhum Funcionário neste relatório.");
         }
     } else {
         $this->campoRotulo("aviso", "Aviso", "Preencha os campos.");
     }
     $this->largura = "100%";
     return true;
 }
Ejemplo n.º 3
0
 function Novo()
 {
     $meses = array();
     $meses[1] = "Janeiro";
     $meses[2] = "Fevereiro";
     $meses[3] = "Março";
     $meses[4] = "Abril";
     $meses[5] = "Maio";
     $meses[6] = "Junho";
     $meses[7] = "Julho";
     $meses[8] = "Agosto";
     $meses[9] = "Setembro";
     $meses[10] = "Outubro";
     $meses[11] = "Novembro";
     $meses[12] = "Dezembro";
     $mesAtual = "";
     if ($this->funcionario != "0") {
         if ($this->data_inicial != "" || $this->data_final != "") {
             $AND = '';
             if ($this->data_inicial) {
                 $data = explode("/", $this->data_inicial);
                 $dia_i = $data[0];
                 $mes_i = $data[1];
                 $ano_i = $data[2];
                 $data_inicial = $ano_i . "/" . $mes_i . "/" . $dia_i . " 00:00:00";
                 $AND = " AND data_pedido >= '{$data_inicial}'";
             }
             if ($this->data_final) {
                 $data_ = explode("/", $this->data_final);
                 $dia_f = $data_[0];
                 $mes_f = $data_[1];
                 $ano_f = $data_[2];
                 $data_final = $ano_f . "/" . $mes_f . "/" . $dia_f . " 23:59:59";
                 $AND .= " AND data_pedido <= '{$data_final}'";
             }
         }
         $sql = "SELECT ref_funcionario, data_partida, data_chegada, COALESCE(vl100,1) + COALESCE(vl75,1) + COALESCE(vl50,1) + COALESCE(vl25,1) as valor, objetivo, destino FROM pmidrh.diaria WHERE ref_funcionario = {$this->funcionario} {$AND} AND ativo = 't' ORDER BY data_partida DESC";
         $db2 = new clsBanco();
         $nome = $db2->campoUnico("SELECT nome FROM cadastro.pessoa WHERE idpes = {$this->funcionario}");
         $nome_funcionario = $nome;
         $relatorio = new relatorios("Relatório de Diárias - {$nome}", 200, false, "SEGPOG - Departamento de Logística", "A4", "Prefeitura de Itajaí\nSEGPOG - Departamento de Logística\nRua Alberto Werner, 100 - Vila Operária\nCEP. 88304-053 - Itajaí - SC");
         //tamanho do retangulo, tamanho das linhas.
         $relatorio->novaPagina(30, 28);
         $db3 = new clsBanco();
         $db3->Consulta($sql);
         if ($db3->Num_Linhas()) {
             while ($db3->ProximoRegistro()) {
                 list($cod_funcionario, $data_partida, $data_chegada, $valor_total, $objetivo, $destino) = $db3->Tupla();
                 $mes = $meses[date("n", strtotime($data_partida))];
                 if ($mes != $mesAtual) {
                     if ($mesAtual != "") {
                         //$relatorio->novalinha( array( "" ), 1, 10 );
                         $relatorio->novalinha(array(""), 1, 10, false, false, false, false, false, false, true);
                     }
                     $mesAtual = $mes;
                     $relatorio->novalinha(array($mesAtual), 1, 13, true);
                     $relatorio->novalinha(array("Data Partida", "Data Chegada", "Valor Total"), 0, 13, true);
                 }
                 $data_partida = date("d/m/Y H:i", strtotime(substr($data_partida, 0, 19)));
                 $data_chegada = date("d/m/Y H:i", strtotime(substr($data_chegada, 0, 19)));
                 $relatorio->novalinha(array($data_partida, $data_chegada, number_format($valor_total, 2, ',', '.')), 1, 13);
                 $relatorio->novalinha(array("Objetivo: " . $objetivo), 20, 13);
                 $relatorio->novalinha(array("Destino: " . $destino), 20, 13);
             }
             // pega o link e exibe ele ao usuario
             $link = $relatorio->fechaPdf();
             $this->campoRotulo("arquivo", "Arquivo", "<a href='" . $link . "'>Visualizar Relatório</a>");
         } else {
             $this->campoRotulo("aviso", "Aviso", "Nenhum Funcionário neste relatorio.");
         }
     } else {
         $this->campoRotulo("aviso", "Aviso", "Escolha um Funcionário.");
     }
     $this->largura = "100%";
     return true;
 }
 function Novo()
 {
     if ($this->secretaria != 0) {
         if ($this->data_inicial != "" || $this->data_final != "") {
             $AND = '';
             if ($this->data_inicial) {
                 $data = explode("/", $this->data_inicial);
                 $dia_i = $data[0];
                 $mes_i = $data[1];
                 $ano_i = $data[2];
                 $data_inicial = $ano_i . "/" . $mes_i . "/" . $dia_i . " 00:00:00";
                 $AND = " AND data_pedido >= '{$data_inicial}'";
             }
             if ($this->data_final) {
                 $data_ = explode("/", $this->data_final);
                 $dia_f = $data_[0];
                 $mes_f = $data_[1];
                 $ano_f = $data_[2];
                 $data_final = $ano_f . "/" . $mes_f . "/" . $dia_f . " 23:59:59";
                 $AND .= " AND data_pedido <= '{$data_final}'";
             }
         }
         if ($this->secretaria) {
             $sql = "SELECT d.ref_funcionario, d.vl100 + d.vl75 + d.vl50 + d.vl25 FROM pmidrh.diaria d, portal.funcionario f, pmidrh.setor s where d.ref_funcionario = f.ref_cod_pessoa_fj AND d.ref_cod_setor = {$this->secretaria} AND d.ativo = 't' {$AND} GROUP BY d.ref_funcionario, d.vl100, d.vl75, d.vl50, d.vl25";
             //$sql = "SELECT d.ref_funcionario, sum( COALESCE(d.vl100,1) + COALESCE(d.vl75,1) + COALESCE(d.vl50,1) + COALESCE(d.vl25,1) ) FROM pmidrh.diaria d, portal.funcionario f, pmidrh.setor s where d.ref_funcionario = f.ref_cod_pessoa_fj AND d.ref_cod_setor = {$this->secretaria} AND d.ativo = 't' {$AND} GROUP BY d.ref_funcionario";
             $db = new clsBanco();
             $nome = $db->campoUnico(" SELECT nm_setor FROM pmidrh.setor WHERE cod_setor = {$this->secretaria}");
             $relatorio = new relatorios("Relatório de Diárias por Secretaria\nSecretaria: {$nome}", 200, false, "SEGPOG - Departamento de Logística", "A4", "Prefeitura de Itajaí\nSEGPOG - Departamento de Logística\nRua Alberto Werner, 100 - Vila Operária\nCEP. 88304-053 - Itajaí - SC");
             //tamanho do retangulo, tamanho das linhas.
             $relatorio->novaPagina(30, 28);
             $relatorio->novalinha(array("Funcionário", "Valor Total"), 0, 13, true);
             $db = new clsBanco();
             $db->Consulta($sql);
             if ($db->Num_Linhas()) {
                 while ($db->ProximoRegistro()) {
                     list($cod_funcionario, $v100, $v75, $v50, $v25) = $db->Tupla();
                     $db2 = new clsBanco();
                     $nome_funcionario = $db2->campoUnico("SELECT nome FROM cadastro.pessoa WHERE idpes = {$cod_funcionario}");
                     $relatorio->novalinha(array($nome_funcionario, number_format($v100 + $v75 + $v50 + $v25, 2, ',', '.')), 1, 13);
                 }
                 // pega o link e exibe ele ao usuario
                 $link = $relatorio->fechaPdf();
                 $this->campoRotulo("arquivo", "Arquivo", "<a href='" . $link . "'>Visualizar Relatório</a>");
             } else {
                 $this->campoRotulo("aviso", "Aviso", "Nenhum Funcionário neste relatório.");
             }
         } else {
             $this->campoRotulo("aviso", "Aviso", "Escolha uma Secretaria.");
         }
         $this->largura = "100%";
         return true;
     } else {
         $this->campoRotulo("aviso", "Aviso", "Nenhum Funcionário neste relatório.");
     }
 }
Ejemplo n.º 5
0
 function Novo()
 {
     if ($this->data_inicial != "" || $this->data_final != "") {
         $AND = '';
         if ($this->data_inicial) {
             $data = explode("/", $this->data_inicial);
             $dia_i = $data[0];
             $mes_i = $data[1];
             $ano_i = $data[2];
             $data_inicial = $ano_i . "-" . $mes_i . "-" . $dia_i . " 00:00:00";
             $AND = " AND a.data_partida >= '{$data_inicial}'";
         }
         if ($this->data_final) {
             $data_ = explode("/", $this->data_final);
             $dia_f = $data_[0];
             $mes_f = $data_[1];
             $ano_f = $data_[2];
             $data_final = $ano_f . "-" . $mes_f . "-" . $dia_f . " 23:59:59";
             $AND .= " AND a.data_chegada <= '{$data_final}'";
         }
         //			if ($data_inicial <= $data_final)
         //			{
         $sql = "SELECT a.ref_funcionario, b.nome, a.data_partida, a.data_chegada, sum( COALESCE(vl100,0) + COALESCE(vl75,0) + COALESCE(vl50,0) + COALESCE(vl25,0) ) as valor, a.objetivo, a.destino FROM pmidrh.diaria a, cadastro.pessoa b WHERE a.ref_funcionario = b.idpes {$AND} AND ativo = 't' GROUP BY a.ref_funcionario, b.nome, a.data_partida, a.data_chegada, a.objetivo, a.destino ORDER BY b.nome";
         $relatorio = new relatorios("Relatório de Diárias", 200, false, "SEGPOG - Departamento de Logística", "A4", "Prefeitura de Itajaí\nSEGPOG - Departamento de Logística\nRua Alberto Werner, 100 - Vila Operária\nCEP. 88304-053 - Itajaí - SC");
         //tamanho do retangulo, tamanho das linhas.
         $relatorio->novaPagina();
         $db = new clsBanco();
         $db->Consulta($sql);
         if ($db->Num_Linhas()) {
             $old_funcionario = 0;
             $soma_valores = 0;
             while ($db->ProximoRegistro()) {
                 list($cod_funcionario, $nome_funcionario, $data_partida, $data_chegada, $valor_total, $objetivo, $destino) = $db->Tupla();
                 if ($old_funcionario != $cod_funcionario) {
                     $relatorio->novalinha(array("Funcionário: {$nome_funcionario}"), 0, 13, true);
                     $old_funcionario = $cod_funcionario;
                     $relatorio->novalinha(array("Data Partida", "Data Chegada", "Valor Total"));
                 }
                 $data_partida = date("d/m/Y H:i", strtotime(substr($data_partida, 0, 19)));
                 $data_chegada = date("d/m/Y H:i", strtotime(substr($data_chegada, 0, 19)));
                 $relatorio->novalinha(array($data_partida, $data_chegada, number_format($valor_total, 2, ',', '.')), 1, 13);
                 $relatorio->novalinha(array("Destino", $destino));
                 $relatorio->novalinha(array("Objetivo", $objetivo));
                 $relatorio->novalinha(array(""));
                 $soma_valores += $valor_total;
             }
             $relatorio->novalinha(array(""));
             $relatorio->novalinha(array("Valor total do periodo:", number_format($soma_valores, 2, ',', '.')));
             // pega o link e exibe ele ao usuario
             $link = $relatorio->fechaPdf();
             $this->campoRotulo("arquivo", "Arquivo", "<a href='" . $link . "'>Visualizar Relatório</a>");
         } else {
             $this->campoRotulo("aviso", "Aviso", "Nenhum Funcionário neste relatório.");
         }
         //}
         //else
         //{
         //	$this->campoRotulo("aviso", "Aviso", "Data //Chegada maior que a Data Partida.");
         //}
     } else {
         $this->campoRotulo("aviso", "Aviso", "Preencha os campos.");
     }
     $this->largura = "100%";
     return true;
 }
Ejemplo n.º 6
0
 function Novo()
 {
     $this->valor_inicial = str_replace(".", "", $this->valor_inicial);
     $this->valor_inicial = str_replace(",", ".", $this->valor_inicial);
     $this->valor_final = str_replace(".", "", $this->valor_final);
     $this->valor_final = str_replace(",", ".", $this->valor_final);
     if ($this->valor_inicial != "" && $this->valor_final != "") {
         if ($this->valor_inicial <= $this->valor_final) {
             if ($this->data_inicial != "" || $this->data_final != "") {
                 $AND = '';
                 if ($this->data_inicial) {
                     $data = explode("/", $this->data_inicial);
                     $dia_i = $data[0];
                     $mes_i = $data[1];
                     $ano_i = $data[2];
                     $data_inicial = $ano_i . "/" . $mes_i . "/" . $dia_i . " 00:00:00";
                     $AND = " AND data_pedido >= '{$data_inicial}'";
                 }
                 if ($this->data_final) {
                     $data_ = explode("/", $this->data_final);
                     $dia_f = $data_[0];
                     $mes_f = $data_[1];
                     $ano_f = $data_[2];
                     $data_final = $ano_f . "/" . $mes_f . "/" . $dia_f . " 23:59:59";
                     $AND .= " AND data_pedido <= '{$data_final}'";
                 }
             }
             $sql = "SELECT \ta.ref_funcionario, b.nome, a.data_partida, a.data_chegada, sum( COALESCE(vl100,1) + COALESCE(vl75,1) + COALESCE(vl50,1) + COALESCE(vl25,1) ) as valor FROM pmidrh.diaria a, cadastro.pessoa b WHERE a.ref_funcionario = b.idpes AND a.ativo = 't' AND (select sum(vl100+vl75+vl50+vl25) FROM pmidrh.diaria WHERE cod_diaria = a.cod_diaria) BETWEEN {$this->valor_inicial} AND {$this->valor_final} {$AND} GROUP BY a.ref_funcionario, b.nome, a.data_partida, a.data_chegada ORDER BY b.nome";
             $relatorio = new relatorios("Relatório de Diárias", 200, false, "SEGPOG - Departamento de Logística", "A4", "Prefeitura de Itajaí\nSEGPOG - Departamento de Logística\nRua Alberto Werner, 100 - Vila Operária\nCEP. 88304-053 - Itajaí - SC");
             //tamanho do retangulo, tamanho das linhas.
             $relatorio->novaPagina();
             $db = new clsBanco();
             $db->Consulta($sql);
             if ($db->Num_Linhas()) {
                 $old_funcionario = 0;
                 while ($db->ProximoRegistro()) {
                     list($cod_funcionario, $nome_funcionario, $data_partida, $data_chegada, $valor_total) = $db->Tupla();
                     if ($old_funcionario != $cod_funcionario) {
                         $relatorio->novalinha(array("Funcionário: {$nome_funcionario}"), 0, 13, true);
                         $old_funcionario = $cod_funcionario;
                         $relatorio->novalinha(array("Data Partida", "Data Chegada", "Valor Total"), 0, 13, true);
                     }
                     $data_partida = date("d/m/Y H:i", strtotime(substr($data_partida, 0, 19)));
                     $data_chegada = date("d/m/Y H:i", strtotime(substr($data_chegada, 0, 19)));
                     $relatorio->novalinha(array($data_partida, $data_chegada, number_format($valor_total, 2, ',', '.')), 1, 13);
                 }
                 // pega o link e exibe ele ao usuario
                 $link = $relatorio->fechaPdf();
                 $this->campoRotulo("arquivo", "Arquivo", "<a href='" . $link . "'>Visualizar Relatório</a>");
             } else {
                 $this->campoRotulo("aviso", "Aviso", "Nenhum Funcionário neste relatorio.");
             }
         } else {
             $this->campoRotulo("aviso", "Aviso", "Valor Final menor que o Valor Inicial.");
         }
     } else {
         $this->campoRotulo("aviso", "Aviso", "Nenhum Funcionário neste relatorio.");
     }
     $this->largura = "100%";
     return true;
 }