Emailing receipts working, some tweaks to payment history page
authorsenator <lebbeous@esilibrary.com>
Tue, 17 May 2011 15:31:08 +0000 (11:31 -0400)
committersenator <lebbeous@esilibrary.com>
Tue, 17 May 2011 15:31:08 +0000 (11:31 -0400)
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
Open-ILS/web/css/skin/default/opac/style.css
Open-ILS/web/templates/default/opac/myopac/main_payments.tt2
Open-ILS/web/templates/default/opac/myopac/receipt_email.tt2 [new file with mode: 0644]
Open-ILS/web/templates/default/opac/myopac/receipt_print.tt2

index bb49e11..0e96bb2 100644 (file)
@@ -5,9 +5,8 @@ use OpenSRF::Utils::Logger qw/$logger/;
 use OpenILS::Utils::CStoreEditor qw/:funcs/;
 use OpenILS::Utils::Fieldmapper;
 use OpenILS::Application::AppUtils;
+use OpenILS::Event;
 use OpenSRF::Utils::JSON;
-#use Data::Dumper;
-#$Data::Dumper::Indent = 0;
 my $U = 'OpenILS::Application::AppUtils';
 
 sub prepare_extended_user_info {
@@ -651,6 +650,24 @@ sub load_myopac_receipt_print {
     return Apache2::Const::OK;
 }
 
+sub load_myopac_receipt_email {
+    my $self = shift;
+
+    # The following ML method doesn't actually check whether the user in
+    # question has an email address, so we do.
+    if ($self->ctx->{user}->email) {
+        $self->ctx->{email_receipt_result} = $U->simplereq(
+           "open-ils.circ", "open-ils.circ.money.payment_receipt.email",
+           $self->editor->authtoken, [$self->cgi->param("payment")]
+        );
+    } else {
+        $self->ctx->{email_receipt_result} =
+            new OpenILS::Event("PATRON_NO_EMAIL_ADDRESS");
+    }
+
+    return Apache2::Const::OK;
+}
+
 sub prepare_fines {
     my ($self, $limit, $offset, $id_list) = @_;
 
index ac67524..caba3e0 100644 (file)
@@ -877,6 +877,10 @@ div.select-wrapper:hover {
 }
 
 #myopac_payments_table th { text-align: left; }
+#myopac_payments_table tbody tr:nth-child(odd) { background-color: #ddd; }
+#myopac_payments_table form { display: inline; }
+#myopac_payments_table input[type="submit"] { padding: 1px; }
+
 .payment-error {
     font-weight: bold; color: red;
     padding: 10px; border: 1px solid #888;
index 2c4daa4..83e25f3 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... 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>
+                    <form action="[% ctx.opac_root %]/myopac/receipt_print" method="POST">
+                        <input type="hidden" name="payment" value="[% payment.mp.id %]" />
+                        <input type="submit" value="[% l('Print') %]" />
+                    </form>
+                    <form action="[% ctx.opac_root %]/myopac/receipt_email" method="POST">
+                        <input type="hidden" name="payment" value="[% payment.mp.id %]" />
+                        <input type="submit" value="[% l('Email') %]" />
+                    </form>
                 </td>
             </tr>
             [% END %]
diff --git a/Open-ILS/web/templates/default/opac/myopac/receipt_email.tt2 b/Open-ILS/web/templates/default/opac/myopac/receipt_email.tt2
new file mode 100644 (file)
index 0000000..371f7df
--- /dev/null
@@ -0,0 +1,15 @@
+[%  PROCESS "default/opac/parts/header.tt2";
+    PROCESS "default/opac/parts/misc_util.tt2";
+    WRAPPER "default/opac/parts/myopac/base.tt2";
+    myopac_page = "prefs"  %]
+    [% IF ctx.email_receipt_result; # result should be undef on success %]
+    <div class="payment-error">
+        [% l('Error preparing receipt:') %]
+        <span title="[% ctx.email_receipt_result.textcode %]">
+            [% ctx.email_receipt_result.desc %]
+        </span>
+    </div>
+    [% ELSE %]
+    <div>[% l('Your receipt will be emailed to [_1]', ctx.user.email) %]</div>
+    [% END %]
+[% END %]
index 4867561..0ee7b12 100644 (file)
@@ -11,7 +11,7 @@
         [% ELSE %]
         <div class="payment-error">
             [% l(
-                'Error creating receipt: [_1]',
+                'Error preparing 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')