<?xml version="1.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="QueryReport" 
		pageWidth="595" 
		pageHeight="842" 
		columnWidth="515" 
		columnSpacing="0" 
		leftMargin="40" 
		rightMargin="40" 
		topMargin="50" 
		bottomMargin="50"
		whenNoDataType="AllSectionsNoDetail"
		isTitleNewPage="false"
		isSummaryNewPage="false">
	<template>"ReportStyles.jrtx"</template>
	<parameter name="ReportTitle" class="java.lang.String"/>
	<parameter name="ExcludedCities" class="java.util.Collection"/>
	<parameter name="OrderClause" class="java.lang.String"/>
	<queryString><![CDATA[SELECT * FROM Address WHERE $X{NOTIN, City, ExcludedCities} ORDER BY $P!{OrderClause}]]></queryString>
	<field name="Id" class="java.lang.Integer"/>
	<field name="FirstName" class="java.lang.String"/>
	<field name="LastName" class="java.lang.String"/>
	<field name="Street" class="java.lang.String"/>
	<field name="City" class="java.lang.String"/>
	<variable name="CityNumber" class="java.lang.Integer" resetType="Group" resetGroup="CityGroup" calculation="System">
		<initialValueExpression>($V{CityNumber} != null)?(Integer.valueOf($V{CityNumber}.intValue() + 1)):(Integer.valueOf(1))</initialValueExpression>
	</variable>
	<group name="CityGroup" minHeightToStartNewPage="60">
		<groupExpression>
			$F{City}
		</groupExpression>
		<groupHeader>
			<band height="20">
				<textField>
					<reportElement x="0" y="4" width="515" height="16" backcolor="#C0C0C0" mode="Opaque" style="Sans_Bold"/>
					<box>
						<bottomPen lineWidth="1"/>
					</box>
					<textElement textAlignment="Left"/>
					<textFieldExpression class="java.lang.String">
						"  " + String.valueOf($V{CityNumber}) + ". " + String.valueOf($F{City})
					</textFieldExpression>
				</textField>
			</band>
		</groupHeader>
		<groupFooter>
			<band height="20">
				<line>
					<reportElement x="0" y="-1" width="515" height="0"/>
				</line>
				<staticText>
					<reportElement x="400" y="0" width="60" height="15" style="Sans_Bold"/>
					<textElement textAlignment="Right" lineSpacing="Single"/>
					<text>Count : </text>
				</staticText>
				<textField>
					<reportElement x="460" y="0" width="30" height="15" style="Sans_Bold"/>
					<textElement textAlignment="Right" lineSpacing="Single"/>
					<textFieldExpression class="java.lang.Integer">
						$V{CityGroup_COUNT}
					</textFieldExpression>
				</textField>
			</band>
		</groupFooter>
	</group>
	<background>
		<band height="742">
			<image scaleImage="Clip" hAlign="Left" vAlign="Bottom">
				<reportElement x="0" y="0" width="150" height="742"/>
				<imageExpression>"jr.watermark.gif"</imageExpression>
			</image>
		</band>
	</background>
	<title>
		<band height="50">
			<line>
				<reportElement x="0" y="0" width="515" height="0" forecolor="black"/>
			</line>
			<textField isBlankWhenNull="true">
				<reportElement x="0" y="10" width="515" height="30" style="Sans_Normal"/>
				<textElement textAlignment="Center" lineSpacing="Single">
					<font size="22"/>
				</textElement>
				<textFieldExpression class="java.lang.String">$P{ReportTitle}</textFieldExpression>
			</textField>
		</band>
	</title>
	<pageHeader>
		<band height="20">
			<staticText>
				<reportElement x="0" y="5" width="55" height="15" forecolor="white" backcolor="#333333" mode="Opaque" style="Sans_Bold"/>
				<textElement textAlignment="Center"/>
				<text>ID</text>
			</staticText>
			<staticText>
				<reportElement x="55" y="5" width="205" height="15" forecolor="white" backcolor="#333333" mode="Opaque" style="Sans_Bold"/>
				<text>Name</text>
			</staticText>
			<staticText>
				<reportElement x="260" y="5" width="255" height="15" forecolor="white" backcolor="#333333" mode="Opaque" style="Sans_Bold"/>
				<text>Street</text>
			</staticText>
		</band>
	</pageHeader>
	<detail>
		<band height="20">
			<textField>
				<reportElement x="0" y="4" width="50" height="15"/>
				<textElement textAlignment="Right"/>
				<textFieldExpression class="java.lang.Integer">
					$F{Id}
				</textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true">
				<reportElement x="55" y="4" width="200" height="15" positionType="Float"/>
				<textFieldExpression class="java.lang.String">
					$F{FirstName} + " " + $F{LastName}
				</textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true">
				<reportElement x="260" y="4" width="255" height="15" positionType="Float"/>
				<textFieldExpression class="java.lang.String">
					$F{Street}
				</textFieldExpression>
			</textField>
			<line>
				<reportElement x="0" y="19" width="515" height="0" forecolor="#808080" positionType="Float"/>
			</line>
		</band>
	</detail>
	<pageFooter>
		<band height="40">
			<printWhenExpression>$P{IS_IGNORE_PAGINATION}.booleanValue()?Boolean.FALSE:Boolean.TRUE</printWhenExpression>
			<line>
				<reportElement x="0" y="10" width="515" height="0"/>
			</line>
			<textField>
				<reportElement x="200" y="20" width="80" height="15"/>
				<textElement textAlignment="Right"/>
				<textFieldExpression class="java.lang.String">
					"Page " + String.valueOf($V{PAGE_NUMBER}) + " of"
				</textFieldExpression>
			</textField>
			<textField evaluationTime="Report">
				<reportElement x="280" y="20" width="75" height="15"/>
				<textElement textAlignment="Left"/>
				<textFieldExpression class="java.lang.String">
					" " + String.valueOf($V{PAGE_NUMBER})
				</textFieldExpression>
			</textField>
		</band>
	</pageFooter>
	<summary>
		<band height="60">
			<textField isStretchWithOverflow="true">
				<reportElement x="175" y="20" width="165" height="15" style="Sans_Italic"/>
				<textElement textAlignment="Center"/>
				<textFieldExpression class="java.lang.String">
					"There were " + 
					String.valueOf($V{REPORT_COUNT}) + 
					" address records on this report."
				</textFieldExpression>
			</textField>
		</band>
	</summary>
</jasperReport>
