<!DOCTYPE openRPTDef>
<report>
 <title>Credit Card Receipt</title>
 <name>CCReceipt</name>
 <description></description>
 <size>Letter</size>
 <portrait/>
 <topmargin>100</topmargin>
 <bottommargin>100</bottommargin>
 <rightmargin>100</rightmargin>
 <leftmargin>100</leftmargin>
 <querysource>
  <name>header</name>
  <sql>SELECT remitto.*,
       formatAddr(remitto_address1, remitto_address2,
                  remitto_address3, remitto_citystatezip,
                  remitto_country) AS remitto_addr
FROM remitto;</sql>
 </querysource>
 <querysource>
  <name>detail</name>
  <sql>SELECT *,
       formatbytea(decrypt(setbytea(ccard_name),
                           setbytea(&lt;? value("key") ?>),
                           'bf')) AS holder,
       formatccnumber(decrypt(setbytea(ccard_number),
                              setbytea(&lt;? value("key") ?>),
                              'bf')) AS xxxx,
       CASE WHEN (ccpay_type='A') THEN &lt;? value("preauth") ?>
            WHEN (ccpay_type='C') THEN &lt;? value("charge") ?>
            WHEN (ccpay_type='R') THEN &lt;? value("refund") ?>
            ELSE ccpay_type
       END AS type,
       CASE WHEN (ccpay_status='A') THEN &lt;? value("authorized") ?>
            WHEN (ccpay_status='C') THEN &lt;? value("approved") ?>
            WHEN (ccpay_status='D') THEN &lt;? value("declined") ?>
            WHEN (ccpay_status='R') THEN &lt;? value("reversed") ?>
            WHEN (ccpay_status='V') THEN &lt;? value("voided") ?>
            WHEN (ccpay_status='X') THEN &lt;? value("noapproval") ?>
            ELSE ccpay_status
       END AS status

FROM ccpay JOIN
     ccard ON (ccpay_ccard_id=ccard_id) JOIN
     custinfo ON (ccard_cust_id=cust_id)
WHERE (ccpay_id=&lt;? value("ccpay_id") ?>);</sql>
 </querysource>
 <pghead>
  <height>101</height>
  <text>
   <rect>
    <x>0</x>
    <y>60</y>
    <width>250</width>
    <height>15</height>
   </rect>
   <bottompad>40</bottompad>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>header</query>
    <column>remitto_addr</column>
   </data>
  </text>
  <label>
   <rect>
    <x>0</x>
    <y>20</y>
    <width>150</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Printed:</string>
  </label>
  <field>
   <rect>
    <x>0</x>
    <y>40</y>
    <width>150</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>header</query>
    <column>remitto_name</column>
   </data>
  </field>
  <label>
   <rect>
    <x>0</x>
    <y>0</y>
    <width>150</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Credit Card Receipt</string>
  </label>
  <field>
   <rect>
    <x>160</x>
    <y>20</y>
    <width>100</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>Context Query</query>
    <column>report_date</column>
   </data>
  </field>
 </pghead>
 <section>
  <name>Header</name>
  <detail>
   <key>
    <query>header</query>
   </key>
   <height>101</height>
  </detail>
 </section>
 <section>
  <name>Detail</name>
  <detail>
   <key>
    <query>detail</query>
   </key>
   <height>231</height>
   <field>
    <rect>
     <x>130</x>
     <y>160</y>
     <width>200</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>10</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>ccpay_r_ref</column>
    </data>
   </field>
   <label>
    <rect>
     <x>0</x>
     <y>160</y>
     <width>125</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>10</size>
     <weight>normal</weight>
    </font>
    <right/>
    <vcenter/>
    <string>Approval Code:</string>
   </label>
   <field>
    <rect>
     <x>130</x>
     <y>200</y>
     <width>200</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>10</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>ccpay_r_ordernum</column>
    </data>
   </field>
   <label>
    <rect>
     <x>0</x>
     <y>40</y>
     <width>125</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>10</size>
     <weight>normal</weight>
    </font>
    <right/>
    <vcenter/>
    <string>Card Number:</string>
   </label>
   <label>
    <rect>
     <x>0</x>
     <y>140</y>
     <width>125</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>10</size>
     <weight>normal</weight>
    </font>
    <right/>
    <vcenter/>
    <string>Status:</string>
   </label>
   <field>
    <rect>
     <x>130</x>
     <y>60</y>
     <width>200</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>10</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>ccpay_transaction_datetime</column>
    </data>
   </field>
   <field>
    <rect>
     <x>130</x>
     <y>80</y>
     <width>200</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>10</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>type</column>
    </data>
   </field>
   <field>
    <rect>
     <x>130</x>
     <y>100</y>
     <width>200</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>10</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>ccpay_amount</column>
    </data>
   </field>
   <label>
    <rect>
     <x>0</x>
     <y>200</y>
     <width>125</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>10</size>
     <weight>normal</weight>
    </font>
    <right/>
    <vcenter/>
    <string>Order:</string>
   </label>
   <label>
    <rect>
     <x>0</x>
     <y>0</y>
     <width>125</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>10</size>
     <weight>normal</weight>
    </font>
    <right/>
    <vcenter/>
    <string>Customer Name:</string>
   </label>
   <label>
    <rect>
     <x>0</x>
     <y>100</y>
     <width>125</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>10</size>
     <weight>normal</weight>
    </font>
    <right/>
    <vcenter/>
    <string>Amount:</string>
   </label>
   <label>
    <rect>
     <x>0</x>
     <y>60</y>
     <width>125</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>10</size>
     <weight>normal</weight>
    </font>
    <right/>
    <vcenter/>
    <string>Transaction Date:</string>
   </label>
   <field>
    <rect>
     <x>130</x>
     <y>180</y>
     <width>200</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>10</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>ccpay_by_username</column>
    </data>
   </field>
   <field>
    <rect>
     <x>130</x>
     <y>20</y>
     <width>200</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>10</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>holder</column>
    </data>
   </field>
   <field>
    <rect>
     <x>130</x>
     <y>0</y>
     <width>200</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>10</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>cust_name</column>
    </data>
   </field>
   <label>
    <rect>
     <x>0</x>
     <y>80</y>
     <width>125</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>10</size>
     <weight>normal</weight>
    </font>
    <right/>
    <vcenter/>
    <string>Transaction Type:</string>
   </label>
   <label>
    <rect>
     <x>0</x>
     <y>180</y>
     <width>125</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>10</size>
     <weight>normal</weight>
    </font>
    <right/>
    <vcenter/>
    <string>By:</string>
   </label>
   <field>
    <rect>
     <x>130</x>
     <y>140</y>
     <width>200</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>10</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>status</column>
    </data>
   </field>
   <label>
    <rect>
     <x>0</x>
     <y>20</y>
     <width>125</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>10</size>
     <weight>normal</weight>
    </font>
    <right/>
    <vcenter/>
    <string>Cardholder:</string>
   </label>
   <field>
    <rect>
     <x>130</x>
     <y>40</y>
     <width>200</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>10</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>xxxx</column>
    </data>
   </field>
  </detail>
 </section>
</report>
