<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//EN"
	"http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">

<jasperReport name="BasicReport" pageWidth="565" pageHeight="842" columnWidth="545"
	leftMargin="10" rightMargin="10" topMargin="30" bottomMargin="30">

	<reportFont name="Arial_Normal" isDefault="true" fontName="Arial" size="12"
		isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false"
		pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false" />

	<reportFont name="Arial_Bold" isDefault="false" fontName="Arial" size="12"
		isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false"
		pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false" />

	<reportFont name="Arial_Italic" isDefault="false" fontName="Arial" size="12"
		isBold="false" isItalic="true" isUnderline="false" isStrikeThrough="false"
		pdfFontName="Helvetica-Oblique" pdfEncoding="Cp1252" isPdfEmbedded="false" />

	<parameter name="Title" class="java.lang.String"></parameter>
	<parameter name="BaseDir" class="java.io.File"></parameter>
	<parameter name="state_abbr" class="java.lang.String"></parameter>
	<queryString>
		<![CDATA[select first_name, last_name, city, state, email, age,
			count(b.order_id) as no_order from sample.customer as a inner
			join sample.customer_order as b on (a.customer_id=b.customer_id)
			where state=$P{state_abbr} group by first_name, last_name,
			city, state, email, age]]>
	</queryString>
	<field name="first_name" class="java.lang.String"></field>
	<field name="last_name" class="java.lang.String"></field>
	<field name="city" class="java.lang.String"></field>

	<field name="state" class="java.lang.String"></field>
	<field name="email" class="java.lang.String"></field>
	<field name="age" class="java.lang.Integer"></field>
	<field name="no_order" class="java.lang.Integer"></field>

	<title>
		<band height="50">
			<line>
				<reportElement x="0" y="0" width="520" height="1" />
				<graphicElement />
			</line>
			<image scaleImage="Clip" vAlign="Middle">
				<reportElement x="0" y="5" width="32" height="32" />
				<graphicElement />
				<imageExpression class="java.io.File">
					<![CDATA[new File($P{BaseDir}, "customer.gif")]]>
				</imageExpression>
			</image>
			<textField isBlankWhenNull="true">
				<reportElement x="40" y="10" width="420" height="30" />
				<textElement textAlignment="Left">
					<font reportFont="Arial_Normal" size="22" />
				</textElement>
				<textFieldExpression class="java.lang.String">
					<![CDATA[$P{Title}]]>
				</textFieldExpression>
			</textField>
		</band>
	</title>
	<pageHeader>
		<band height="20">
			<textField>
				<reportElement mode="Opaque" x="0" y="5" width="520" height="15"
					forecolor="#ffffff" backcolor="#666666" />
				<textElement textAlignment="Left">
					<font reportFont="Arial_Bold" />
				</textElement>
				<textFieldExpression class="java.lang.String">
					<![CDATA["Customers in " + $P{state_abbr}]]>
				</textFieldExpression>
			</textField>
		</band>
	</pageHeader>
	<columnHeader>
		<band height="20">
			<staticText>
				<reportElement mode="Opaque" x="0" y="5" width="130" height="15"
					forecolor="#ffffff" backcolor="#bbbbbb" />
				<textElement textAlignment="Left">
					<font reportFont="Arial_Bold" />
				</textElement>
				<text>
					<![CDATA[Name]]>
				</text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="130" y="5" width="130" height="15"
					forecolor="#ffffff" backcolor="#bbbbbb" />
				<textElement textAlignment="Left">
					<font reportFont="Arial_Bold" />
				</textElement>
				<text>
					<![CDATA[Location]]>
				</text>
			</staticText>

			<staticText>
				<reportElement mode="Opaque" x="260" y="5" width="150" height="15"
					forecolor="#ffffff" backcolor="#bbbbbb" />
				<textElement textAlignment="Left">
					<font reportFont="Arial_Bold" />
				</textElement>
				<text>
					<![CDATA[Email]]>
				</text>
			</staticText>

			<staticText>
				<reportElement mode="Opaque" x="410" y="5" width="30" height="15"
					forecolor="#ffffff" backcolor="#bbbbbb" />
				<textElement textAlignment="Left">
					<font reportFont="Arial_Bold" />
				</textElement>
				<text>
					<![CDATA[Age]]>
				</text>
			</staticText>

			<staticText>
				<reportElement mode="Opaque" x="440" y="5" width="80" height="15"
					forecolor="#ffffff" backcolor="#bbbbbb" />
				<textElement textAlignment="Left">
					<font reportFont="Arial_Bold" />
				</textElement>
				<text>
					<![CDATA[No. of Orders]]>
				</text>
			</staticText>
		</band>
	</columnHeader>
	<detail>
		<band height="20">
			<textField>
				<reportElement x="0" y="4" width="130" height="15" />
				<textElement textAlignment="Left" />
				<textFieldExpression class="java.lang.String">
					<![CDATA[$F{last_name} + ", " + $F{first_name}]]>
				</textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true">
				<reportElement positionType="Float" x="130" y="4"
					width="130" height="15" />
				<textElement />
				<textFieldExpression class="java.lang.String">
					<![CDATA[$F{city} + ", " + $F{state}]]>
				</textFieldExpression>
			</textField>

			<textField isStretchWithOverflow="true">
				<reportElement positionType="Float" x="260" y="4"
					width="150" height="15" />
				<textElement />
				<textFieldExpression class="java.lang.String">
					<![CDATA[$F{email}]]>
				</textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true">
				<reportElement positionType="Float" x="410" y="4"
					width="30" height="15" />
				<textElement textAlignment="Center" />
				<textFieldExpression class="java.lang.String">
					<![CDATA[String.valueOf($F{age})]]>
				</textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true">
				<reportElement positionType="Float" x="440" y="4"
					width="80" height="15" />
				<textElement textAlignment="Center" />
				<textFieldExpression class="java.lang.String">
					<![CDATA[String.valueOf($F{no_order})]]>
				</textFieldExpression>
			</textField>
			<line>
				<reportElement positionType="Float" x="0" y="19" width="520" height="1"
					forecolor="#808080" />
				<graphicElement />
			</line>
		</band>
	</detail>
	<pageFooter>
		<band height="40">
			<line>
				<reportElement x="0" y="10" width="520" height="1" />
				<graphicElement />
			</line>
			<textField>
				<reportElement x="200" y="20" width="85" height="15" />
				<textElement textAlignment="Right" />
				<textFieldExpression class="java.lang.String">
					<![CDATA["Page " + String.valueOf($V{PAGE_NUMBER})]]>
				</textFieldExpression>
			</textField>
			<textField evaluationTime="Report">
				<reportElement x="285" y="20" width="75" height="15" />
				<textElement textAlignment="Left" />
				<textFieldExpression class="java.lang.String">
					<![CDATA[" of " + String.valueOf($V{PAGE_NUMBER})]]>
				</textFieldExpression>
			</textField>
		</band>
	</pageFooter>
	<summary>
		<band height="35">
			<textField isStretchWithOverflow="true">
				<reportElement x="175" y="20" width="165" height="15" />
				<textElement textAlignment="Center">
					<font reportFont="Arial_Italic" />
				</textElement>
				<textFieldExpression class="java.lang.String">
					<![CDATA["There were " +
			String.valueOf($V{REPORT_COUNT}) +
			"  customer records on this report."]]>
				</textFieldExpression>
			</textField>
		</band>
	</summary>
</jasperReport>