<?xml version="1.0" encoding="UTF-8"?>
<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="no_ana_demo_pla_perso_sexo" language="groovy" pageWidth="572" pageHeight="752" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">
	<property name="ireport.zoom" value="1.2100000000000009"/>
	<property name="ireport.x" value="0"/>
	<property name="ireport.y" value="0"/>
	<property name="ireport.jasperserver.reportUnit" value="/reports/nomina/no_ana_demo_pla_perso"/>
	<property name="ireport.jasperserver.url" value="http://192.168.2.43:8090/jasperserver/services/repository"/>
	<parameter name="id_periodo" class="java.math.BigDecimal">
		<defaultValueExpression><![CDATA[]]></defaultValueExpression>
	</parameter>
	<queryString>
		<![CDATA[SELECT ROWNUM AS NUM, tab0.*, (SELECT sum(tab0.cantidad) as total FROM(

select * from (

 select ROWNUM as numero,'1' as SEXO, '1' as todo,tablados.* from (

  select  tabla.descripcion,count(tabla.masculino) as cantidad
 from(
    select
    dat.sexo,
    ar.id_area,
    tab8.descripcion,
    -- 1 femenino - 2 masculino
    case when dat.sexo = 2 then 1 else 0 end as masculino
    from no_estado_func_v est

    join no_periodo_v per   on per.id_periodo = est.periodo

    join datos_funcionario dat    on est.id_tipo_doc = dat.id_tipo_doc and est.num_doc = dat.num_doc

    left join no_nombramiento_v nom    on nom.id_tipo_doc = est.id_tipo_doc and nom.num_doc = est.num_doc

    left join area ar on est.id_ea=ar.id_area

    LEFT JOIN rh_pn_jerarquia tab8 ON tab8.id_pn_jer=ar.id_nivel

    where 1=1 and dat.sexo=2  and         est.periodo =$P{id_periodo}
    and (
        nom.estado = 1
        or
        (
          nom.estado = 0
          and nom.fecha_termina > per.fecha_fin
        )
    )

    )tabla
    group by tabla.descripcion



)tablados


)
union
select * from (

 select ROWNUM as numero,'2' as SEXO,'1' as todo,tablados.* from (

  select  tabla.descripcion,count(tabla.femenino) as cantidad
 from(
    select
    dat.sexo,
    ar.id_area,
    tab8.descripcion,
    -- 1 femenino - 2 masculino
    case when dat.sexo = 2 then 1 else 0 end as femenino
    from no_estado_func_v est

    join no_periodo_v per   on per.id_periodo = est.periodo

    join datos_funcionario dat    on est.id_tipo_doc = dat.id_tipo_doc and est.num_doc = dat.num_doc

    left join no_nombramiento_v nom    on nom.id_tipo_doc = est.id_tipo_doc and nom.num_doc = est.num_doc

    left join area ar on est.id_ea=ar.id_area

    LEFT JOIN rh_pn_jerarquia tab8 ON tab8.id_pn_jer=ar.id_nivel

    where 1=1 and dat.sexo=1 and         est.periodo = $P{id_periodo}
    and (
        nom.estado = 1
        or
        (
          nom.estado = 0
          and nom.fecha_termina > per.fecha_fin
        )
    )

    )tabla
    group by tabla.descripcion



)tablados


)


)tab0

) as total FROM(

select * from (

 select ROWNUM as numero,'1' as SEXO,tablados.* from (

  select  tabla.descripcion,count(tabla.masculino) as cantidad
 from(
    select
    dat.sexo,
    ar.id_area,
    tab8.descripcion,
    -- 1 femenino - 2 masculino
    case when dat.sexo = 2 then 1 else 0 end as masculino
    from no_estado_func_v est

    join no_periodo_v per   on per.id_periodo = est.periodo

    join datos_funcionario dat    on est.id_tipo_doc = dat.id_tipo_doc and est.num_doc = dat.num_doc

    left join no_nombramiento_v nom    on nom.id_tipo_doc = est.id_tipo_doc and nom.num_doc = est.num_doc

    left join area ar on est.id_ea=ar.id_area

    LEFT JOIN rh_pn_jerarquia tab8 ON tab8.id_pn_jer=ar.id_nivel

    where 1=1 and dat.sexo=2  and         est.periodo = $P{id_periodo}
    and (
        nom.estado = 1
        or
        (
          nom.estado = 0
          and nom.fecha_termina > per.fecha_fin
        )
    )

    )tabla
    group by tabla.descripcion



)tablados


)
union
select * from (

 select ROWNUM as numero,'2' as SEXO,tablados.* from (

  select  tabla.descripcion,count(tabla.femenino) as cantidad
 from(
    select
    dat.sexo,
    ar.id_area,
    tab8.descripcion,
    -- 1 femenino - 2 masculino
    case when dat.sexo = 2 then 1 else 0 end as femenino
    from no_estado_func_v est

    join no_periodo_v per   on per.id_periodo = est.periodo

    join datos_funcionario dat    on est.id_tipo_doc = dat.id_tipo_doc and est.num_doc = dat.num_doc

    left join no_nombramiento_v nom    on nom.id_tipo_doc = est.id_tipo_doc and nom.num_doc = est.num_doc

    left join area ar on est.id_ea=ar.id_area

    LEFT JOIN rh_pn_jerarquia tab8 ON tab8.id_pn_jer=ar.id_nivel

    where 1=1 and dat.sexo=1 and         est.periodo = $P{id_periodo}
    and (
        nom.estado = 1
        or
        (
          nom.estado = 0
          and nom.fecha_termina > per.fecha_fin
        )
    )

    )tabla
    group by tabla.descripcion



)tablados


)





)tab0
order by tab0.sexo,tab0.numero]]>
	</queryString>
	<field name="NUM" class="java.math.BigDecimal"/>
	<field name="NUMERO" class="java.math.BigDecimal"/>
	<field name="SEXO" class="java.lang.String"/>
	<field name="DESCRIPCION" class="java.lang.String"/>
	<field name="CANTIDAD" class="java.math.BigDecimal"/>
	<field name="TOTAL" class="java.math.BigDecimal"/>
	<variable name="cantidad" class="java.math.BigDecimal" calculation="Sum">
		<variableExpression><![CDATA[$F{CANTIDAD}]]></variableExpression>
		<initialValueExpression><![CDATA[0]]></initialValueExpression>
	</variable>
	<variable name="variable1" class="java.math.BigDecimal" calculation="Sum">
		<variableExpression><![CDATA[$F{CANTIDAD}]]></variableExpression>
		<initialValueExpression><![CDATA[0]]></initialValueExpression>
	</variable>
	<columnHeader>
		<band height="38" splitType="Stretch">
			<staticText>
				<reportElement x="0" y="0" width="572" height="20"/>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font size="8" isBold="true"/>
				</textElement>
				<text><![CDATA[DISTRIBUCIÓN POR GENERO Y NIVEL JERARQUICO]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="281" y="26" width="100" height="12" forecolor="#000000" backcolor="#AED6FB"/>
				<box>
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
					<font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
				</textElement>
				<text><![CDATA[Cantidad]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="181" y="26" width="100" height="12" forecolor="#000000" backcolor="#AED6FB"/>
				<box>
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
					<font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
				</textElement>
				<text><![CDATA[Nivel Jerarquico]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="81" y="26" width="100" height="12" forecolor="#000000" backcolor="#AED6FB"/>
				<box>
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
					<font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
				</textElement>
				<text><![CDATA[Sexo]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="381" y="26" width="100" height="12" forecolor="#000000" backcolor="#AED6FB"/>
				<box>
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
					<font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
				</textElement>
				<text><![CDATA[Porcentaje]]></text>
			</staticText>
		</band>
	</columnHeader>
	<detail>
		<band height="10" splitType="Stretch">
			<textField isStretchWithOverflow="true" pattern="#,##0.00" isBlankWhenNull="true">
				<reportElement x="281" y="0" width="100" height="10"/>
				<box>
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Center">
					<font size="8"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{CANTIDAD}]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
				<reportElement x="181" y="0" width="100" height="10"/>
				<box leftPadding="2">
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement>
					<font size="8"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[( $F{DESCRIPCION}!=null
    ? $F{DESCRIPCION}
    : "DIRECTIVO"
)]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
				<reportElement x="81" y="0" width="100" height="10"/>
				<box leftPadding="2">
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement>
					<font size="8"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[( $F{SEXO}=='1'
    ? "Femenino"
    : "Masculino"
)]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true" pattern="#,##0.00" isBlankWhenNull="true">
				<reportElement x="381" y="0" width="100" height="10"/>
				<box>
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Center">
					<font size="8"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{CANTIDAD}/$F{TOTAL}*100]]></textFieldExpression>
			</textField>
		</band>
	</detail>
	<columnFooter>
		<band height="13" splitType="Stretch"/>
	</columnFooter>
	<summary>
		<band height="150" splitType="Stretch">
			<staticText>
				<reportElement mode="Opaque" x="81" y="0" width="200" height="10" forecolor="#000000" backcolor="#AED6FB"/>
				<box>
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
					<font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
				</textElement>
				<text><![CDATA[Total]]></text>
			</staticText>
			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
				<reportElement mode="Opaque" x="281" y="0" width="100" height="10" backcolor="#CFCFCF"/>
				<box>
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Center">
					<font size="8"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{cantidad}]]></textFieldExpression>
			</textField>
			<stackedBar3DChart>
				<chart>
					<reportElement x="0" y="28" width="572" height="122"/>
					<chartTitle/>
					<chartSubtitle/>
					<chartLegend/>
				</chart>
				<categoryDataset>
					<categorySeries>
						<seriesExpression><![CDATA[( $F{SEXO}=='1'
    ? "Femenino"
    : "Masculino"
)]]></seriesExpression>
						<categoryExpression><![CDATA[( $F{DESCRIPCION}!=null
    ? $F{DESCRIPCION}
    : "DIRECTIVO"
)]]></categoryExpression>
						<valueExpression><![CDATA[$F{CANTIDAD}]]></valueExpression>
						<labelExpression><![CDATA[( $F{DESCRIPCION}!=null
    ? $F{DESCRIPCION}
    : "DIRECTIVO"
)]]></labelExpression>
					</categorySeries>
				</categoryDataset>
				<bar3DPlot>
					<plot/>
					<itemLabel color="#000000" backgroundColor="#FFFFFF"/>
					<categoryAxisFormat>
						<axisFormat>
							<labelFont/>
							<tickLabelFont/>
						</axisFormat>
					</categoryAxisFormat>
					<valueAxisFormat>
						<axisFormat>
							<labelFont/>
							<tickLabelFont/>
						</axisFormat>
					</valueAxisFormat>
				</bar3DPlot>
			</stackedBar3DChart>
			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
				<reportElement mode="Opaque" x="381" y="0" width="100" height="10" backcolor="#CFCFCF"/>
				<box>
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Center">
					<font size="8"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[($V{cantidad}/$F{TOTAL})*100]]></textFieldExpression>
			</textField>
		</band>
	</summary>
</jasperReport>
