<?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="_stirenergy" pageWidth="550" pageHeight="802" columnWidth="550" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">
	<property name="ireport.scriptlethandling" value="0"/>
	<property name="ireport.encoding" value="UTF-8"/>
	<property name="ireport.zoom" value="2.0526324729228267"/>
	<property name="ireport.x" value="0"/>
	<property name="ireport.y" value="0"/>
	<import value="net.sf.jasperreports.engine.*"/>
	<import value="java.util.*"/>
	<import value="usda.weru.weps.reports.query.*"/>
	<import value="net.sf.jasperreports.engine.data.*"/>
	<parameter name="RUN_ID" class="java.lang.Integer" isForPrompting="false">
		<defaultValueExpression><![CDATA[Integer.valueOf(0)]]></defaultValueExpression>
	</parameter>
	<parameter name="DATE_FORMAT" class="java.lang.String" isForPrompting="false">
		<defaultValueExpression><![CDATA["MM/dd/yy"]]></defaultValueExpression>
	</parameter>
	<queryString>
		<![CDATA[SELECT
stir."runid",
stir."line",
stir."date",
stir."rotation",
stir."operation",
stir."crop",
stir."stir",
fuel."energy" AS "energy",
stir."energy" AS "volume",
stir."cropnumber",
stir."lastharvest",
stir."volumename",
fuel."display" AS "fuel",
fuel."diesel",

fuel."price",
run."fieldxlength" * run."fieldylength" AS area

FROM
     weps('stir_energy') AS stir
LEFT JOIN weps('fuels') AS fuel
ON stir."fuel"=fuel."name"
LEFT JOIN weps('runs') AS run
ON stir."runid"=run."runid"
WHERE
     stir."runid" = $P{RUN_ID}]]>
	</queryString>
	<field name="runid" class="java.lang.Integer"/>
	<field name="line" class="java.lang.Integer"/>
	<field name="date" class="java.sql.Date"/>
	<field name="rotation" class="java.lang.Integer"/>
	<field name="operation" class="java.lang.String"/>
	<field name="crop" class="java.lang.String"/>
	<field name="stir" class="java.lang.Double"/>
	<field name="energy" class="java.lang.Double"/>
	<field name="cropnumber" class="java.lang.Integer"/>
	<field name="lastharvest" class="java.lang.Boolean"/>
	<field name="volumename" class="java.lang.String"/>
	<field name="fuel" class="java.lang.String"/>
	<field name="price" class="java.lang.Double"/>
	<field name="volume" class="java.lang.Double"/>
	<field name="diesel" class="java.lang.Double"/>
	<field name="area" class="java.lang.Double"/>
	<variable name="US_UNITS" class="java.lang.Boolean" resetType="None">
		<variableExpression><![CDATA["US".equals(((usda.weru.weps.reports.query.WepsConnection)$P{REPORT_CONNECTION}).getUnits())]]></variableExpression>
	</variable>
	<variable name="DATE_FORMAT" class="java.text.DateFormat" resetType="None">
		<variableExpression><![CDATA[new SimpleDateFormat($P{DATE_FORMAT})]]></variableExpression>
	</variable>
	<variable name="energyperarea" class="java.lang.Double">
		<variableExpression><![CDATA[$F{volume} / $F{energy}]]></variableExpression> <!-- Originally $F{volume} * $F{diesel} * $F{energy} -->
	</variable>
	<variable name="priceperarea" class="java.lang.Double">
		<variableExpression><![CDATA[$V{energyperarea} * $F{price}]]></variableExpression> <!-- Originally $F{volume} * $F{diesel} * $F{price} -->
		<!-- volume is the energy(L diesel/ha); diesel is conversion rate; price is price rate in table-->
	</variable>
	<variable name="areaunits" class="java.lang.String" resetType="None">
		<variableExpression><![CDATA[($V{US_UNITS} ? "ac" : "ha")]]></variableExpression>
	</variable>
	<variable name="sum_stir" class="java.lang.Double" calculation="Sum">
		<variableExpression><![CDATA[$F{stir}]]></variableExpression>
	</variable>
	<variable name="sum_energy" class="java.lang.Double" calculation="Sum">
		<variableExpression><![CDATA[$V{energyperarea}]]></variableExpression>
	</variable>
	<variable name="sum_price" class="java.lang.Double" calculation="Sum">
		<variableExpression><![CDATA[$V{priceperarea}]]></variableExpression>
	</variable>
	<variable name="areaconverted" class="java.lang.Double">
		<variableExpression><![CDATA[$V{US_UNITS} ? ($F{area} / 100000 * 2.29568411) : ($F{area} * 0.0001 )]]></variableExpression>
	</variable>
	<pageHeader>
		<band height="25">
			<frame>
				<reportElement style="Section Lines Top" stretchType="RelativeToBandHeight" x="0" y="5" width="550" height="20"/>
			</frame>
			<staticText>
				<reportElement key="staticText-2" style="Section Header" mode="Opaque" x="0" y="5" width="550" height="20"/>
				<textElement/>
				<text><![CDATA[Rotation Stir Energy]]></text>
			</staticText>
		</band>
	</pageHeader>
	<columnHeader>
		<band height="30" splitType="Prevent">
			<frame>
				<reportElement style="Section Lines Header" stretchType="RelativeToBandHeight" mode="Transparent" x="0" y="0" width="550" height="30"/>
			</frame>
			<staticText>
				<reportElement key="element-90" style="Label" x="4" y="14" width="50" height="16"/>
				<textElement/>
				<text><![CDATA[Date]]></text>
			</staticText>
			<staticText>
				<reportElement key="element-90" style="Label" x="66" y="14" width="208" height="16"/>
				<textElement/>
				<text><![CDATA[Operation]]></text>
			</staticText>
			<staticText>
				<reportElement key="element-90" style="Label" x="345" y="14" width="57" height="15"/>
				<textElement textAlignment="Right"/>
				<text><![CDATA[Stir]]></text>
			</staticText>
			<staticText>
				<reportElement key="element-90" style="Label" x="402" y="0" width="71" height="14"/>
				<textElement textAlignment="Right"/>
				<text><![CDATA[Energy]]></text>
			</staticText>
			<textField isStretchWithOverflow="true" isBlankWhenNull="false">
				<reportElement key="textField" style="Units" x="402" y="14" width="71" height="16"/>
				<textElement textAlignment="Right"/>
				<textFieldExpression class="java.lang.String"><![CDATA[FuelsResultSet.getDisplayUnits("energynovolume", $V{US_UNITS}) + " (" + $F{volumename} + ")/" + $V{areaunits}]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement key="element-90" style="Label" x="274" y="14" width="88" height="16"/>
				<textElement/>
				<text><![CDATA[Fuel]]></text>
			</staticText>
			<staticText>
				<reportElement key="element-90" style="Label" x="493" y="0" width="53" height="14"/>
				<textElement textAlignment="Right"/>
				<text><![CDATA[Cost]]></text>
			</staticText>
			<textField isStretchWithOverflow="true" isBlankWhenNull="false">
				<reportElement key="textField" style="Units" x="493" y="14" width="53" height="16"/>
				<textElement textAlignment="Right"/>
				<textFieldExpression class="java.lang.String"><![CDATA[FuelsResultSet.getDisplayUnits("pricenovolume", $V{US_UNITS}) + "/" + $V{areaunits}]]></textFieldExpression>
			</textField>
		</band>
	</columnHeader>
	<detail>
		<band height="16" splitType="Prevent">
			<rectangle>
				<reportElement style="Detail Row Shaded" stretchType="RelativeToBandHeight" x="0" y="0" width="550" height="16">
					<printWhenExpression><![CDATA[new Boolean($V{REPORT_COUNT}.intValue() % 2 == 0)]]></printWhenExpression>
				</reportElement>
			</rectangle>
			<frame>
				<reportElement style="Section Lines Sides" stretchType="RelativeToBandHeight" x="0" y="0" width="550" height="16"/>
			</frame>
			<!-- Start energy column -->
			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
				<reportElement key="textField" style="Value Decimal Small" x="402" y="1" width="71" height="15"/>
				<textElement textAlignment="Right"/>
				<textFieldExpression class="java.lang.Double"><![CDATA[$F{volume}]]></textFieldExpression>
			</textField>
			<!-- End energy column -->
			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
				<reportElement key="textField" style="Value" x="66" y="1" width="208" height="15"/>
				<textElement/>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{operation}]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
				<reportElement key="textField" style="Value Decimal Small" x="345" y="1" width="57" height="15"/>
				<textElement textAlignment="Right"/>
				<textFieldExpression class="java.lang.Double"><![CDATA[$F{stir}]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
				<reportElement key="textField" style="Value" x="274" y="1" width="88" height="15"/>
				<textElement/>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{fuel}]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
				<reportElement key="textField" style="Value Mono" x="4" y="1" width="82" height="15"/>
				<textElement/>
				<textFieldExpression class="java.lang.String"><![CDATA[$V{DATE_FORMAT}.format($F{date})]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
				<reportElement key="textField" style="Value Money" x="493" y="1" width="53" height="15"/>
				<textElement textAlignment="Right"/>
				<textFieldExpression class="java.lang.Double"><![CDATA[$V{priceperarea}]]></textFieldExpression>
			</textField>
		</band>
	</detail>
	<columnFooter>
		<band height="1">
			<frame>
				<reportElement style="Section Lines Bottom" x="0" y="0" width="550" height="1"/>
			</frame>
		</band>
	</columnFooter>
	<pageFooter>
		<band height="20" splitType="Stretch">
			<printWhenExpression><![CDATA[$F{line} == null]]></printWhenExpression>
			<frame>
				<reportElement style="Section Lines Bottom" stretchType="RelativeToBandHeight" x="0" y="0" width="550" height="20"/>
			</frame>
			<staticText>
				<reportElement key="staticText-1" style="Warning" x="1" y="0" width="549" height="20"/>
				<textElement textAlignment="Center" verticalAlignment="Middle"/>
				<text><![CDATA[(No Data Avaliable)]]></text>
			</staticText>
		</band>
	</pageFooter>
	<lastPageFooter>
		<band height="45">
			<printWhenExpression><![CDATA[$F{line} != null]]></printWhenExpression>
			<frame>
				<reportElement style="Section Lines" stretchType="RelativeToBandHeight" x="0" y="0" width="550" height="44"/>
			</frame>
			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
				<reportElement key="textField" style="Value Decimal Medium" x="345" y="1" width="57" height="15"/>
				<textElement textAlignment="Right"/>
				<textFieldExpression class="java.lang.Double"><![CDATA[$V{sum_stir}]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
				<reportElement key="textField" style="Value Decimal Medium" x="402" y="1" width="71" height="15"/>
				<textElement textAlignment="Right"/>
				<textFieldExpression class="java.lang.Double"><![CDATA[$V{sum_energy}]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
				<reportElement key="textField" style="Value Money" x="493" y="1" width="53" height="15" isPrintInFirstWholeBand="true"/>
				<textElement textAlignment="Right"/>
				<textFieldExpression class="java.lang.Double"><![CDATA[$V{sum_price}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement key="element-90" style="Label" x="220" y="1" width="174" height="15"/>
				<textElement/>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{rotation} + " yr rotation (total/" + $V{areaunits} + ")"]]></textFieldExpression>
			</textField>
			<!--total/ac/yr row-->
			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
				<reportElement key="textField" style="Value Decimal Medium" x="402" y="15" width="71" height="15"/>
				<textElement textAlignment="Right"/>
				<textFieldExpression class="java.lang.Double"><![CDATA[$V{sum_energy} / $F{rotation}]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
				<reportElement key="textField" style="Value Decimal Medium" x="345" y="15" width="57" height="15"/>
				<textElement textAlignment="Right"/>
				<textFieldExpression class="java.lang.Double"><![CDATA[$V{sum_stir} / $F{rotation}]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
				<reportElement key="textField" style="Value Money" x="493" y="15" width="53" height="15" isPrintInFirstWholeBand="true"/>
				<textElement textAlignment="Right"/>
				<textFieldExpression class="java.lang.Double"><![CDATA[$V{sum_price} / $F{rotation}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement key="element-90" style="Label" x="217" y="15" width="174" height="15"/>
				<textElement/>
				<textFieldExpression class="java.lang.String"><![CDATA["avg yearly (total/" + $V{areaunits} + "/yr)"]]></textFieldExpression>
			</textField>
			<!--End total/ac/yr row-->
			<textField>
				<reportElement key="element-90" style="Label" x="125" y="30" width="214" height="15"/>
				<textElement/>
				<textFieldExpression class="java.lang.String"><![CDATA["avg yearly " + $V{areaconverted}.intValue() + " " + $V{areaunits} + " field rotation (total/yr)"]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
				<reportElement key="textField" style="Value Money" x="493" y="30" width="53" height="15"/>
				<textElement textAlignment="Right"/>
				<textFieldExpression class="java.lang.Double"><![CDATA[$V{sum_price} * $V{areaconverted}]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
				<reportElement key="textField" style="Value Decimal Huge" x="402" y="30" width="71" height="15"/>
				<textElement textAlignment="Right"/>
				<textFieldExpression class="java.lang.Double"><![CDATA[$V{sum_energy} * $V{areaconverted}]]></textFieldExpression>
			</textField>
		</band>
	</lastPageFooter>
</jasperReport>