<?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="so_tagliandi_testata" language="groovy" pageWidth="595" pageHeight="555" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="0" bottomMargin="0" uuid="ec199b87-ad79-489e-912c-9d107bd9bf4f">
	<property name="ireport.zoom" value="1.5"/>
	<property name="ireport.x" value="0"/>
	<property name="ireport.y" value="0"/>
	<style name="Intestazione" mode="Opaque" forecolor="#000000" backcolor="#C0C0C0" fill="Solid" radius="5" hAlign="Left" vAlign="Middle" fontSize="8" isBold="true">
		<pen lineWidth="0.25" lineColor="#000000"/>
		<box>
			<pen lineWidth="0.25"/>
			<topPen lineWidth="0.25" lineColor="#000000"/>
			<leftPen lineWidth="0.25" lineColor="#000000"/>
			<bottomPen lineWidth="0.25" lineColor="#000000"/>
			<rightPen lineWidth="0.25" lineColor="#000000"/>
		</box>
		<paragraph leftIndent="2"/>
	</style>
	<style name="Campi" fill="Solid" hAlign="Left" vAlign="Middle" fontSize="8">
		<paragraph leftIndent="2"/>
	</style>
	<style name="NomeCampo" hAlign="Left" vAlign="Middle" fontSize="8" isBold="true">
		<paragraph leftIndent="2"/>
	</style>
	<parameter name="idtestata" class="java.lang.Integer">
		<defaultValueExpression><![CDATA[]]></defaultValueExpression>
	</parameter>
	<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
		<defaultValueExpression><![CDATA["/home/dlicitra/Scrivania/stampe_spedibox/segnacollo/"]]></defaultValueExpression>
	</parameter>
	<queryString>
		<![CDATA[SELECT 	tes.*,
	CONCAT(tes.codpost_mitt,' ', tes.localita_mitt,'(',provmitt.iso,')') as cap_loc_pv_mitt ,
	CONCAT(tes.codpost_dest,' ', tes.localita_dest,'(',provdest.iso,')') as cap_loc_pv_dest ,
	'copia cliente' as descrizione
	FROM 	testateordini as tes
	  LEFT join comuni AS comitt on upper(comitt.comune) = upper(tes.localita_mitt) and comitt.cap = tes.codpost_mitt
            LEFT join comuni AS codest on upper(codest.comune) = upper(tes.localita_dest) and codest.cap = tes.codpost_dest
	LEFT JOIN province as provmitt ON provmitt.id = coalesce(comitt.idprovince,0)
	LEFT JOIN province as provdest ON provdest.id = coalesce(codest.idprovince,0)
	WHERE tes.id=$P{idtestata}

UNION

SELECT tes.* ,
	CONCAT(tes.codpost_mitt,' ', tes.localita_mitt,'(',provmitt.iso,')') as cap_loc_pv_mitt ,
	CONCAT(tes.codpost_dest,' ', tes.localita_dest,'(',provdest.iso,')') as cap_loc_pv_dest ,
	'copia vettore' as descrizione
	FROM 	testateordini as tes
	  LEFT join comuni AS comitt on upper(comitt.comune) = upper(tes.localita_mitt) and comitt.cap = tes.codpost_mitt
	  LEFT join comuni AS codest on upper(codest.comune) = upper(tes.localita_dest) and codest.cap = tes.codpost_dest
		LEFT JOIN province as provmitt ON provmitt.id = coalesce(comitt.idprovince,0)
		LEFT JOIN province as provdest ON provdest.id = coalesce(codest.idprovince,0)
	where tes.id=$P{idtestata}]]>
	</queryString>
	<field name="id" class="java.lang.Integer"/>
	<field name="aliquotaiva" class="java.lang.Double"/>
	<field name="azienda" class="java.lang.String"/>
	<field name="codiceordine" class="java.lang.String"/>
	<field name="codpost_dest" class="java.lang.String"/>
	<field name="codpost_mitt" class="java.lang.String"/>
	<field name="cognome_dest" class="java.lang.String"/>
	<field name="cognome_mitt" class="java.lang.String"/>
	<field name="contatto_dest" class="java.lang.String"/>
	<field name="contatto_mitt" class="java.lang.String"/>
	<field name="dataordine" class="java.sql.Date"/>
	<field name="dataritiro" class="java.sql.Date"/>
	<field name="esercizio" class="java.lang.String"/>
	<field name="gdo_dest" class="java.lang.Boolean"/>
	<field name="gdo_mitt" class="java.lang.Boolean"/>
	<field name="indirizzo_dest" class="java.lang.String"/>
	<field name="indirizzo_mitt" class="java.lang.String"/>
	<field name="ins_time" class="java.sql.Timestamp"/>
	<field name="ins_user" class="java.lang.String"/>
	<field name="localita_dest" class="java.lang.String"/>
	<field name="localita_mitt" class="java.lang.String"/>
	<field name="nazione_dest" class="java.lang.String"/>
	<field name="nazione_mitt" class="java.lang.String"/>
	<field name="nome_dest" class="java.lang.String"/>
	<field name="nome_mitt" class="java.lang.String"/>
	<field name="noteritiro_dest" class="java.lang.String"/>
	<field name="noteritiro_mitt" class="java.lang.String"/>
	<field name="numpacchi" class="java.lang.Integer"/>
	<field name="pedanearendere" class="java.lang.Integer"/>
	<field name="prezzoivato" class="java.lang.Double"/>
	<field name="statoordine" class="java.lang.String"/>
	<field name="stato_dest" class="java.lang.String"/>
	<field name="stato_mitt" class="java.lang.String"/>
	<field name="status" class="java.lang.String"/>
	<field name="telcontatto_dest" class="java.lang.String"/>
	<field name="telcontatto_mitt" class="java.lang.String"/>
	<field name="totkg" class="java.lang.Double"/>
	<field name="totmtcubi" class="java.lang.Double"/>
	<field name="upd_time" class="java.sql.Timestamp"/>
	<field name="upd_user" class="java.lang.String"/>
	<field name="idaddclienti" class="java.lang.Long"/>
	<field name="idutente" class="java.lang.Long"/>
	<field name="fatturato" class="java.lang.Boolean"/>
	<field name="email_mitt" class="java.lang.String"/>
	<field name="cap_loc_pv_mitt" class="java.lang.String"/>
	<field name="cap_loc_pv_dest" class="java.lang.String"/>
	<field name="descrizione" class="java.lang.String"/>
	<background>
		<band splitType="Stretch"/>
	</background>
	<title>
		<band height="32" splitType="Stretch">
			<rectangle radius="5">
				<reportElement x="0" y="1" width="554" height="30" uuid="68cf31f6-9537-400b-91cc-7a0ecae78169"/>
				<graphicElement>
					<pen lineWidth="0.5"/>
				</graphicElement>
			</rectangle>
			<staticText>
				<reportElement x="7" y="1" width="124" height="29" uuid="4bb2f3bd-a7f6-43bd-acec-5370ab60e085"/>
				<textElement verticalAlignment="Middle"/>
				<text><![CDATA[Firma vettore per ricevuta :]]></text>
			</staticText>
			<staticText>
				<reportElement x="374" y="1" width="38" height="29" uuid="91351093-6049-4837-acb2-b7a438043d10"/>
				<textElement verticalAlignment="Middle"/>
				<text><![CDATA[Data :]]></text>
			</staticText>
		</band>
	</title>
	<pageHeader>
		<band splitType="Stretch"/>
	</pageHeader>
	<columnHeader>
		<band splitType="Stretch"/>
	</columnHeader>
	<detail>
		<band height="200" splitType="Stretch">
			<staticText>
				<reportElement style="Intestazione" mode="Opaque" x="0" y="70" width="70" height="14" forecolor="#000000" uuid="8d9d15bd-4c7e-48e4-abd2-bf28e230db1f"/>
				<text><![CDATA[Mittente]]></text>
			</staticText>
			<textField isStretchWithOverflow="true">
				<reportElement style="Campi" x="71" y="70" width="120" height="14" uuid="08f891d3-f3cb-43d3-8091-5049a8fc23a7"/>
				<textFieldExpression><![CDATA[$F{nome_mitt} + " " + $F{cognome_mitt}]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement style="Intestazione" x="204" y="70" width="70" height="14" uuid="2c14fb9b-7d43-4004-8c00-dff2813d1ff4"/>
				<text><![CDATA[Destinatario]]></text>
			</staticText>
			<textField isStretchWithOverflow="true">
				<reportElement style="Campi" x="275" y="70" width="120" height="14" uuid="657661ae-7403-482c-b072-52efb226fb0e"/>
				<textFieldExpression><![CDATA[$F{nome_dest} + " " + $F{cognome_dest}]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement style="Intestazione" x="400" y="70" width="154" height="14" uuid="1d85969c-5ead-4525-be42-5bace3c8c353"/>
				<text><![CDATA[Riepilogo spedizione - merce]]></text>
			</staticText>
			<textField>
				<reportElement x="157" y="11" width="397" height="20" forecolor="#FF9900" uuid="0000578e-edee-404f-89e1-fa29ca323e2b"/>
				<textElement textAlignment="Right" verticalAlignment="Middle">
					<font size="12"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{descrizione}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="157" y="31" width="397" height="20" uuid="363d7522-fb67-436c-9a02-d042cf8bbeac"/>
				<textElement textAlignment="Right" verticalAlignment="Middle">
					<font isBold="true"/>
				</textElement>
				<textFieldExpression><![CDATA['Ordine ' + $F{codiceordine}]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement style="NomeCampo" x="401" y="84" width="70" height="14" uuid="1d4ce176-4859-4a06-898c-83f878840df7"/>
				<textElement verticalAlignment="Middle"/>
				<text><![CDATA[Colli Pallet]]></text>
			</staticText>
			<staticText>
				<reportElement style="NomeCampo" x="401" y="98" width="70" height="14" uuid="83a955ea-3103-4dfc-8bb2-fda8579c04a9"/>
				<text><![CDATA[Volume]]></text>
			</staticText>
			<staticText>
				<reportElement style="NomeCampo" x="401" y="112" width="70" height="14" uuid="6719ff0a-cd54-487c-b73b-f74c1b403cf6"/>
				<text><![CDATA[Peso]]></text>
			</staticText>
			<textField>
				<reportElement style="Campi" x="473" y="84" width="83" height="14" uuid="c0d4b56d-0c33-420a-a251-98021a7e9c9c"/>
				<textElement textAlignment="Right"/>
				<textFieldExpression><![CDATA['n.' + $F{numpacchi}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement style="Campi" x="473" y="98" width="82" height="14" uuid="aa81aa21-c3c8-4c17-a192-62d49f772e78"/>
				<textElement textAlignment="Right"/>
				<textFieldExpression><![CDATA['mc ' + $F{totmtcubi}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement style="Campi" x="473" y="112" width="81" height="14" uuid="6eed9e93-f187-4d27-ad83-313bfd0a2974"/>
				<textElement textAlignment="Right"/>
				<textFieldExpression><![CDATA['kg ' + $F{totkg}]]></textFieldExpression>
			</textField>
			<subreport>
				<reportElement positionType="Float" x="-19" y="126" width="595" height="74" uuid="b2d297fc-aa05-4370-afe0-5156a93f98b4"/>
				<subreportParameter name="SUBREPORT_DIR">
					<subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>
				</subreportParameter>
				<subreportParameter name="idtestata">
					<subreportParameterExpression><![CDATA[$P{idtestata}]]></subreportParameterExpression>
				</subreportParameter>
				<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
				<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "so_tagliandi_subreport1.jasper"]]></subreportExpression>
			</subreport>
			<frame>
				<reportElement positionType="Float" x="204" y="84" width="190" height="14" uuid="1b46d570-7cec-4211-a794-9e44bb9ccf39"/>
				<textField isStretchWithOverflow="true">
					<reportElement style="Campi" positionType="Float" x="70" y="0" width="120" height="14" uuid="d6d8a8bc-108b-4503-a177-4f7bae40a54d"/>
					<textFieldExpression><![CDATA[$F{indirizzo_dest}]]></textFieldExpression>
				</textField>
				<staticText>
					<reportElement style="NomeCampo" positionType="Float" x="0" y="0" width="70" height="14" uuid="62f01224-ca98-4559-9e25-6a91842547da"/>
					<textElement verticalAlignment="Middle"/>
					<text><![CDATA[Indirizzo]]></text>
				</staticText>
			</frame>
			<frame>
				<reportElement positionType="Float" x="0" y="84" width="191" height="14" uuid="2e01e8bf-88fd-4e56-8a29-42d855fec4c3"/>
				<textField isStretchWithOverflow="true">
					<reportElement style="Campi" positionType="Float" x="70" y="0" width="121" height="14" uuid="8c7f0519-a070-45a2-a49b-df1cbc649204"/>
					<textFieldExpression><![CDATA[$F{indirizzo_mitt}]]></textFieldExpression>
				</textField>
				<staticText>
					<reportElement style="NomeCampo" x="0" y="0" width="70" height="14" uuid="1da21fb4-f4c1-4b9a-b68c-9da4632943db"/>
					<textElement verticalAlignment="Middle"/>
					<text><![CDATA[Indirizzo]]></text>
				</staticText>
			</frame>
			<frame>
				<reportElement positionType="Float" x="204" y="98" width="190" height="14" uuid="4f2f5e37-7510-4d89-b435-29df47cdc3b9"/>
				<textField isStretchWithOverflow="true">
					<reportElement style="Campi" positionType="Float" x="70" y="0" width="120" height="14" uuid="15766b67-0999-4868-ad56-bfb7c913fa34"/>
					<textFieldExpression><![CDATA[$F{cap_loc_pv_dest}]]></textFieldExpression>
				</textField>
				<staticText>
					<reportElement style="NomeCampo" positionType="Float" x="0" y="0" width="70" height="14" uuid="71cecb4b-aa06-4cf8-af3a-242640db3811"/>
					<text><![CDATA[CAP]]></text>
				</staticText>
			</frame>
			<frame>
				<reportElement positionType="Float" x="0" y="98" width="191" height="14" uuid="a9390a07-99ee-447b-8447-0ba40c017592"/>
				<textField isStretchWithOverflow="true">
					<reportElement style="Campi" positionType="Float" x="70" y="0" width="121" height="14" uuid="b8b6e21a-802d-40b3-8e65-086638791fe5"/>
					<textFieldExpression><![CDATA[$F{cap_loc_pv_mitt}]]></textFieldExpression>
				</textField>
				<staticText>
					<reportElement style="NomeCampo" positionType="Float" x="0" y="0" width="70" height="14" uuid="cdf2ddb9-c8e3-45e6-99ca-3adcf74d787b"/>
					<text><![CDATA[CAP]]></text>
				</staticText>
			</frame>
			<frame>
				<reportElement positionType="Float" x="0" y="112" width="191" height="14" uuid="f1136538-06de-4d2e-92ac-38221c830f53"/>
				<staticText>
					<reportElement style="NomeCampo" positionType="Float" x="0" y="0" width="70" height="14" uuid="8824e1c1-85fe-4b92-94b9-f287446d7b92"/>
					<text><![CDATA[Nazione]]></text>
				</staticText>
				<textField>
					<reportElement style="Campi" positionType="Float" x="70" y="0" width="60" height="14" uuid="2fec745b-7b92-4bf1-8a44-94ac40f82b83"/>
					<textFieldExpression><![CDATA[$F{nazione_mitt}]]></textFieldExpression>
				</textField>
				<textField isBlankWhenNull="true">
					<reportElement style="Campi" positionType="Float" x="130" y="0" width="60" height="14" uuid="654116e0-34c6-4680-88dc-889a2ec5ba05"/>
					<textFieldExpression><![CDATA[$F{stato_mitt}]]></textFieldExpression>
				</textField>
			</frame>
			<frame>
				<reportElement positionType="Float" x="1" y="126" width="191" height="14" uuid="3a4650e1-1fe3-4993-988e-e1e707f32c24"/>
				<staticText>
					<reportElement style="NomeCampo" positionType="FixRelativeToBottom" x="0" y="0" width="69" height="14" uuid="275460de-613d-43e4-be68-59f7857f2002"/>
					<text><![CDATA[Contatto]]></text>
				</staticText>
				<textField>
					<reportElement style="Campi" positionType="Float" x="69" y="0" width="122" height="14" uuid="b1db9798-bf3b-436b-9138-7089ecdc7f8d"/>
					<textFieldExpression><![CDATA[$F{contatto_mitt}]]></textFieldExpression>
				</textField>
			</frame>
			<frame>
				<reportElement positionType="Float" x="0" y="140" width="192" height="14" uuid="c9f71bcf-449d-4fb7-9c97-152cc09591d7"/>
				<staticText>
					<reportElement style="NomeCampo" positionType="FixRelativeToBottom" x="0" y="0" width="70" height="14" uuid="968328a3-bdc5-428e-b25b-01394ce51c94"/>
					<text><![CDATA[Recapito]]></text>
				</staticText>
				<textField>
					<reportElement style="Campi" positionType="Float" x="70" y="0" width="122" height="14" uuid="a3fe8231-1062-4d2b-a73b-fa214e6ef0ac"/>
					<textFieldExpression><![CDATA[$F{telcontatto_mitt}]]></textFieldExpression>
				</textField>
			</frame>
			<frame>
				<reportElement positionType="Float" x="1" y="154" width="191" height="31" uuid="040da94d-681c-4e54-9824-49f936e92c57"/>
				<staticText>
					<reportElement style="NomeCampo" positionType="FixRelativeToBottom" x="0" y="0" width="69" height="14" uuid="3113013a-3572-419b-8b2b-56e342cc22c5"/>
					<text><![CDATA[Note]]></text>
				</staticText>
				<textField isStretchWithOverflow="true">
					<reportElement style="Campi" positionType="Float" x="69" y="0" width="122" height="31" uuid="815f06f2-9f0e-4a24-82e3-de75b7145499">
						<printWhenExpression><![CDATA[$F{noteritiro_mitt} != null && !$F{noteritiro_mitt}.isEmpty()]]></printWhenExpression>
					</reportElement>
					<textElement verticalAlignment="Middle"/>
					<textFieldExpression><![CDATA[$F{noteritiro_mitt}]]></textFieldExpression>
				</textField>
			</frame>
			<frame>
				<reportElement positionType="Float" x="204" y="112" width="190" height="14" uuid="8960b7f7-91c6-4131-8739-7ec7fd753d2f"/>
				<staticText>
					<reportElement style="NomeCampo" positionType="Float" x="0" y="0" width="70" height="14" uuid="7fd5e86f-d418-4f08-82d6-89af1003ce01"/>
					<text><![CDATA[Nazione]]></text>
				</staticText>
				<textField>
					<reportElement style="Campi" positionType="Float" x="70" y="0" width="60" height="14" uuid="d4ac1908-f30a-4cd6-b7c0-87aecb2e4241"/>
					<textFieldExpression><![CDATA[$F{nazione_dest}]]></textFieldExpression>
				</textField>
				<textField isBlankWhenNull="true">
					<reportElement style="Campi" positionType="Float" x="130" y="0" width="60" height="14" uuid="447c268e-743c-451a-9560-c45acef36a5a"/>
					<textFieldExpression><![CDATA[$F{stato_dest}]]></textFieldExpression>
				</textField>
			</frame>
			<frame>
				<reportElement positionType="Float" x="204" y="126" width="190" height="14" uuid="c381f610-228d-4707-8558-50590bb105eb"/>
				<staticText>
					<reportElement style="NomeCampo" positionType="FixRelativeToBottom" x="0" y="0" width="70" height="14" uuid="7ce00b13-dfff-4ead-a10f-fb5b857b3155"/>
					<text><![CDATA[Contatto]]></text>
				</staticText>
				<textField>
					<reportElement style="Campi" positionType="FixRelativeToBottom" x="70" y="0" width="120" height="14" uuid="8ee2efc9-9dbc-4409-a0cd-86a6c0aa27a5"/>
					<textFieldExpression><![CDATA[$F{contatto_dest}]]></textFieldExpression>
				</textField>
			</frame>
			<frame>
				<reportElement positionType="Float" x="204" y="140" width="190" height="14" uuid="aa49a3c1-640d-4ff0-baa4-b2390546db5a"/>
				<staticText>
					<reportElement style="NomeCampo" positionType="FixRelativeToBottom" x="0" y="0" width="70" height="14" uuid="3f4dd8ca-3bcd-4dfc-b9de-b9f1f3443b7d"/>
					<text><![CDATA[Recapito]]></text>
				</staticText>
				<textField>
					<reportElement style="Campi" positionType="FixRelativeToBottom" x="70" y="0" width="120" height="14" uuid="2b4918ca-2d48-44ed-b353-63e60502b4da"/>
					<textFieldExpression><![CDATA[$F{telcontatto_dest}]]></textFieldExpression>
				</textField>
			</frame>
			<frame>
				<reportElement positionType="Float" x="204" y="154" width="190" height="31" uuid="6cee7138-bbe8-41eb-bf1a-ae8de4c000b0"/>
				<staticText>
					<reportElement style="NomeCampo" positionType="FixRelativeToBottom" x="0" y="0" width="70" height="14" uuid="af761639-4b21-4886-bcd3-e5bbc8e0740b"/>
					<text><![CDATA[Note]]></text>
				</staticText>
				<textField isStretchWithOverflow="true">
					<reportElement style="Campi" positionType="FixRelativeToBottom" x="70" y="0" width="120" height="31" uuid="4fcbdfcf-c243-42cb-ac68-2260eac5e1df">
						<printWhenExpression><![CDATA[$F{noteritiro_dest} != null && !$F{noteritiro_dest}.isEmpty()]]></printWhenExpression>
					</reportElement>
					<textElement verticalAlignment="Middle"/>
					<textFieldExpression><![CDATA[$F{noteritiro_dest}]]></textFieldExpression>
				</textField>
			</frame>
			<image hAlign="Center" vAlign="Middle">
				<reportElement x="1" y="0" width="157" height="70" uuid="965ef509-85bb-4bb8-8fbc-f19a9cfe66a0"/>
				<imageExpression><![CDATA[$P{SUBREPORT_DIR} + "logo.jpg"]]></imageExpression>
			</image>
		</band>
	</detail>
	<columnFooter>
		<band height="12" splitType="Stretch"/>
	</columnFooter>
	<pageFooter>
		<band splitType="Stretch"/>
	</pageFooter>
	<summary>
		<band splitType="Stretch"/>
	</summary>
</jasperReport>
