<?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="SalesByMonthDetail" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="515" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" scriptletClass="test.TestScriptlet" resourceBundle="sales" whenResourceMissingType="Error">
	<style name="Sans_Normal" isDefault="true" fontName="SansSerif" fontSize="12" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
	<style name="Sans_Bold" isDefault="false" fontName="SansSerif" fontSize="12" isBold="true" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
	<style name="Sans_Italic" isDefault="false" fontName="SansSerif" fontSize="12" isItalic="true" pdfFontName="Helvetica-Oblique" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
	<style name="PageHeader" isDefault="false" style="Sans_Normal" forecolor="#FFFFFF"/>
	<style name="detail" isDefault="false">
		<conditionalStyle>
			<conditionExpression><![CDATA[new Boolean($V{REPORT_COUNT}.intValue() % 2 == 0)]]></conditionExpression>
			<style isDefault="false" style="detail" mode="Opaque" backcolor="#E0E0E0"/>
		</conditionalStyle>
	</style>
	<parameter name="CloseYear" class="java.lang.Short"/>
	<parameter name="CloseMonth" class="java.lang.Short"/>
	<queryString>
		<![CDATA[SELECT
			sales_fact.amount as amount,
			sales_date_of_close.close_month_name as close_month_name,
			sales_person.first_name as sales_person_first_name,
			sales_person.last_name as sales_person_last_name,
			sales_account.account_name as account_name
		FROM
		    sales_fact
		    INNER JOIN sales_date_of_close ON sales_fact.sales_date_of_close_id = sales_date_of_close.id
		    INNER JOIN sales_person ON sales_fact.sales_person_id = sales_person.id
		    INNER JOIN sales_account ON sales_fact.sales_account_id = sales_account.id
		WHERE
			sales_date_of_close.close_year = $P{CloseYear} and
			sales_date_of_close.close_month = $P{CloseMonth}
		ORDER BY sales_person.id, sales_account.id]]>
	</queryString>
	<field name="amount" class="java.lang.Float"/>
	<field name="sales_person_first_name" class="java.lang.String"/>
	<field name="sales_person_last_name" class="java.lang.String"/>
	<field name="account_name" class="java.lang.String"/>
	<variable name="totalAmount" class="java.lang.Float" calculation="Sum">
		<variableExpression><![CDATA[$F{amount}]]></variableExpression>
		<initialValueExpression><![CDATA[new Float(0.f)]]></initialValueExpression>
	</variable>
	<pageHeader>
		<band height="16" splitType="Stretch">
			<frame>
				<reportElement mode="Opaque" x="0" y="0" width="515" height="16" backcolor="#C0C0C0">
					<property name="net.sf.jasperreports.export.pdf.tag.table" value="start"/>
					<property name="net.sf.jasperreports.export.pdf.tag.tr" value="full"/>
				</reportElement>
				<textField isStretchWithOverflow="true">
					<reportElement style="PageHeader" x="10" y="0" width="120" height="16">
						<property name="net.sf.jasperreports.export.pdf.tag.th" value="full"/>
					</reportElement>
					<textElement/>
					<textFieldExpression class="java.lang.String"><![CDATA[$R{sales.person}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="true">
					<reportElement style="PageHeader" x="140" y="0" width="260" height="16">
						<property name="net.sf.jasperreports.export.pdf.tag.th" value="full"/>
					</reportElement>
					<textElement/>
					<textFieldExpression class="java.lang.String"><![CDATA[$R{sales.account}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="true">
					<reportElement style="PageHeader" x="410" y="0" width="95" height="16">
						<property name="net.sf.jasperreports.export.pdf.tag.th" value="full"/>
					</reportElement>
					<textElement textAlignment="Right"/>
					<textFieldExpression class="java.lang.String"><![CDATA[$R{sales.amount}]]></textFieldExpression>
				</textField>
			</frame>
		</band>
	</pageHeader>
	<detail>
		<band height="20" splitType="Prevent">
			<frame>
				<reportElement style="detail" x="0" y="0" width="515" height="20">
					<property name="net.sf.jasperreports.export.pdf.tag.tr" value="full"/>
				</reportElement>
				<box>
					<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#808080"/>
				</box>
				<textField isStretchWithOverflow="true">
					<reportElement isPrintRepeatedValues="false" x="10" y="4" width="120" height="16" isPrintInFirstWholeBand="true">
						<property name="net.sf.jasperreports.export.pdf.tag.td" value="full"/>
					</reportElement>
					<textElement/>
					<textFieldExpression class="java.lang.String"><![CDATA[$F{sales_person_first_name} + " " + $F{sales_person_last_name}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="true">
					<reportElement x="140" y="4" width="260" height="16">
						<property name="net.sf.jasperreports.export.pdf.tag.td" value="full"/>
					</reportElement>
					<textElement/>
					<textFieldExpression class="java.lang.String"><![CDATA[$F{account_name}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="true" pattern="#0.00">
					<reportElement x="410" y="4" width="95" height="16">
						<property name="net.sf.jasperreports.export.pdf.tag.td" value="full"/>
					</reportElement>
					<textElement textAlignment="Right"/>
					<textFieldExpression class="java.lang.Float"><![CDATA[$F{amount}]]></textFieldExpression>
				</textField>
			</frame>
		</band>
	</detail>
	<pageFooter>
		<band splitType="Stretch">
			<frame>
				<reportElement mode="Transparent" x="0" y="0" width="0" height="0">
					<property name="net.sf.jasperreports.export.pdf.tag.table" value="end"/>
				</reportElement>
			</frame>
		</band>
	</pageFooter>
</jasperReport>
