<?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="packing_slip_rep_subreport1" pageWidth="802" pageHeight="555" orientation="Landscape" columnWidth="802" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">
	<property name="ireport.zoom" value="1.5"/>
	<property name="ireport.x" value="225"/>
	<property name="ireport.y" value="0"/>
	<parameter name="despId" class="java.lang.String"/>
	<queryString>
		<![CDATA[SELECT

     CASE WHEN DESPATCHDET."LINE_NO__SORD" IS NULL THEN ' ' ELSE DESPATCHDET."LINE_NO__SORD" END AS DESPATCHDET_SORD_NO,
     CASE WHEN DESPATCHDET."LOT_NO" IS NULL THEN ' ' ELSE DESPATCHDET."LOT_NO" END AS DESPATCHDET_LOT_NO,
     CASE WHEN DESPATCHDET."NO_ART" IS NULL THEN 0 ELSE DESPATCHDET."NO_ART" END AS DESPATCHDET_NO_ART,
     CASE WHEN DESPATCHDET."QUANTITY__ORD" IS NULL THEN 0 ELSE DESPATCHDET."QUANTITY__ORD" END AS DESPATCHDET_QUANTITY__ORD,
     CASE WHEN DESPATCHDET."QUANTITY" IS NULL THEN 0 ELSE  DESPATCHDET."QUANTITY" END AS DESPATCHDET_QUANTITY,
     CASE WHEN ITEMREGNO."ITEM_CODE" IS NULL THEN ' 'ELSE ITEMREGNO."ITEM_CODE" END AS ITEMREGNO_ITEM_CODE,
     CASE WHEN ITEMREGNO."REF_CODE" IS NULL THEN ' ' ELSE ITEMREGNO."REF_CODE" END AS ITEMREGNO_REF_CODE,
     CASE WHEN ITEMREGNO."USAGE" IS NULL THEN ' ' ELSE ITEMREGNO."USAGE" END AS ITEMREGNO_USAGE,
     STOCK."EXP_DATE" AS STOCK_EXP_DATE,
	DESPATCHdet.desp_id

FROM
     "LCK"."DESPATCHDET" DESPATCHDET,
     "LCK"."ITEMREGNO" ITEMREGNO,
     "LCK"."STOCK" STOCK
WHERE
	despatchdet.item_code = itemregno.item_code AND
   itemregno.site_code = stock.site_code AND
   despatchdet.lot_no = stock.lot_no  and
   despatchdet.lot_sl = stock.lot_sl  and
	TRIM(DESPATCHdet.desp_id) = TRIM($P{despId})]]>
	</queryString>
	<field name="DESPATCHDET_SORD_NO" class="java.lang.String"/>
	<field name="DESPATCHDET_LOT_NO" class="java.lang.String"/>

	<!-- <field name="DESPATCHDET_NO_ART" class="java.math.BigDecimal"/> -->
	<field name="DESPATCHDET_NO_ART" class="java.lang.String"/>

	<!-- <field name="DESPATCHDET_QUANTITY__ORD" class="java.math.BigDecimal"/> -->
	<field name="DESPATCHDET_QUANTITY__ORD" class="java.lang.String"/>

	<!-- <field name="DESPATCHDET_QUANTITY" class="java.math.BigDecimal"/> -->
	<field name="DESPATCHDET_QUANTITY" class="java.lang.String"/>
	<field name="ITEMREGNO_ITEM_CODE" class="java.lang.String"/>
	<field name="ITEMREGNO_REF_CODE" class="java.lang.String"/>
	<field name="ITEMREGNO_USAGE" class="java.lang.String"/>

	<!-- <field name="STOCK_EXP_DATE" class="java.sql.Timestamp"/> -->
	<field name="STOCK_EXP_DATE" class="java.lang.String"/>
	<field name="DESP_ID" class="java.lang.String"/>
	<variable name="ordQtySum" class="java.lang.String" calculation="Sum">
		<variableExpression><![CDATA[$F{DESPATCHDET_QUANTITY__ORD}]]></variableExpression>
	</variable>
	<variable name="shipQtySum" class="java.lang.String" calculation="Sum">
		<variableExpression><![CDATA[$F{DESPATCHDET_QUANTITY}]]></variableExpression>
	</variable>
	<background>
		<band splitType="Stretch"/>
	</background>
	<title>
		<band height="4" splitType="Stretch"/>
	</title>
	<pageHeader>
		<band height="21" splitType="Stretch">
			<staticText>
				<reportElement x="307" y="5" width="150" height="10"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<text><![CDATA[SKU Description:]]></text>
			</staticText>
			<staticText>
				<reportElement x="167" y="5" width="122" height="10"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<text><![CDATA[Customer SKU:]]></text>
			</staticText>
			<staticText>
				<reportElement x="52" y="5" width="88" height="10"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<text><![CDATA[SKU]]></text>
			</staticText>
			<staticText>
				<reportElement x="616" y="5" width="42" height="10"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<text><![CDATA[Ord Qty : ]]></text>
			</staticText>
			<staticText>
				<reportElement x="10" y="5" width="31" height="10"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<text><![CDATA[Line#:]]></text>
			</staticText>
			<staticText>
				<reportElement x="696" y="5" width="46" height="10"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<text><![CDATA[Shp Qty :]]></text>
			</staticText>
			<line>
				<reportElement x="10" y="2" width="763" height="1"/>
			</line>
			<line>
				<reportElement x="10" y="18" width="763" height="1"/>
			</line>
		</band>
	</pageHeader>
	<columnHeader>
		<band splitType="Stretch"/>
	</columnHeader>
	<detail>
		<band height="22" splitType="Stretch">
			<staticText>
				<reportElement x="478" y="11" width="22" height="10"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<text><![CDATA[Qty :]]></text>
			</staticText>
			<textField>
				<reportElement x="19" y="2" width="31" height="9"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{DESPATCHDET_SORD_NO}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="61" y="2" width="88" height="9"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{ITEMREGNO_ITEM_CODE}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="340" y="11" width="51" height="10"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{DESPATCHDET_LOT_NO}]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement x="309" y="11" width="31" height="10"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<text><![CDATA[Lot# :]]></text>
			</staticText>
			<textField pattern="dd/MM/yy">
				<reportElement x="426" y="11" width="51" height="10"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{STOCK_EXP_DATE}.equals(null)?"":$F{STOCK_EXP_DATE}]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement x="403" y="11" width="23" height="10"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<text><![CDATA[Exp :]]></text>
			</staticText>
			<textField>
				<reportElement x="500" y="11" width="51" height="10"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{DESPATCHDET_NO_ART}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="311" y="1" width="148" height="9"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{ITEMREGNO_USAGE}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="702" y="1" width="51" height="10"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{DESPATCHDET_QUANTITY}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="169" y="1" width="122" height="9"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{ITEMREGNO_REF_CODE}]]></textFieldExpression>
			</textField>
			<elementGroup>
				<textField pattern="">
					<reportElement x="621" y="1" width="51" height="10"/>
					<textElement>
						<font fontName="Courier New" size="7"/>
					</textElement>
					<textFieldExpression><![CDATA[$F{DESPATCHDET_QUANTITY__ORD}]]></textFieldExpression>
				</textField>
			</elementGroup>
		</band>
	</detail>
	<columnFooter>
		<band splitType="Stretch"/>
	</columnFooter>
	<pageFooter>
		<band height="18">
			<textField>
				<reportElement x="704" y="5" width="51" height="10"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<textFieldExpression><![CDATA[$V{shipQtySum}]]></textFieldExpression>
			</textField>
			<line>
				<reportElement x="10" y="15" width="763" height="2"/>
				<graphicElement>
					<pen lineStyle="Dashed"/>
				</graphicElement>
			</line>
			<staticText>
				<reportElement x="10" y="5" width="51" height="10"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<text><![CDATA[Totals . . :]]></text>
			</staticText>
			<textField evaluationTime="Column">
				<reportElement x="621" y="5" width="51" height="10"/>
				<textElement>
					<font fontName="Courier New" size="7"/>
				</textElement>
				<textFieldExpression><![CDATA[$V{ordQtySum}]]></textFieldExpression>
			</textField>
			<line>
				<reportElement x="10" y="0" width="763" height="2"/>
				<graphicElement>
					<pen lineStyle="Dashed"/>
				</graphicElement>
			</line>
		</band>
	</pageFooter>
	<summary>
		<band splitType="Stretch"/>
	</summary>
</jasperReport>
