Skip to content

Commit

Permalink
Relatório de autores
Browse files Browse the repository at this point in the history
  • Loading branch information
edersoares committed Sep 27, 2018
1 parent a79bf14 commit bf48c9c
Show file tree
Hide file tree
Showing 4 changed files with 442 additions and 0 deletions.
196 changes: 196 additions & 0 deletions ReportSources/library-authors.jrxml
@@ -0,0 +1,196 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.0 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="library-authors" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="ff823efd-75fc-4ad7-ae5f-fa380463488d">
<parameter name="instituicao" class="java.lang.Integer">
<defaultValueExpression><![CDATA[new java.lang.Integer(0)]]></defaultValueExpression>
</parameter>
<parameter name="escola" class="java.lang.Integer">
<defaultValueExpression><![CDATA[new java.lang.Integer(0)]]></defaultValueExpression>
</parameter>
<parameter name="logo" class="java.lang.String"/>
<parameter name="ordem" class="java.lang.String"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String"/>
<parameter name="database" class="java.lang.String"/>
<parameter name="data_emissao" class="java.lang.String"/>
<parameter name="source" class="java.lang.String"/>
<field name="nm_instituicao" class="java.lang.String"/>
<field name="cod_acervo_autor" class="java.lang.Integer"/>
<field name="nm_autor" class="java.lang.String"/>
<field name="descricao" class="java.lang.String"/>
<field name="ref_cod_biblioteca" class="java.lang.Integer"/>
<field name="nm_biblioteca" class="java.lang.String"/>
<field name="nm_escola" class="java.lang.String"/>
<field name="logradouro" class="java.lang.String"/>
<field name="bairro" class="java.lang.String"/>
<field name="municipio" class="java.lang.String"/>
<field name="numero" class="java.math.BigDecimal"/>
<field name="uf_municipio" class="java.lang.String"/>
<field name="fone_ddd" class="java.lang.String"/>
<field name="cep" class="java.lang.String"/>
<field name="fone" class="java.lang.String"/>
<field name="email" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="103" splitType="Stretch">
<image>
<reportElement x="9" y="3" width="57" height="46" uuid="92a8bbdb-0896-4749-a08c-1653a5a9c2e3"/>
<imageExpression><![CDATA[$P{logo}]]></imageExpression>
</image>
<staticText>
<reportElement x="192" y="79" width="138" height="14" uuid="9c36fbc4-ac0d-4a9a-9196-28797e2dc5f6"/>
<textElement textAlignment="Center">
<font fontName="DejaVu Sans" size="12" isBold="true"/>
</textElement>
<text><![CDATA[Autores]]></text>
</staticText>
</band>
</title>
<pageHeader>
<band height="15" splitType="Stretch">
<textField isBlankWhenNull="true">
<reportElement x="75" y="-72" width="307" height="13" uuid="fa6a8b45-b6f5-44b3-a146-aaf65df8edaf"/>
<textElement>
<font fontName="DejaVu Sans" size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA["Endereço: "+$F{logradouro}+", "+$F{numero}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="75" y="-100" width="307" height="13" uuid="ce19fa21-7328-4a02-b28f-17c82bbc03ae"/>
<textElement>
<font fontName="DejaVu Sans" size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{nm_instituicao}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="305" y="-48" width="233" height="13" forecolor="#000000" uuid="636e13b9-bfff-4fa8-a18a-5fc3d5c181be"/>
<textElement>
<font fontName="DejaVu Sans" size="8" isBold="true" isItalic="false"/>
</textElement>
<textFieldExpression><![CDATA["E-mail: "+$F{email}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="305" y="-60" width="141" height="13" uuid="fea0317c-b154-42a1-9666-798706fe5f3d"/>
<textElement>
<font fontName="DejaVu Sans" size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{municipio}+" - "+$F{uf_municipio}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="449" y="-60" width="77" height="13" uuid="adcd0540-6f15-4f65-b545-5c7ab8598e03"/>
<textElement>
<font fontName="DejaVu Sans" size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA["CEP: "+$F{cep}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="75" y="-86" width="307" height="13" uuid="e91902f9-34fa-4ccc-9321-bd98b920a44d"/>
<textElement>
<font fontName="DejaVu Sans" size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{nm_escola}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="75" y="-60" width="228" height="13" uuid="d98a7f55-d02d-4f8e-b839-475d1f68d893"/>
<textElement>
<font fontName="DejaVu Sans" size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA["Bairro:" +$F{bairro}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="75" y="-48" width="201" height="13" uuid="c13381d9-31ae-4ae8-8a33-32510373b74d"/>
<textElement>
<font fontName="DejaVu Sans" size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA["Telefone: ("+$F{fone_ddd}+") "+$F{fone}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="11" y="1" width="292" height="13" uuid="8da7af30-27b7-4349-8ba5-7d3e84108b0e"/>
<textElement>
<font fontName="DejaVu Sans" size="8"/>
</textElement>
<textFieldExpression><![CDATA["Biblioteca: "+$F{nm_biblioteca}]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<columnHeader>
<band height="18" splitType="Stretch">
<staticText>
<reportElement x="279" y="1" width="100" height="13" uuid="c41b4b27-6e74-4418-8f84-60491741ae8a"/>
<textElement>
<font fontName="DejaVu Sans" size="8"/>
</textElement>
<text><![CDATA[Descrição]]></text>
</staticText>
<staticText>
<reportElement x="25" y="1" width="35" height="13" uuid="78437f30-d99b-472b-8bad-9e5c5e9bcdec"/>
<textElement>
<font fontName="DejaVu Sans" size="8"/>
</textElement>
<text><![CDATA[Código]]></text>
</staticText>
<staticText>
<reportElement x="67" y="1" width="100" height="13" uuid="c69233c2-5092-4152-85d6-72aeae300c67"/>
<textElement>
<font fontName="DejaVu Sans" size="8"/>
</textElement>
<text><![CDATA[Autor]]></text>
</staticText>
<line>
<reportElement x="7" y="15" width="544" height="1" uuid="000518be-eb1d-48ed-a65f-0e9c625a4ca9"/>
<graphicElement>
<pen lineWidth="0.25"/>
</graphicElement>
</line>
</band>
</columnHeader>
<detail>
<band height="15" splitType="Stretch">
<textField isBlankWhenNull="true">
<reportElement x="279" y="1" width="259" height="13" uuid="4f4b607f-d81e-4cf5-9b0e-77a7b46a7cd5"/>
<textElement>
<font fontName="DejaVu Sans" size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{descricao}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="25" y="1" width="35" height="13" uuid="27bfe41c-f4c7-4ec0-873d-a695ac5edf1d"/>
<textElement>
<font fontName="DejaVu Sans" size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{cod_acervo_autor}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="67" y="1" width="209" height="13" uuid="95e7c80c-18d0-4024-ad0f-d615c8e10052"/>
<textElement>
<font fontName="DejaVu Sans" size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{nm_autor}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="2" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="20" splitType="Stretch">
<textField>
<reportElement x="25" y="5" width="100" height="13" uuid="5df887b2-1c0b-47e2-93a7-500b1ea8c176"/>
<textElement>
<font fontName="DejaVu Sans" size="8"/>
</textElement>
<textFieldExpression><![CDATA["Total de autores: "+$V{REPORT_COUNT}]]></textFieldExpression>
</textField>
<line>
<reportElement x="7" y="2" width="544" height="1" uuid="43a64607-e174-47c0-93a7-e319ab53ae62"/>
<graphicElement>
<pen lineWidth="0.25"/>
</graphicElement>
</line>
</band>
</pageFooter>
<summary>
<band height="3" splitType="Stretch"/>
</summary>
</jasperReport>
143 changes: 143 additions & 0 deletions Reports/LibraryAuthorsReport.php
@@ -0,0 +1,143 @@
<?php

use iEducar\Reports\JsonDataSource;

require_once 'lib/Portabilis/Report/ReportCore.php';
require_once 'App/Model/IedFinder.php';

class LibraryAuthorsReport extends Portabilis_Report_ReportCore
{
use JsonDataSource;

/**
* @inheritdoc
*/
public function templateName()
{
return 'library-authors';
}

/**
* @inheritdoc
*/
public function requiredArgs()
{
$this->addRequiredArg('instituicao');
$this->addRequiredArg('escola');
}

/**
* Retorna o SQL para buscar os dados do relatório principal.
*
* TODO: refactor query
*
* @return string
*/
public function getSqlMainReport()
{
$instituicao = $this->args['instituicao'] ?: 0;
$escola = $this->args['escola'] ?: 0;

return "
SELECT
public.fcn_upper(instituicao.nm_instituicao) as nm_instituicao,
cod_acervo_autor,
public.fcn_upper(relatorio.get_texto_sem_caracter_especial(nm_autor)) as nm_autor,
descricao,
ref_cod_biblioteca,
(SELECT biblioteca.nm_biblioteca
FROM pmieducar.biblioteca
WHERE acervo_autor.ref_cod_biblioteca = biblioteca.cod_biblioteca) as nm_biblioteca,
relatorio.get_nome_escola(escola.cod_escola) AS nm_escola,
(SELECT COALESCE((SELECT COALESCE((SELECT logradouro.nome
FROM public.logradouro,
cadastro.juridica,
cadastro.pessoa ps,
cadastro.endereco_pessoa
WHERE juridica.idpes = ps.idpes AND
ps.idpes = endereco_pessoa.idpes AND
endereco_pessoa.idlog = logradouro.idlog AND
juridica.idpes = escola.ref_idpes),(SELECT endereco_externo.logradouro
FROM cadastro.endereco_externo
WHERE endereco_externo.idpes = escola.ref_idpes))),(SELECT logradouro FROM pmieducar.escola_complemento where ref_cod_escola = escola.cod_escola))) AS logradouro,
(SELECT COALESCE((SELECT COALESCE((SELECT bairro.nome
FROM public.municipio,
cadastro.endereco_pessoa,
cadastro.juridica,
public.bairro
WHERE endereco_pessoa.idbai = bairro.idbai AND
bairro.idmun = municipio.idmun AND
juridica.idpes = endereco_pessoa.idpes AND
juridica.idpes = escola.ref_idpes),(SELECT endereco_externo.bairro FROM cadastro.endereco_externo WHERE endereco_externo.idpes = escola.ref_idpes))),(SELECT bairro FROM pmieducar.escola_complemento where ref_cod_escola = escola.cod_escola))) AS bairro,
(SELECT COALESCE((SELECT COALESCE ((SELECT municipio.nome
FROM public.municipio,
cadastro.endereco_pessoa,
cadastro.juridica,
public.bairro
WHERE endereco_pessoa.idbai = bairro.idbai AND
bairro.idmun = municipio.idmun AND
juridica.idpes = endereco_pessoa.idpes AND
juridica.idpes = escola.ref_idpes), (SELECT endereco_externo.cidade FROM cadastro.endereco_externo WHERE endereco_externo.idpes = escola.ref_idpes))),(SELECT municipio FROM pmieducar.escola_complemento where ref_cod_escola = escola.cod_escola))) AS municipio,
(SELECT COALESCE((SELECT COALESCE((SELECT endereco_pessoa.numero
FROM cadastro.endereco_pessoa,
cadastro.juridica
WHERE juridica.idpes = endereco_pessoa.idpes AND
juridica.idpes = escola.ref_idpes),(SELECT endereco_externo.numero FROM cadastro.endereco_externo WHERE endereco_externo.idpes = escola.ref_idpes))),(SELECT numero FROM pmieducar.escola_complemento where ref_cod_escola = escola.cod_escola))) AS numero,
(SELECT COALESCE((SELECT COALESCE((SELECT municipio.sigla_uf
FROM public.municipio,
cadastro.endereco_pessoa,
cadastro.juridica,
public.bairro
WHERE endereco_pessoa.idbai = bairro.idbai AND
bairro.idmun = municipio.idmun AND
juridica.idpes = endereco_pessoa.idpes AND
juridica.idpes = escola.ref_idpes),(SELECT endereco_externo.sigla_uf FROM cadastro.endereco_externo WHERE endereco_externo.idpes = escola.ref_idpes))),(select inst.ref_sigla_uf from pmieducar.instituicao inst where inst.cod_instituicao = instituicao.cod_instituicao))) AS uf_municipio,
(SELECT COALESCE((SELECT min(to_char(fone_pessoa.ddd,'99'))
FROM cadastro.fone_pessoa,
cadastro.juridica
WHERE juridica.idpes = fone_pessoa.idpes AND
juridica.idpes = escola.ref_idpes),COALESCE((SELECT min(to_char(ddd_telefone,'99')) FROM pmieducar.escola_complemento where ref_cod_escola = escola.cod_escola),''))) AS fone_ddd,
(SELECT COALESCE((SELECT COALESCE((SELECT to_char(endereco_pessoa.cep, '99999-999')
FROM cadastro.endereco_pessoa,
cadastro.juridica
WHERE juridica.idpes = endereco_pessoa.idpes AND
juridica.idpes = escola.ref_idpes),(SELECT to_char(endereco_externo.cep,'99999-999') FROM cadastro.endereco_externo WHERE endereco_externo.idpes = escola.ref_idpes))),(SELECT to_char(escola_complemento.cep,'99999-999') FROM pmieducar.escola_complemento where escola_complemento.ref_cod_escola = escola.cod_escola))) AS cep,
(SELECT COALESCE((SELECT min(to_char(fone_pessoa.fone, '9999-9999'))
FROM cadastro.fone_pessoa,
cadastro.juridica
WHERE juridica.idpes = fone_pessoa.idpes AND
juridica.idpes = escola.ref_idpes),COALESCE((SELECT min(to_char(telefone, '9999-9999')) FROM pmieducar.escola_complemento where escola_complemento.ref_cod_escola = escola.cod_escola),''))) AS fone,
(SELECT COALESCE((SELECT ps.email
FROM cadastro.pessoa ps,
cadastro.juridica
WHERE juridica.idpes = ps.idpes AND
juridica.idpes = escola.ref_idpes),(SELECT email FROM pmieducar.escola_complemento where ref_cod_escola = escola.cod_escola))) AS email
FROM pmieducar.instituicao
INNER JOIN pmieducar.escola ON TRUE
AND escola.ref_cod_instituicao = instituicao.cod_instituicao
INNER JOIN pmieducar.biblioteca ON TRUE
AND biblioteca.ref_cod_escola = escola.cod_escola
INNER JOIN pmieducar.acervo_autor ON TRUE
AND acervo_autor.ref_cod_biblioteca = biblioteca.cod_biblioteca
WHERE TRUE
AND instituicao.cod_instituicao = {$instituicao}
AND escola.cod_escola = {$escola}
AND acervo_autor.ativo = 1
ORDER BY nm_autor
";
}
}
58 changes: 58 additions & 0 deletions Views/LibraryAuthorsController.php
@@ -0,0 +1,58 @@
<?php

require_once 'lib/Portabilis/Controller/ReportCoreController.php';
require_once 'Reports/Reports/LibraryAuthorsReport.php';

class LibraryAuthorsController extends Portabilis_Controller_ReportCoreController
{
/**
* @var int
*/
protected $_processoAp = 625;

/**
* @var string
*/
protected $_titulo = 'Relatório de Autores';

/**
* @inheritdoc
*/
protected function _preRender()
{
parent::_preRender();

Portabilis_View_Helper_Application::loadStylesheet($this, 'intranet/styles/localizacaoSistema.css');

$this->breadcrumb('Relatório de Autores', [
'educar_biblioteca_index.php' => 'Biblioteca',
]);
}

/**
* @inheritdoc
*/
public function form()
{
$this->inputsHelper()->dynamic(['instituicao', 'escola']);
}

/**
* @inheritdoc
*/
public function beforeValidation()
{
$this->report->addArg('instituicao', (int) $this->getRequest()->ref_cod_instituicao);
$this->report->addArg('escola', (int) $this->getRequest()->ref_cod_escola);
}

/**
* @return LibraryAuthorsReport
*
* @throws Exception
*/
public function report()
{
return new LibraryAuthorsReport();
}
}

0 comments on commit bf48c9c

Please sign in to comment.