<?xml version="1.0" encoding="UTF-8"  ?>
<!-- Created with iReport - A designer for JasperReports -->
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport
		 name="collection_report"

		 language="groovy"		 columnCount="1"
		 printOrder="Vertical"
		 orientation="Portrait"
		 pageWidth="595"
		 pageHeight="842"
		 columnWidth="535"
		 columnSpacing="0"
		 leftMargin="30"
		 rightMargin="30"
		 topMargin="20"
		 bottomMargin="20"
		 whenNoDataType="NoPages"
		 isTitleNewPage="false"
		 isSummaryNewPage="false">
	<property name="ireport.scriptlethandling" value="0" />
	<property name="ireport.encoding" value="UTF-8" />
	<import value="java.util.*" />
	<import value="net.sf.jasperreports.engine.*" />
	<import value="net.sf.jasperreports.engine.data.*" />

	<parameter name="fromdate" isForPrompting="false" class="java.lang.String"/>
	<parameter name="todate" isForPrompting="false" class="java.lang.String"/>
	<parameter name="collectorid" isForPrompting="false" class="java.lang.String"/>
	<parameter name="collectorname" isForPrompting="false" class="java.lang.String"/>
	<parameter name="collector.objid" isForPrompting="false" class="java.lang.String"/>
	<parameter name="collector.firstname" isForPrompting="false" class="java.lang.Object"/>
	<parameter name="collector.lastname" isForPrompting="false" class="java.lang.String"/>
	<parameter name="collector" isForPrompting="false" class="java.lang.Object"/>
	<parameter name="PRINTEDBY" isForPrompting="false" class="java.lang.String"/>
	<queryString><![CDATA[SELECT ia.objid, ia.code, ia.title, SUM(cri.amount) AS amount 
FROM ( 
	SELECT objid, 
		(SELECT COUNT(*) FROM cashreceipt_void WHERE receiptid=a.objid) AS voided 
	FROM cashreceipt a 
	WHERE objid IN (SELECT objid FROM remittance_cashreceipt WHERE objid=a.objid) 
	  AND objid NOT IN (SELECT receiptid FROM cashreceipt_void WHERE receiptid=a.objid) 
          AND CONVERT(receiptdate,DATE) BETWEEN $P{fromdate} AND $P{todate} 
          AND collector_objid LIKE $P{collectorid}  
)xx 
	INNER JOIN cashreceipt cr ON xx.objid=cr.objid 
	INNER JOIN cashreceiptitem cri ON cr.objid=cri.receiptid 
	INNER JOIN itemaccount ia ON cri.item_objid = ia.objid 
GROUP BY ia.objid, ia.code, ia.title 
ORDER BY ia.title]]></queryString>

	<field name="amount" class="java.lang.Double"/>
	<field name="code" class="java.lang.String"/>
	<field name="objid" class="java.lang.String"/>
	<field name="title" class="java.lang.String"/>

	<variable name="grandtotal" class="java.lang.Double" resetType="Report" calculation="Sum">
		<variableExpression><![CDATA[$F{amount}]]></variableExpression>
	</variable>
		<background>
			<band height="0"  isSplitAllowed="true" >
			</band>
		</background>
		<title>
			<band height="131"  isSplitAllowed="true" >
				<staticText>
					<reportElement
						x="0"
						y="0"
						width="535"
						height="17"
						key="staticText-1"/>
					<box></box>
					<textElement textAlignment="Center">
						<font/>
					</textElement>
				<text><![CDATA[Republic of the Philippines]]></text>
				</staticText>
				<staticText>
					<reportElement
						x="0"
						y="15"
						width="535"
						height="17"
						key="staticText-2"/>
					<box></box>
					<textElement textAlignment="Center">
						<font/>
					</textElement>
				<text><![CDATA[Province of Misamis Occidental]]></text>
				</staticText>
				<staticText>
					<reportElement
						x="0"
						y="31"
						width="535"
						height="17"
						key="staticText-3"/>
					<box></box>
					<textElement textAlignment="Center" verticalAlignment="Middle">
						<font pdfFontName="Helvetica-Bold" isBold="true"/>
					</textElement>
				<text><![CDATA[OROQUIETA CITY]]></text>
				</staticText>
				<staticText>
					<reportElement
						x="0"
						y="58"
						width="535"
						height="17"
						key="staticText-4"/>
					<box></box>
					<textElement textAlignment="Center">
						<font pdfFontName="Helvetica-Bold" isBold="true"/>
					</textElement>
				<text><![CDATA[OFFICE OF THE MUNICIPAL TREASURER]]></text>
				</staticText>
				<staticText>
					<reportElement
						x="0"
						y="73"
						width="535"
						height="17"
						key="staticText-6"/>
					<box></box>
					<textElement textAlignment="Center">
						<font size="12"/>
					</textElement>
				<text><![CDATA[SUMMARY OF COLLECTIONS]]></text>
				</staticText>
				<staticText>
					<reportElement
						x="0"
						y="110"
						width="50"
						height="17"
						key="staticText-8"/>
					<box></box>
					<textElement textAlignment="Left">
						<font/>
					</textElement>
				<text><![CDATA[Collector:]]></text>
				</staticText>
				<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="50"
						y="110"
						width="410"
						height="16"
						key="textField">
							<printWhenExpression><![CDATA[($P{collector} != null)]]></printWhenExpression>
						</reportElement>
					<box></box>
					<textElement>
						<font/>
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA[$P{collector.firstname} + " " + $P{collector.lastname}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="0"
						y="88"
						width="535"
						height="20"
						key="textField"/>
					<box></box>
					<textElement textAlignment="Center">
						<font/>
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA["Collection from " + $P{fromdate} + " to " + $P{todate}]]></textFieldExpression>
				</textField>
				<staticText>
					<reportElement
						x="50"
						y="110"
						width="340"
						height="16"
						key="staticText-13">
							<printWhenExpression><![CDATA[$P{collector}==null]]></printWhenExpression>
						</reportElement>
					<box></box>
					<textElement>
						<font/>
					</textElement>
				<text><![CDATA[All Collectors]]></text>
				</staticText>
				<staticText>
					<reportElement
						x="0"
						y="43"
						width="535"
						height="16"
						key="staticText-16"/>
					<box></box>
					<textElement textAlignment="Center" verticalAlignment="Middle">
						<font size="8"/>
					</textElement>
				<text><![CDATA[City of Good Life]]></text>
				</staticText>
			</band>
		</title>
		<pageHeader>
			<band height="12"  isSplitAllowed="true" >
				<line direction="TopDown">
					<reportElement
						x="0"
						y="9"
						width="535"
						height="2"
						key="line-1"/>
					<graphicElement stretchType="NoStretch"/>
				</line>
			</band>
		</pageHeader>
		<columnHeader>
			<band height="25"  isSplitAllowed="true" >
				<staticText>
					<reportElement
						x="0"
						y="0"
						width="79"
						height="17"
						key="staticText-5"/>
					<box></box>
					<textElement textAlignment="Center">
						<font pdfFontName="Helvetica-Bold" isBold="true"/>
					</textElement>
				<text><![CDATA[Account Code]]></text>
				</staticText>
				<staticText>
					<reportElement
						x="86"
						y="0"
						width="357"
						height="17"
						key="staticText-9"/>
					<box></box>
					<textElement textAlignment="Center">
						<font pdfFontName="Helvetica-Bold" size="10" isBold="true"/>
					</textElement>
				<text><![CDATA[Account Title]]></text>
				</staticText>
				<staticText>
					<reportElement
						x="470"
						y="0"
						width="51"
						height="17"
						key="staticText-10"/>
					<box></box>
					<textElement textAlignment="Center">
						<font pdfFontName="Helvetica-Bold" isBold="true"/>
					</textElement>
				<text><![CDATA[Total]]></text>
				</staticText>
				<line direction="TopDown">
					<reportElement
						x="1"
						y="20"
						width="535"
						height="2"
						key="line-2"/>
					<graphicElement stretchType="NoStretch"/>
				</line>
			</band>
		</columnHeader>
		<detail>
			<band height="19"  isSplitAllowed="true" >
				<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="0"
						y="0"
						width="79"
						height="18"
						key="textField"/>
					<box></box>
					<textElement>
						<font/>
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA[$F{code}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="86"
						y="0"
						width="336"
						height="18"
						key="textField"/>
					<box></box>
					<textElement>
						<font/>
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA[$F{title}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="false" pattern="#,##0.00" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="433"
						y="0"
						width="87"
						height="18"
						key="textField"/>
					<box></box>
					<textElement textAlignment="Right">
						<font/>
					</textElement>
				<textFieldExpression   class="java.lang.Double"><![CDATA[$F{amount}]]></textFieldExpression>
				</textField>
			</band>
		</detail>
		<columnFooter>
			<band height="0"  isSplitAllowed="true" >
			</band>
		</columnFooter>
		<pageFooter>
			<band height="22"  isSplitAllowed="true" >
				<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="410"
						y="4"
						width="99"
						height="17"
						key="textField"/>
					<box></box>
					<textElement textAlignment="Right">
						<font size="8"/>
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA["Page " + $V{PAGE_NUMBER} + " of "]]></textFieldExpression>
				</textField>
				<line direction="TopDown">
					<reportElement
						x="0"
						y="3"
						width="535"
						height="2"
						key="line-4"/>
					<graphicElement stretchType="NoStretch"/>
				</line>
				<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Report" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="509"
						y="4"
						width="21"
						height="17"
						key="textField-1"/>
					<box></box>
					<textElement textAlignment="Right">
						<font size="8"/>
					</textElement>
				<textFieldExpression   class="java.lang.Integer"><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
				</textField>
				<staticText>
					<reportElement
						x="0"
						y="7"
						width="149"
						height="15"
						key="staticText-14"/>
					<box></box>
					<textElement>
						<font size="8"/>
					</textElement>
				<text><![CDATA[GENERATED BY ETRACS 2.5  ]]></text>
				</staticText>
				<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="160"
						y="7"
						width="210"
						height="15"
						key="textField-2"/>
					<box></box>
					<textElement>
						<font size="8"/>
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA["PRINTED BY " + $P{PRINTEDBY}]]></textFieldExpression>
				</textField>
			</band>
		</pageFooter>
		<lastPageFooter>
			<band height="27"  isSplitAllowed="true" >
				<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="408"
						y="0"
						width="100"
						height="17"
						key="textField-3"/>
					<box></box>
					<textElement textAlignment="Right">
						<font size="8"/>
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA["Page " + $V{PAGE_NUMBER} + " of "]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Report" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="509"
						y="0"
						width="22"
						height="17"
						key="textField-4"/>
					<box></box>
					<textElement textAlignment="Right">
						<font size="8"/>
					</textElement>
				<textFieldExpression   class="java.lang.Integer"><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
				</textField>
				<staticText>
					<reportElement
						x="1"
						y="3"
						width="149"
						height="15"
						key="staticText-15"/>
					<box></box>
					<textElement>
						<font size="8"/>
					</textElement>
				<text><![CDATA[GENERATED BY ETRACS 2.5  ]]></text>
				</staticText>
				<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="161"
						y="3"
						width="210"
						height="15"
						key="textField-5"/>
					<box></box>
					<textElement>
						<font size="8"/>
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA["PRINTED BY " + $P{PRINTEDBY}]]></textFieldExpression>
				</textField>
				<line direction="TopDown">
					<reportElement
						x="0"
						y="1"
						width="535"
						height="2"
						key="line-5"/>
					<graphicElement stretchType="NoStretch"/>
				</line>
			</band>
		</lastPageFooter>
		<summary>
			<band height="26"  isSplitAllowed="true" >
				<staticText>
					<reportElement
						x="343"
						y="5"
						width="79"
						height="17"
						key="staticText-11"/>
					<box></box>
					<textElement textAlignment="Right">
						<font pdfFontName="Helvetica-Bold" isBold="true"/>
					</textElement>
				<text><![CDATA[Grand Total:]]></text>
				</staticText>
				<textField isStretchWithOverflow="false" pattern="#,##0.00" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="420"
						y="5"
						width="103"
						height="18"
						key="textField"/>
					<box></box>
					<textElement textAlignment="Right">
						<font pdfFontName="Helvetica-Bold" isBold="true"/>
					</textElement>
				<textFieldExpression   class="java.lang.Double"><![CDATA[$V{grandtotal}]]></textFieldExpression>
				</textField>
				<line direction="TopDown">
					<reportElement
						x="0"
						y="0"
						width="535"
						height="2"
						key="line-3"/>
					<graphicElement stretchType="NoStretch"/>
				</line>
			</band>
		</summary>
</jasperReport>
