[open-ils-commits] r16486 - in trunk/Open-ILS/web: js/ui/default/circ/selfcheck templates/default/circ/selfcheck (senator)

svn at svn.open-ils.org svn at svn.open-ils.org
Mon May 24 12:04:45 EDT 2010


Author: senator
Date: 2010-05-24 12:04:42 -0400 (Mon, 24 May 2010)
New Revision: 16486

Added:
   trunk/Open-ILS/web/js/ui/default/circ/selfcheck/payment.js
Modified:
   trunk/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js
   trunk/Open-ILS/web/templates/default/circ/selfcheck/main.tt2
   trunk/Open-ILS/web/templates/default/circ/selfcheck/payment.tt2
Log:
Separate payment form code from the rest of the self check interface

This will facilitate the borrowing of the same code for re-use in the OPAC,
and potentially elsewhere.


Added: trunk/Open-ILS/web/js/ui/default/circ/selfcheck/payment.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/circ/selfcheck/payment.js	                        (rev 0)
+++ trunk/Open-ILS/web/js/ui/default/circ/selfcheck/payment.js	2010-05-24 16:04:42 UTC (rev 16486)
@@ -0,0 +1,115 @@
+var proto = (
+    (typeof(SelfCheckManager) == "undefined") ?
+        (function PaymentForm() {}) : SelfCheckManager
+).prototype;
+
+proto.drawPayFinesPage = function(patron, onPaymentSubmit) {
+    if (!this.finesTBody)
+        this.finesTBody = dojo.byId("oils-selfck-fines-tbody");
+
+    // find the total selected amount
+    var total = 0;
+    dojo.forEach(
+        dojo.query('[name=selector]', this.finesTbody),
+        function(input) {
+            if(input.checked)
+                total += Number(input.getAttribute('balance_owed'));
+        }
+    );
+    total = total.toFixed(2);
+
+    dojo.query("span", "oils-selfck-cc-payment-summary")[0].innerHTML = total;
+
+    oilsSelfckCCNumber.attr('value', '');
+    oilsSelfckCCMonth.attr('value', '01');
+    oilsSelfckCCYear.attr('value', new Date().getFullYear());
+    oilsSelfckCCFName.attr('value', patron.first_given_name());
+    oilsSelfckCCLName.attr('value', patron.family_name());
+    var addr = patron.billing_address() || patron.mailing_address();
+
+    if(addr) {
+        oilsSelfckCCStreet.attr('value', addr.street1()+' '+addr.street2());
+        oilsSelfckCCCity.attr('value', addr.city());
+        oilsSelfckCCState.attr('value', addr.state());
+        oilsSelfckCCZip.attr('value', addr.post_code());
+    }
+
+    dojo.connect(oilsSelfckEditDetails, 'onChange',
+        function(newVal) {
+            dojo.forEach(
+                [   oilsSelfckCCFName,
+                    oilsSelfckCCLName,
+                    oilsSelfckCCStreet,
+                    oilsSelfckCCCity,
+                    oilsSelfckCCState,
+                    oilsSelfckCCZip
+                ],
+                function(dij) { dij.attr('disabled', !newVal); }
+            );
+        }
+    );
+
+
+    var self = this;
+    dojo.connect(oilsSelfckCCSubmit, 'onClick',
+        function() {
+            progressDialog.show(true);
+            self.sendCCPayment(onPaymentSubmit);
+        }
+    );
+}
+
+// In this form, this code only supports global on/off credit card
+// payments and does not dissallow payments to transactions that started
+// at remote locations or transactions that have accumulated billings at
+// remote locations that dissalow credit card payments.
+// TODO add per-transaction blocks for orgs that do not support CC payments
+
+proto.sendCCPayment = function(onPaymentSubmit) {
+
+    var args = {
+        userid : this.patron.id(),
+        payment_type : 'credit_card_payment',
+        payments : [],
+        cc_args : {
+            where_process : 1,
+            number : oilsSelfckCCNumber.attr('value'),
+            expire_year : oilsSelfckCCYear.attr('value'),
+            expire_month : oilsSelfckCCMonth.attr('value'),
+            billing_first : oilsSelfckCCFName.attr('value'),
+            billing_last : oilsSelfckCCLName.attr('value'),
+            billing_address : oilsSelfckCCStreet.attr('value'),
+            billing_city : oilsSelfckCCCity.attr('value'),
+            billing_state : oilsSelfckCCState.attr('value'),
+            billing_zip : oilsSelfckCCZip.attr('value')
+        }
+    }
+
+
+    // find the selected transactions
+    dojo.forEach(
+        dojo.query('[name=selector]', this.finesTbody),
+        function(input) {
+            if(input.checked) {
+                args.payments.push([
+                    input.getAttribute('xact'),
+                    Number(input.getAttribute('balance_owed')).toFixed(2)
+                ]);
+            }
+        }
+    );
+
+
+    var resp = fieldmapper.standardRequest(
+        ['open-ils.circ', 'open-ils.circ.money.payment'],
+        {params : [this.authtoken, args]}
+    );
+
+    progressDialog.hide();
+
+    var evt = openils.Event.parse(resp);
+    if (evt)
+        alert(evt);
+    else if (typeof(onPaymentSubmit) == "function")
+        onPaymentSubmit();
+}

Modified: trunk/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js	2010-05-24 15:52:01 UTC (rev 16485)
+++ trunk/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js	2010-05-24 16:04:42 UTC (rev 16486)
@@ -100,7 +100,15 @@
     var linkHandlers = {
         'oils-selfck-hold-details-link' : function() { self.drawHoldsPage(); },
         'oils-selfck-view-fines-link' : function() { self.drawFinesPage(); },
-        'oils-selfck-pay-fines-link' : function() { self.drawPayFinesPage(); },
+        'oils-selfck-pay-fines-link' : function() {
+            self.goToTab("payment");
+            self.drawPayFinesPage(
+                self.patron, function() {
+                    self.updateFinesSummary();
+                    self.drawFinesPage();
+                }
+            );
+        },
         'oils-selfck-nav-home' : function() { self.drawCircPage(); },
         'oils-selfck-nav-logout' : function() { self.logoutPatron(); },
         'oils-selfck-nav-logout-print' : function() { self.logoutPatron(true); },
@@ -667,124 +675,6 @@
 }
 
 
-SelfCheckManager.prototype.drawPayFinesPage = function() {
-    this.goToTab('payment');
-
-    // find the total selected amount
-    var total = 0;
-    dojo.forEach(
-        dojo.query('[name=selector]', this.finesTbody),
-        function(input) {
-            if(input.checked)
-                total += Number(input.getAttribute('balance_owed'));
-        }
-    );
-    total = total.toFixed(2);
-
-    dojo.byId('oils-selfck-cc-payment-summary').innerHTML = 
-        dojo.string.substitute(
-            localeStrings.CC_PAYABLE_BALANCE,
-            [total]
-        );
-
-    oilsSelfckCCNumber.attr('value', '');
-    oilsSelfckCCMonth.attr('value', '01');
-    oilsSelfckCCYear.attr('value', new Date().getFullYear());
-    oilsSelfckCCFName.attr('value', this.patron.first_given_name());
-    oilsSelfckCCLName.attr('value', this.patron.family_name());
-    var addr = this.patron.billing_address() || this.patron.mailing_address();
-
-    if(addr) {
-        oilsSelfckCCStreet.attr('value', addr.street1()+' '+addr.street2());
-        oilsSelfckCCCity.attr('value', addr.city());
-        oilsSelfckCCState.attr('value', addr.state());
-        oilsSelfckCCZip.attr('value', addr.post_code());
-    }
-
-    dojo.connect(oilsSelfckEditDetails, 'onChange', 
-        function(newVal) {
-            dojo.forEach(
-                [   oilsSelfckCCFName, 
-                    oilsSelfckCCLName, 
-                    oilsSelfckCCStreet, 
-                    oilsSelfckCCCity, 
-                    oilsSelfckCCState, 
-                    oilsSelfckCCZip
-                ],
-                function(dij) { dij.attr('disabled', !newVal); }
-            );
-        }
-    );
-
-
-    var self = this;
-    dojo.connect(oilsSelfckCCSubmit, 'onClick',
-        function() {
-            progressDialog.show(true);
-            self.sendCCPayment();
-        }
-    );
-}
-
-
-// In this form, this code only supports global on/off credit card 
-// payments and does not dissallow payments to transactions that started
-// at remote locations or transactions that have accumulated billings at 
-// remote locations that dissalow credit card payments.
-// TODO add per-transaction blocks for orgs that do not support CC payments
-
-SelfCheckManager.prototype.sendCCPayment = function() {
-
-    var args = {
-        userid : this.patron.id(),
-        payment_type : 'credit_card_payment',
-        payments : [],
-        cc_args : {
-            where_process : 1,
-            number : oilsSelfckCCNumber.attr('value'),
-            expire_year : oilsSelfckCCYear.attr('value'),
-            expire_month : oilsSelfckCCMonth.attr('value'),
-            billing_first : oilsSelfckCCFName.attr('value'),
-            billing_last : oilsSelfckCCLName.attr('value'),
-            billing_address : oilsSelfckCCStreet.attr('value'),
-            billing_city : oilsSelfckCCCity.attr('value'),
-            billing_state : oilsSelfckCCState.attr('value'),
-            billing_zip : oilsSelfckCCZip.attr('value')
-        }
-    }
-
-
-    // find the selected transactions
-    dojo.forEach(
-        dojo.query('[name=selector]', this.finesTbody),
-        function(input) {
-            if(input.checked) {
-                args.payments.push([
-                    input.getAttribute('xact'),
-                    Number(input.getAttribute('balance_owed')).toFixed(2)
-                ]);
-            }
-        }
-    );
-
-
-    var resp = fieldmapper.standardRequest(
-        ['open-ils.circ', 'open-ils.circ.money.payment'],
-        {params : [this.authtoken, args]}
-    );
-
-    progressDialog.hide();
-
-    var evt = openils.Event.parse(resp);
-    if(evt) {
-        alert(evt);
-    } else {
-        this.updateFinesSummary();
-        this.drawFinesPage();
-    }
-}
-
-
 SelfCheckManager.prototype.drawFinesPage = function() {
 
     // TODO add option to hid scanBox

Modified: trunk/Open-ILS/web/templates/default/circ/selfcheck/main.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/circ/selfcheck/main.tt2	2010-05-24 15:52:01 UTC (rev 16485)
+++ trunk/Open-ILS/web/templates/default/circ/selfcheck/main.tt2	2010-05-24 16:04:42 UTC (rev 16486)
@@ -1,6 +1,7 @@
 [% ctx.page_title = 'Self Checkout' %]
 [% WRAPPER default/base.tt2 %]
 <script src='[% ctx.media_prefix %]/js/ui/default/circ/selfcheck/selfcheck.js'> </script>
+<script src="[% ctx.media_prefix %]/js/ui/default/circ/selfcheck/payment.js"></script>
 <link rel='stylesheet' type='text/css' href='[% ctx.media_prefix %]/css/skin/[% ctx.skin %]/selfcheck.css'></link>
 [% INCLUDE 'default/circ/selfcheck/audio_config.tt2' %]
 

Modified: trunk/Open-ILS/web/templates/default/circ/selfcheck/payment.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/circ/selfcheck/payment.tt2	2010-05-24 15:52:01 UTC (rev 16485)
+++ trunk/Open-ILS/web/templates/default/circ/selfcheck/payment.tt2	2010-05-24 16:04:42 UTC (rev 16486)
@@ -1,4 +1,6 @@
-<div id='oils-selfck-cc-payment-summary'> </div>
+<div id='oils-selfck-cc-payment-summary'>
+    Total amount to pay: $<span></span>
+</div>
 <table id='oils-selfck-cc-payment-table'>
     <tbody>
         <tr>



More information about the open-ils-commits mailing list