<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<!DOCTYPE document SYSTEM "rml_1_0.dtd">
{% load i18n satchmo_currency %}
<document filename="{{ filename }}">
<template pageSize="(21.5cm, 28cm)" leftMargin="1.0cm" rightMargin="1.0cm" topMargin="1.0cm" bottomMargin="1.0cm" title="Store Packing Slip" author="{{ shopDetails.store_name }}" allowSplitting="20">
	<pageTemplate id="first">
		<pageGraphics>

			<image x="5mm" y="240mm" width="65mm" height="30mm" file="{{iconURI}}"/>

            <setFont name="Helvetica" size="10"/>
			<fill color="(0,0,0)"/>

			<drawString x="14cm" y="270mm">{% trans "Invoice #" %}</drawString>
			<drawString x="14cm" y="266mm">{% trans "Date" %}: </drawString>

			<drawRightString x="18cm" y="270mm">{{ order.id }}</drawRightString>
			<drawRightString x="18cm" y="266mm">{% now "N j, Y" %}</drawRightString>

			<setFont name="Helvetica" size="16"/>
			<drawCentredString x="11cm" y="182mm">{% trans "PACKING SLIP" %}</drawCentredString>
            
            <setFont name="Helvetica" size="14"/>
			<drawString x="7.5cm" y="24cm">{% trans "Billing Address" %}</drawString>
            <drawString x="13.5cm" y="24cm">{% trans "Shipping Address" %}</drawString>
            
            <setFont name="Helvetica" size="12"/>
            <drawString x="1cm" y="235mm">{{shopDetails.street1}}</drawString>
            {% if shopDetails.street2 %}
            <drawString x="1cm" y="230mm">{{shopDetails.street2}}</drawString>
            <drawString x="1cm" y="225mm">{{shopDetails.city}}, {{shopDetails.state}} {{shopDetails.postal_code}}</drawString>
            <drawString x="1cm" y="220mm">{{shopDetails.phone}}</drawString>
            <drawString x="1cm" y="215mm">{{shopDetails.store_email}}</drawString>
            {% else %}
            <drawString x="1cm" y="230mm">{{shopDetails.city}}, {{shopDetails.state}} {{shopDetails.postal_code}}</drawString>
            <drawString x="1cm" y="225mm">{{shopDetails.phone}}</drawString>
            <drawString x="1cm" y="220mm">{{shopDetails.store_email}}</drawString>
            {% endif %}
            <rect x="13.5cm" y="26.2cm" width="5cm" height="1.3cm" fill="no" stroke="yes" round="5mm" />
            
            <rect x="7.1cm" y="19.8cm" width="5cm" height="4cm" fill="no" stroke="yes" round="5mm" />
            <rect x="13.1cm" y="19.8cm" width="5cm" height="4cm" fill="no" stroke="yes" round="5mm" />
            
		</pageGraphics>
        <frame id="billaddress" x1="7cm" y1="18.9cm" width="5cm" height="5cm" />
		<frame id="shipaddress" x1="13cm" y1="18.9cm" width="5cm" height="5cm"/>
		<frame id="column" x1="1.0cm" y1="2cm" width="19cm" height="16.5cm"/>
	</pageTemplate>
	<pageTemplate id="others">
		<pageGraphics>
			<image x="5mm" y="240mm" width="65mm" height="30mm" file="{{iconURI}}"/>

			<setFont name="Helvetica" size="8"/>
			<fill color="(0,0,0)"/>

			<drawString x="15cm" y="270mm">{% trans "Invoice #" %}</drawString>
			<drawString x="15cm" y="266mm">{% trans "Date" %}: </drawString>

			<drawRightString x="20cm" y="270mm">{{ order.id }}</drawRightString>
			<drawRightString x="20cm" y="266mm">{% now "N j, Y" %}</drawRightString>

			<setFont name="Helvetica" size="18"/>
			<drawString x="13cm" y="230mm">{% trans "PACKING SLIP" %}, {% trans "Page" %} 2</drawString>
            <rect x="14.5cm" y="26cm" width="6.5cm" height="1.5cm" fill="no" stroke="yes" round="5mm" />
		</pageGraphics>
		<frame id="column" x1="2.0cm" y1="1.5cm" width="18cm" height="17cm"/>
	</pageTemplate>
</template>
<stylesheet>
	<blockTableStyle id="accounts">
		<blockAlignment value="RIGHT" start="-1,0" stop="-1,-1"/>
		<lineStyle kind="LINEABOVE" start="-1,-2" stop="-1,-2"/>
	</blockTableStyle>

	<paraStyle name="conditions" fontName="Helvetica" fontSize="8" alignment="justify"/>
	<paraStyle name="name" fontName="Helvetica-Bold" fontSize="12"/>
	<paraStyle name="payment" fontName="Helvetica" fontSize="14"/>
	<blockTableStyle id="products">
		 <blockFont name="Helvetica-BoldOblique" size="12" start="0,0" stop="-1,0"/>
		 <blockBackground colorName="grey" start="0,0" stop="-1,0"/>
		 <blockTextColor colorName="white" start="0,0" stop="-1,0"/>
		 <blockValign value="TOP"/>
		 <blockAlignment value="RIGHT" start="1,0" stop="-1,-1"/>
		 <lineStyle kind="LINEBELOW" colorName="black" start="0,0" stop="-1,0"/>
	</blockTableStyle>
</stylesheet>
<story>

    <para style="name">{{order.bill_addressee}}</para>
	<para>{{order.bill_street1}}</para>
	{% if order.bill_street2 %}
          <para>{{ order.bill_street2}}</para>
        {% endif %}
	<para>{{order.bill_city}}, {{order.bill_state}}</para>
	<para>{{order.bill_postal_code}}</para>
        {% ifnotequal order.bill_country shopDetails.country.iso2_code %}
        <para>{{order.bill_country_name}}</para>
        {% else %}
	<spacer length="0.8cm" width="1mm"/>
	{% endifnotequal %}
	<para>{% trans "Phone" %}: {{order.contact.primary_phone.phone}}</para>
	<para>{% trans "Email" %}: {{order.contact.email}}</para>

	<nextFrame/>
    
    <para style="name">{{order.ship_addressee}}</para>
	<para>{{order.ship_street1}}</para>
        {% if order.ship_street2 %}
          <para>{{ order.ship_street2 }}</para>
        {% endif %}
	<para>{{order.ship_city}}, {{order.ship_state}}</para>
	<para>{{order.ship_postal_code}}</para>
        {% ifnotequal order.ship_country shopDetails.country.iso2_code %}
        <para>{{ order.ship_country_name }}</para>
        {% else %}
	<spacer length="0.8cm" width="1mm"/>
        {% endifnotequal %}
    <nextFrame/>
    
	<setNextTemplate name="others"/>
	<spacer length="0.5cm" width="1mm"/>
	<blockTable colWidths="14cm, 3.5cm" style="products">
	<tr>
		<td>{% trans "Description" %}</td>
        <td>{% trans "Quantity" %}</td>
	</tr>
    {% for item in order.orderitem_set.all %}
    <tr>
        <td><para>{{ item.product.name|fix_ampersands }}</para></td>
        <td>{{ item.quantity }} </td>
    </tr>
    {% endfor %}
	<tr><td></td></tr>
    <tr><td></td></tr>
	</blockTable>
	<spacer length="0.5cm" width="1mm"/>
	<para style="payment">
		{% trans "Thank you for your business!" %}
	</para>
</story>
</document>
