<jasperReport name="LateOrdersReport" language="java" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="b95d8996-97c3-4d30-ab13-8a8345bf8a24">
	<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/>
	<style name="Sans_Normal" default="true" fontName="DejaVu Sans" fontSize="8.0" bold="false" italic="false" underline="false" strikeThrough="false"/>
	<style name="Sans_Bold" fontName="DejaVu Sans" fontSize="8.0" bold="true" italic="false" underline="false" strikeThrough="false"/>
	<style name="Title" style="Sans_Bold" fontSize="12.0"/>
	<style name="ColumnHeader" style="Sans_Bold" forecolor="#FFFFFF"/>
	<style name="CellStyle" mode="Opaque">
		<conditionalStyle backcolor="#E0E0E0">
			<conditionExpression><![CDATA[$V{ROW_COUNT} % 2 == 0]]></conditionExpression>
		</conditionalStyle>
	</style>
	<style name="Detail">
		<conditionalStyle mode="Opaque" backcolor="#E0E0E0">
			<conditionExpression><![CDATA[$V{REPORT_COUNT} % 2 == 0]]></conditionExpression>
		</conditionalStyle>
		<conditionalStyle>
			<pen lineWidth="0.5" lineColor="#FF0000"/>
			<conditionExpression><![CDATA[$V{DeliveryDelay} != null]]></conditionExpression>
		</conditionalStyle>
	</style>
	<query language="sql"><![CDATA[SELECT OrderId, ShipCountry, Freight, OrderDate, RequiredDate, ShippedDate FROM Orders WHERE ShippedDate IS NOT NULL]]></query>
	<field name="OrderId" class="java.lang.Integer"/>
	<field name="ShipCountry" class="java.lang.String"/>
	<field name="Freight" class="java.lang.Float"/>
	<field name="OrderDate" class="java.sql.Timestamp"/>
	<field name="RequiredDate" class="java.sql.Timestamp"/>
	<field name="ShippedDate" class="java.sql.Timestamp"/>
	<variable name="DeliveryDelay" class="java.lang.Integer">
		<expression><![CDATA[$F{ShippedDate}.after($F{RequiredDate}) ?
					(1 + (int) (($F{ShippedDate}.getTime() - $F{RequiredDate}.getTime() - 1) / 3600000)) :
					null]]></expression>
	</variable>
	<title height="40">
		<element kind="staticText" uuid="9e2f3dcb-8fc2-4123-944c-0c36d2a75770" x="0" y="0" width="555" height="20" hTextAlign="Center" vTextAlign="Middle" style="Title">
			<text><![CDATA[Shipped Orders]]></text>
		</element>
	</title>
	<pageHeader height="15">
		<element kind="frame" uuid="523a8a78-f099-4d2b-a3e5-1e03c272eab1" mode="Opaque" x="0" y="0" width="555" height="15" backcolor="#000000">
			<element kind="staticText" uuid="a1c54469-3c72-49cb-a023-a46d2a6cfa36" x="5" y="0" width="55" height="15" hTextAlign="Right" vTextAlign="Middle" style="ColumnHeader">
				<text><![CDATA[Order ID]]></text>
			</element>
			<element kind="staticText" uuid="878015da-7efd-4b41-ae6d-1b6162a79519" x="65" y="0" width="100" height="15" vTextAlign="Middle" style="ColumnHeader">
				<text><![CDATA[Country]]></text>
			</element>
			<element kind="staticText" uuid="d3dbceec-a4d5-4aa1-af26-c24145fecefe" x="170" y="0" width="60" height="15" hTextAlign="Right" vTextAlign="Middle" style="ColumnHeader">
				<text><![CDATA[Freight]]></text>
			</element>
			<element kind="staticText" uuid="e40c5ae1-42d1-4a23-a18d-031ed7f945e7" x="235" y="0" width="80" height="15" hTextAlign="Center" vTextAlign="Middle" style="ColumnHeader">
				<text><![CDATA[Order date]]></text>
			</element>
			<element kind="staticText" uuid="38b115af-21a4-4b8d-a40f-6463253f9ce6" x="320" y="0" width="80" height="15" hTextAlign="Center" vTextAlign="Middle" style="ColumnHeader">
				<text><![CDATA[Required date]]></text>
			</element>
			<element kind="staticText" uuid="c9e868ea-d986-493e-bafb-e3a925d65504" x="405" y="0" width="80" height="15" hTextAlign="Center" vTextAlign="Middle" style="ColumnHeader">
				<text><![CDATA[Shipped date]]></text>
			</element>
			<element kind="staticText" uuid="363216c1-0eb0-4825-a2b5-3737c2f1ce72" x="490" y="0" width="60" height="15" hTextAlign="Right" vTextAlign="Middle" style="ColumnHeader">
				<text><![CDATA[Late (hrs)]]></text>
			</element>
		</element>
	</pageHeader>
	<detail>
		<band height="15">
			<element kind="frame" uuid="bdb0ab67-41b8-4e2f-ba40-0ce4f89cfa17" x="0" y="0" width="555" height="15" style="Detail">
				<element kind="textField" uuid="870def8d-eabf-4c70-a994-8214099a9605" x="5" y="0" width="55" height="15" hTextAlign="Right" vTextAlign="Middle">
					<expression><![CDATA[$F{OrderId}.toString()]]></expression>
				</element>
				<element kind="textField" uuid="8bed42e8-aa6a-4ccb-8ab8-3c910cdd3a29" x="65" y="0" width="100" height="15" vTextAlign="Middle">
					<expression><![CDATA[$F{ShipCountry}]]></expression>
				</element>
				<element kind="textField" uuid="4845648b-af75-4fdb-b7af-0c80e6a715d3" x="170" y="0" width="60" height="15" pattern="#,###.00" hTextAlign="Right" vTextAlign="Middle">
					<expression><![CDATA[$F{Freight}]]></expression>
				</element>
				<element kind="textField" uuid="2f16e56e-55bd-4247-bde7-0d5c84a4c30d" x="235" y="0" width="80" height="15" pattern="medium,hide" hTextAlign="Center" vTextAlign="Middle">
					<expression><![CDATA[$F{OrderDate}]]></expression>
				</element>
				<element kind="textField" uuid="dc6c3a54-44de-481e-980c-093bfe0849a2" x="320" y="0" width="80" height="15" pattern="medium,hide" hTextAlign="Center" vTextAlign="Middle">
					<expression><![CDATA[$F{RequiredDate}]]></expression>
				</element>
				<element kind="textField" uuid="7bb0e8be-7602-4e39-9773-586967229268" x="405" y="0" width="80" height="15" pattern="medium,hide" hTextAlign="Center" vTextAlign="Middle">
					<expression><![CDATA[$F{ShippedDate}]]></expression>
				</element>
				<element kind="textField" uuid="967da15b-01eb-4e85-9bdf-8ae84b711a59" x="490" y="0" width="60" height="15" blankWhenNull="true" hTextAlign="Right" vTextAlign="Middle">
					<expression><![CDATA[$V{DeliveryDelay}.toString()]]></expression>
				</element>
			</element>
		</band>
	</detail>
	<summary height="100">
		<element kind="staticText" uuid="851074bb-014f-41c6-960a-e6fe7992c21e" x="0" y="20" width="555" height="20" style="Title">
			<text><![CDATA[Late deliveries summary (count and total delay) by country and freight range]]></text>
		</element>
		<element kind="crosstab" uuid="8a029eb2-4d27-420d-bce4-54e0672e71c6" x="0" y="40" width="555" height="60" columnBreakOffset="10" repeatColumnHeaders="false">
			<dataset>
				<incrementWhenExpression><![CDATA[$V{DeliveryDelay} != null]]></incrementWhenExpression>
			</dataset>
			<rowGroup name="CountryRow" totalPosition="End" width="80">
				<bucket class="java.lang.String">
					<expression><![CDATA[$F{ShipCountry}]]></expression>
				</bucket>
				<header style="CellStyle">
					<element kind="textField" uuid="a0a693b5-7245-4e91-9888-d0fe76d8ac2d" x="5" y="0" width="75" height="20" vTextAlign="Middle" style="Sans_Bold">
						<expression><![CDATA[$V{CountryRow}]]></expression>
					</element>
					<box style="CellStyle">
						<pen lineWidth="1.0" lineColor="#000000"/>
					</box>
				</header>
				<totalHeader>
					<element kind="staticText" uuid="19976811-f3b5-4117-a84b-ace5aa55ffb4" x="5" y="0" width="75" height="20" fontSize="12.0" vTextAlign="Middle" style="Sans_Bold">
						<text><![CDATA[TOTAL]]></text>
					</element>
					<box>
						<pen lineWidth="1.0" lineColor="#000000"/>
					</box>
				</totalHeader>
			</rowGroup>
			<columnGroup name="FreightColumn" totalPosition="End" height="20">
				<bucket class="java.lang.Integer">
					<expression><![CDATA[$F{Freight}.intValue()/100]]></expression>
				</bucket>
				<header>
					<element kind="textField" uuid="5c3cbc80-217a-4f1a-99a0-0359c7b373e4" x="0" y="0" width="60" height="20" hTextAlign="Center" vTextAlign="Middle" style="Sans_Bold">
						<expression><![CDATA[($V{FreightColumn} * 100) + "-" + (($V{FreightColumn} + 1) * 100)]]></expression>
					</element>
					<box>
						<pen lineWidth="1.0" lineColor="#000000"/>
					</box>
				</header>
				<totalHeader>
					<element kind="staticText" uuid="f4321ea1-82c7-43e8-b375-f85ccc071eb5" x="0" y="0" width="60" height="20" fontSize="12.0" hTextAlign="Center" vTextAlign="Middle" style="Sans_Bold">
						<text><![CDATA[TOTAL]]></text>
					</element>
					<box>
						<pen lineWidth="1.0" lineColor="#000000"/>
					</box>
				</totalHeader>
			</columnGroup>
			<measure name="OrderCount" calculation="Count" class="java.lang.Integer">
				<expression><![CDATA[$F{Freight}]]></expression>
			</measure>
			<measure name="Delay" calculation="Sum" class="java.lang.Integer">
				<expression><![CDATA[$V{DeliveryDelay}]]></expression>
			</measure>
			<cell width="60" height="20">
				<contents style="CellStyle">
					<element kind="textField" uuid="5a51bf0d-2ef5-44a1-8759-e35bc94cb4f3" x="0" y="0" width="60" height="10" hTextAlign="Center" vTextAlign="Middle">
						<expression><![CDATA[$V{OrderCount}]]></expression>
					</element>
					<element kind="textField" uuid="e78f18f4-be18-48c6-8779-bd54e5f4a704" x="0" y="10" width="60" height="10" blankWhenNull="true" hTextAlign="Center" vTextAlign="Middle">
						<expression><![CDATA[$V{Delay}]]></expression>
					</element>
					<box style="CellStyle">
						<pen lineWidth="1.0" lineColor="#000000"/>
					</box>
				</contents>
			</cell>
			<cell width="60" height="20" rowTotalGroup="CountryRow">
				<contents mode="Opaque" backcolor="#FFFF00">
					<element kind="textField" uuid="27460a67-61ae-4372-b263-5bf54551b0be" x="0" y="0" width="60" height="10" hTextAlign="Center" vTextAlign="Middle" style="Sans_Bold">
						<expression><![CDATA[$V{OrderCount}]]></expression>
					</element>
					<element kind="textField" uuid="5997d6ae-ab07-4b73-b948-8e723907c6a8" x="0" y="10" width="60" height="10" blankWhenNull="true" hTextAlign="Center" vTextAlign="Middle" style="Sans_Bold">
						<expression><![CDATA[$V{Delay}]]></expression>
					</element>
					<box>
						<pen lineWidth="1.0" lineColor="#000000"/>
					</box>
				</contents>
			</cell>
			<cell width="60" height="20" columnTotalGroup="FreightColumn">
				<contents mode="Opaque" backcolor="#00FF00">
					<element kind="textField" uuid="cbbd158c-2883-4c67-ac17-79071fa107a7" x="0" y="0" width="60" height="10" hTextAlign="Center" vTextAlign="Middle" style="Sans_Bold">
						<expression><![CDATA[$V{OrderCount}]]></expression>
					</element>
					<element kind="textField" uuid="7f7c42f0-3d47-4f9c-96fd-cf76b7d118aa" x="0" y="10" width="60" height="10" blankWhenNull="true" hTextAlign="Center" vTextAlign="Middle" style="Sans_Bold">
						<expression><![CDATA[$V{Delay}]]></expression>
					</element>
					<box>
						<pen lineWidth="1.0" lineColor="#000000"/>
					</box>
				</contents>
			</cell>
			<cell width="60" height="20" rowTotalGroup="CountryRow" columnTotalGroup="FreightColumn">
				<contents mode="Opaque" backcolor="#808080">
					<element kind="textField" uuid="8d8d120b-55db-46cb-bcb5-b2caaed58c65" x="0" y="0" width="60" height="10" hTextAlign="Center" vTextAlign="Middle" style="Sans_Bold">
						<expression><![CDATA[$V{OrderCount}]]></expression>
					</element>
					<element kind="textField" uuid="6a104267-9fb1-4f00-8373-5e3cee56d9ed" x="0" y="10" width="60" height="10" blankWhenNull="true" hTextAlign="Center" vTextAlign="Middle" style="Sans_Bold">
						<expression><![CDATA[$V{Delay}]]></expression>
					</element>
					<box>
						<pen lineWidth="1.0" lineColor="#000000"/>
					</box>
				</contents>
			</cell>
		</element>
	</summary>
</jasperReport>
