Receipt printing also from payment history
authorsenator <lebbeous@esilibrary.com>
Mon, 16 May 2011 22:39:32 +0000 (18:39 -0400)
committersenator <lebbeous@esilibrary.com>
Mon, 16 May 2011 22:39:32 +0000 (18:39 -0400)
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
Open-ILS/web/templates/default/opac/myopac/main_pay.tt2
Open-ILS/web/templates/default/opac/myopac/main_payments.tt2
Open-ILS/web/templates/default/opac/myopac/receipt_print.tt2 [new file with mode: 0644]

index 4a1811b..72fbf59 100644 (file)
@@ -125,6 +125,8 @@ sub load {
     return $self->load_myopac_payments if $path =~ m|opac/myopac/main_payments|;
     return $self->load_myopac_pay if $path =~ m|opac/myopac/main_pay|;
     return $self->load_myopac_main if $path =~ m|opac/myopac/main|;
+    return $self->load_myopac_receipt_email if $path =~ m|opac/myopac/receipt_email|;
+    return $self->load_myopac_receipt_print if $path =~ m|opac/myopac/receipt_print|;
     return $self->load_myopac_update_email if $path =~ m|opac/myopac/update_email|;
     return $self->load_myopac_update_password if $path =~ m|opac/myopac/update_password|;
     return $self->load_myopac_update_username if $path =~ m|opac/myopac/update_username|;
index 1e16eca..bb49e11 100644 (file)
@@ -640,6 +640,17 @@ sub load_myopac_pay {
     return Apache2::Const::OK;
 }
 
+sub load_myopac_receipt_print {
+    my $self = shift;
+
+    $self->ctx->{printable_receipt} = $U->simplereq(
+       "open-ils.circ", "open-ils.circ.money.payment_receipt.print",
+       $self->editor->authtoken, [$self->cgi->param("payment")]
+    );
+
+    return Apache2::Const::OK;
+}
+
 sub prepare_fines {
     my ($self, $limit, $offset, $id_list) = @_;
 
index 5cd7cdd..1992181 100644 (file)
         </p>
     [% ELSE %]
         <p><big>[% l('Your payment has been approved.') %]</big></p>
-        [% IF ctx.printable_receipt.template_output %]
-        <p>[ <a href="javascript:void(0);"
+        [% IF ctx.printable_receipt.template_output;
+            print_args = [];
+            FOR p IN ctx.payment_response.payments;
+                print_args.push('payment=' _ p);
+            END %]
+        <p>[ <a href="[% ctx.opac_root %]/myopac/receipt_print?[% print_args.join('&amp;') %]"
+            target="_egrecpt"
             onclick="try { print_node('printable-receipt'); } catch (e) { window.print(); } return false;">[% l('Print receipt') %]</a> ]</p>
         <tt id="printable-receipt">
             [% ctx.printable_receipt.template_output.data %]
@@ -28,6 +33,7 @@
         <div class="payment-error">
             [% l(
                 'Error creating receipt: [_1]',
+                    (ctx.printable_receipt.textcode ? ctx.printable_receipt.textcode _ ' / ' _ ctx.printable_receipt.desc : 0) ||
                     ctx.printable_receipt.error_output.data ||
                     l('No receipt data returned from server')
                 ) %]
index bf956b6..2c4daa4 100644 (file)
                 <td>[% (payment.xact_type == 'grocery') ? payment.last_billing_type : payment.title %]</td>
                 <td>[% money(payment.mp.amount) %]</td>
                 <td>
-                    [%# post to print/email form... %]
-                    <a href=''>[% l('Print') %]</a> / <a href=''>[% l('Email') %]</a>
+                    [%# post to print/email form... XXX wait, why post? -senator %]
+                    <a href="[% ctx.opac_root %]/myopac/receipt_print?payment=[% payment.mp.id %]" target="_egrcpt">[% l('Print') %]</a>
+                    /
+                    <a href=''>[% l('Email') %]</a>
                 </td>
             </tr>
             [% END %]
diff --git a/Open-ILS/web/templates/default/opac/myopac/receipt_print.tt2 b/Open-ILS/web/templates/default/opac/myopac/receipt_print.tt2
new file mode 100644 (file)
index 0000000..4867561
--- /dev/null
@@ -0,0 +1,22 @@
+[%# sic! no wrapper %]
+<html>
+    <head>
+        <title>[% l('Receipt') %]</title>
+    </head>
+    <body onload="if (document.getElementById('printable-receipt')) window.print();">
+        [% IF ctx.printable_receipt.template_output %]
+        <tt id="printable-receipt">
+            [% ctx.printable_receipt.template_output.data %]
+        </tt>
+        [% ELSE %]
+        <div class="payment-error">
+            [% l(
+                'Error creating receipt: [_1]',
+                    (ctx.printable_receipt.textcode ? ctx.printable_receipt.textcode _ ' / ' _ ctx.printable_receipt.desc : 0) ||
+                    ctx.printable_receipt.error_output.data ||
+                    l('No receipt data returned from server')
+                ) %]
+        </div>
+        [% END %]
+    </body>
+</html>