<?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="check_sheet_by_ptcn" pageWidth="792" pageHeight="612" orientation="Landscape" columnWidth="772" leftMargin="15" rightMargin="5" topMargin="18" bottomMargin="10">
	<property name="ireport.zoom" value="1.5"/>
	<property name="ireport.x" value="0"/>
	<property name="ireport.y" value="0"/>
	<parameter name="PTCN" class="java.lang.String"/>
	<queryString>
		<![CDATA[SELECT
T.ORDER_NO AS ORDER_NO,
T.LINE_NO AS LINE_NO,
T.PALLET_ID AS PALLET_ID,
T.LOC_CODE AS LOC_CODE,
T.ITEM_CODE AS ITEM_CODE,
T.ITEM_DESCR AS ITEM_DESCR,
T.LOT_NO AS LOT_NO,
T.ORD_QTY AS ORD_QTY,
T.PCKD_QTY AS PCKD_QTY,
T.NO_OF_CASES AS NO_OF_CASES,
T.WAVE_STATUS AS WAVE_STATUS,
T.WAVE_REF_TYPE AS WAVE_REF_TYPE
FROM
(SELECT
SO.SALE_ORDER AS ORDER_NO,
SD.LINE_NO AS LINE_NO,
DDF_GET_PALLET_ID_LINE_NO(POD.PICK_ORDER, POD.LINE_NO,'P','P') AS PALLET_ID,
DDF_GET_PALLET_ID_LINE_NO(POD.PICK_ORDER, POD.LINE_NO,'P','L') AS LOC_CODE,
POD.ITEM_CODE AS ITEM_CODE,
(SELECT I.DESCR AS DESCR FROM ITEM I WHERE POD.ITEM_CODE = I.ITEM_CODE) AS ITEM_DESCR,
POD.LOT_NO AS LOT_NO,
SD.QUANTITY__STDUOM AS ORD_QTY,
POD.QUANTITY AS PCKD_QTY,
POD.NO_ART AS NO_OF_CASES,
WT.STATUS AS WAVE_STATUS,
WT.REF_TYPE AS WAVE_REF_TYPE
FROM PICK_ORD_DET POD, SORDER SO, SORDDET SD, WAVE_TASK_DET WT, LOCATION L
WHERE
	WT.PTCN= '$P!{PTCN}'
AND POD.PICK_ORDER = WT.REF_ID
AND POD.SALE_ORDER = SO.SALE_ORDER
AND SD.LINE_NO = POD.LINE_NO__SORD
AND SD.SALE_ORDER = SO.SALE_ORDER
AND POD.LOC_CODE__TO = L.LOC_CODE
AND L.INV_STAT = 'DOCK'

UNION ALL

SELECT
SO.SALE_ORDER AS ORDER_NO,
SD.LINE_NO AS LINE_NO,
DDF_GET_PALLET_ID_LINE_NO(ROD.PICK_ORDER, ROD.LINE_NO,'R','P') AS PALLET_ID,
DDF_GET_PALLET_ID_LINE_NO(ROD.PICK_ORDER, ROD.LINE_NO,'R','L') AS LOC_CODE,
ROD.ITEM_CODE AS ITEM_CODE,
(SELECT I.DESCR AS DESCR FROM ITEM I WHERE ROD.ITEM_CODE = I.ITEM_CODE) AS ITEM_DESCR,
ROD.LOT_NO AS LOT_NO,
SD.QUANTITY__STDUOM AS ORD_QTY,
ROD.QUANTITY AS PCKD_QTY,
ROD.NO_ART AS NO_OF_CASES,
WT.STATUS AS WAVE_STATUS,
WT.REF_TYPE AS WAVE_REF_TYPE
FROM REPL_ORD_DET ROD, SORDER SO, SORDDET SD, WAVE_TASK_DET WT, LOCATION L
WHERE
WT.PTCN= '$P!{PTCN}'
AND ROD.REPL_ORDER = WT.REF_ID
AND ROD.SALE_ORDER = SO.SALE_ORDER
AND SD.LINE_NO = ROD.LINE_NO__SORD
AND SD.SALE_ORDER = SO.SALE_ORDER
AND ROD.LOC_CODE__TO = L.LOC_CODE
AND L.INV_STAT = 'DOCK'
) T]]>
	</queryString>
	<field name="ORDER_NO" class="java.lang.String"/>
	<field name="LINE_NO" class="java.lang.Double"/>
	<field name="PALLET_ID" class="java.lang.String"/>
	<field name="LOC_CODE" class="java.lang.String"/>
	<field name="ITEM_CODE" class="java.lang.String"/>
	<field name="ITEM_DESCR" class="java.lang.String"/>
	<field name="LOT_NO" class="java.lang.String"/>
	<field name="ORD_QTY" class="java.lang.Double"/>
	<field name="PCKD_QTY" class="java.lang.Double"/>
	<field name="NO_OF_CASES" class="java.lang.Double"/>
	<field name="WAVE_STATUS" class="java.lang.String"/>
	<field name="WAVE_REF_TYPE" class="java.lang.String"/>
	<sortField name="ITEM_CODE"/>
	<variable name="line_tot" class="java.lang.Double" resetType="Group" resetGroup="Line" calculation="Sum">
		<variableExpression><![CDATA[new java.lang.Double($F{PCKD_QTY}.doubleValue())]]></variableExpression>
	</variable>
	<variable name="ord_tot" class="java.lang.Double" calculation="Sum">
		<variableExpression><![CDATA[new java.lang.Double($F{PCKD_QTY}.doubleValue())]]></variableExpression>
	</variable>
	<variable name="ord_qty_eaches" class="java.lang.Double">
		<variableExpression><![CDATA[new java.lang.Double($F{ORD_QTY}.doubleValue())]]></variableExpression>
	</variable>
	<variable name="packed_qty_eaches" class="java.lang.Double">
		<variableExpression><![CDATA[new java.lang.Double($F{PCKD_QTY}.doubleValue())]]></variableExpression>
	</variable>
	<variable name="packed_qty_cases" class="java.lang.Double">
		<variableExpression><![CDATA[new java.lang.Double((ibase.webitm.reports.utility.BaseReportMethods.length(ibase.webitm.reports.utility.BaseReportMethods.trim($F{LOC_CODE})) > 0) && $F{WAVE_STATUS}.equals("Y") && (!$F{WAVE_REF_TYPE}.equals("A"))?$F{NO_OF_CASES}.doubleValue():0)]]></variableExpression>
	</variable>
	<group name="Line">
		<groupExpression><![CDATA[$F{LINE_NO}]]></groupExpression>
		<groupHeader>
			<band/>
		</groupHeader>
		<groupFooter>
			<band height="16">
				<textField evaluationTime="Group" evaluationGroup="Line" pattern="###0" isBlankWhenNull="true">
					<reportElement x="651" y="0" width="35" height="16" isRemoveLineWhenBlank="true" printWhenGroupChanges="Line"/>
					<textElement textAlignment="Right">
						<font fontName="Courier New" size="7"/>
					</textElement>
					<textFieldExpression class="java.lang.Double"><![CDATA[$V{line_tot}]]></textFieldExpression>
				</textField>
				<staticText>
					<reportElement x="595" y="0" width="45" height="8"/>
					<textElement>
						<font fontName="Courier New" size="7"/>
					</textElement>
					<text><![CDATA[Line Total]]></text>
				</staticText>
			</band>
		</groupFooter>
	</group>
	<background>
		<band splitType="Stretch"/>
	</background>
	<title>
		<band splitType="Stretch"/>
	</title>
	<pageHeader>
		<band height="58" splitType="Stretch">
			<staticText>
				<reportElement x="142" y="36" width="34" height="10"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<text><![CDATA[Line#]]></text>
			</staticText>
			<staticText>
				<reportElement x="0" y="12" width="772" height="14"/>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font fontName="Courier New" size="10"/>
				</textElement>
				<text><![CDATA[Quality Audit Cartons]]></text>
			</staticText>
			<staticText>
				<reportElement x="277" y="36" width="36" height="10"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<text><![CDATA[CnsLoc]]></text>
			</staticText>
			<staticText>
				<reportElement x="0" y="36" width="60" height="10"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<text><![CDATA[Pktkt Ctl#]]></text>
			</staticText>
			<staticText>
				<reportElement x="82" y="36" width="60" height="10"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<text><![CDATA[Order#]]></text>
			</staticText>
			<staticText>
				<reportElement x="382" y="36" width="134" height="10"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<text><![CDATA[Item Description]]></text>
			</staticText>
			<staticText>
				<reportElement x="710" y="36" width="34" height="16"/>
				<textElement textAlignment="Center">
					<font fontName="Courier New" size="7"/>
				</textElement>
				<text><![CDATA[Pckd Qty Cases]]></text>
			</staticText>
			<staticText>
				<reportElement x="588" y="36" width="35" height="16"/>
				<textElement textAlignment="Center">
					<font fontName="Courier New" size="7"/>
				</textElement>
				<text><![CDATA[Ord Qty Eaches]]></text>
			</staticText>
			<staticText>
				<reportElement x="651" y="36" width="39" height="16"/>
				<textElement textAlignment="Center">
					<font fontName="Courier New" size="7"/>
				</textElement>
				<text><![CDATA[Pckd Qty Eaches]]></text>
			</staticText>
			<staticText>
				<reportElement x="181" y="36" width="75" height="10"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<text><![CDATA[PalletID]]></text>
			</staticText>
			<staticText>
				<reportElement x="515" y="36" width="63" height="10"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<text><![CDATA[Lot#]]></text>
			</staticText>
			<textField pattern="HH:mm:ss" isBlankWhenNull="true">
				<reportElement x="45" y="12" width="44" height="11"/>
				<textElement>
					<font fontName="Courier New" size="7" isBold="false"/>
				</textElement>
				<textFieldExpression class="java.util.Date"><![CDATA[new java.util.Date()]]></textFieldExpression>
			</textField>
			<textField pattern="MM/dd/yy" isBlankWhenNull="true">
				<reportElement x="5" y="12" width="44" height="11"/>
				<textElement>
					<font fontName="Courier New" size="7" isBold="false"/>
				</textElement>
				<textFieldExpression class="java.util.Date"><![CDATA[new java.util.Date()]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="708" y="12" width="26" height="11"/>
				<textElement>
					<font fontName="Courier New" size="8" isBold="false"/>
				</textElement>
				<textFieldExpression class="java.lang.Integer"><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement x="681" y="12" width="25" height="10"/>
				<textElement>
					<font fontName="Courier New" size="8" isBold="false"/>
				</textElement>
				<text><![CDATA[Page :]]></text>
			</staticText>
			<staticText>
				<reportElement x="329" y="36" width="54" height="10"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<text><![CDATA[Item#]]></text>
			</staticText>
		</band>
	</pageHeader>
	<columnHeader>
		<band splitType="Stretch"/>
	</columnHeader>
	<detail>
		<band height="11">
			<textField isBlankWhenNull="true">
				<reportElement isPrintRepeatedValues="false" x="380" y="0" width="135" height="10" isRemoveLineWhenBlank="true"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{ITEM_DESCR}]]></textFieldExpression>
			</textField>
			<textField pattern="###0" isBlankWhenNull="true">
				<reportElement x="710" y="0" width="30" height="10" isRemoveLineWhenBlank="true"/>
				<textElement textAlignment="Right">
					<font fontName="Courier New" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.Double"><![CDATA[$V{packed_qty_cases}]]></textFieldExpression>
			</textField>
			<textField pattern="###0" isBlankWhenNull="true">
				<reportElement x="651" y="0" width="35" height="10" isRemoveLineWhenBlank="true"/>
				<textElement textAlignment="Right">
					<font fontName="Courier New" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.Double"><![CDATA[$V{packed_qty_eaches}]]></textFieldExpression>
			</textField>
			<textField pattern="###0" isBlankWhenNull="true">
				<reportElement x="588" y="0" width="30" height="10" isRemoveLineWhenBlank="true"/>
				<textElement textAlignment="Right">
					<font fontName="Courier New" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.Double"><![CDATA[$V{ord_qty_eaches}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement isPrintRepeatedValues="false" x="326" y="0" width="55" height="10" isRemoveLineWhenBlank="true"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{ITEM_CODE}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="180" y="0" width="93" height="10" isRemoveLineWhenBlank="true"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{PALLET_ID}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="514" y="0" width="55" height="10" isRemoveLineWhenBlank="true"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{LOT_NO}]]></textFieldExpression>
			</textField>
			<textField pattern="###0" isBlankWhenNull="true">
				<reportElement x="143" y="0" width="21" height="10" isRemoveLineWhenBlank="true"/>
				<textElement textAlignment="Right">
					<font fontName="Courier New" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.Double"><![CDATA[$F{LINE_NO}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement isPrintRepeatedValues="false" x="0" y="0" width="79" height="10"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$P{PTCN}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="277" y="0" width="49" height="10" isRemoveLineWhenBlank="true">
					<printWhenExpression><![CDATA[new Boolean($F{WAVE_STATUS}.equals("Y")?true:false)]]></printWhenExpression>
				</reportElement>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{LOC_CODE}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement isPrintRepeatedValues="false" x="82" y="0" width="60" height="10"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{ORDER_NO}]]></textFieldExpression>
			</textField>
		</band>
	</detail>
	<summary>
		<band height="18" splitType="Stretch">
			<staticText>
				<reportElement x="0" y="0" width="488" height="14"/>
				<textElement textAlignment="Left" verticalAlignment="Middle">
					<font fontName="Courier New" size="10"/>
				</textElement>
				<text><![CDATA[*** END OF REPORT ***]]></text>
			</staticText>
			<textField pattern="###0" isBlankWhenNull="true">
				<reportElement x="651" y="0" width="35" height="16" isRemoveLineWhenBlank="true"/>
				<textElement textAlignment="Right">
					<font fontName="Courier New" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.Double"><![CDATA[$V{ord_tot}]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement x="595" y="0" width="56" height="8"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<text><![CDATA[Order Total]]></text>
			</staticText>
		</band>
	</summary>
</jasperReport>
