broke the fines display into various parts. more work to come
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 13 Feb 2006 21:39:29 +0000 (21:39 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 13 Feb 2006 21:39:29 +0000 (21:39 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@3049 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/opac/common/js/config.js
Open-ILS/web/opac/skin/default/js/myopac.js
Open-ILS/web/opac/skin/default/xml/myopac/myopac_fines.xml

index efd342f..aaf052e 100644 (file)
@@ -217,6 +217,7 @@ var FETCH_CHECKED_OUT_SLIM          = "open-ils.circ:open-ils.circ.actor.user.checked_ou
 var FETCH_HOLDS                                        = "open-ils.circ:open-ils.circ.holds.retrieve";
 var FETCH_FINES_SUMMARY                        = "open-ils.actor:open-ils.actor.user.fines.summary";
 var FETCH_TRANSACTIONS                 = "open-ils.actor:open-ils.actor.user.transactions.have_charge.fleshed";
+var FETCH_MONEY_BILLING                        = 'open-ils.circ:open-ils.circ.money.billing.retrieve.all';
 var FETCH_CROSSREF                             = "open-ils.search:open-ils.search.authority.crossref";
 var FETCH_CROSSREF_BATCH               = "open-ils.search:open-ils.search.authority.crossref.batch";
 var CREATE_HOLD                                        = "open-ils.circ:open-ils.circ.holds.create";
@@ -246,6 +247,7 @@ var DELETE_CONTAINER_ITEM           = 'open-ils.actor:open-ils.actor.container.item.delet
 var FLESH_CONTAINER                            = 'open-ils.actor:open-ils.actor.container.flesh';
 var FLESH_PUBLIC_CONTAINER             = 'open-ils.actor:open-ils.actor.container.public.flesh';
 var FETCH_COPY                                         = 'open-ils.search:open-ils.search.asset.copy.retrieve';
+var CHECK_HOLD_POSSIBLE                        = 'open-ils.circ:open-ils.circ.title_hold.is_possible';
 /* ---------------------------------------------------------------------------- */
 
 
index 2c06a28..b547712 100644 (file)
@@ -359,54 +359,105 @@ function _finesFormatNumber(num) {
        return num;
 }          
 
+function _trimTime(time) { if(!time) return ""; return time.replace(/\ .*/,""); }
+
 function _trimSeconds(time) { if(!time) return ""; return time.replace(/\..*/,""); }
 
 
-var transTemplate;
 function myOPACShowTransactions(r) {
 
-       if(transTemplate) return;
-       var tbody = $('myopac_fines_tbody');
-       unHideMe($('myopac_trans_table'));
-       transTemplate = tbody.removeChild($('myopac_trans_row'));
+       if(myopacGenericTransTemplate || myopacCircTransTemplate) return;
 
        var transactions = r.getResultObject();
 
-       //alert(js2JSON(transactions));
-
        for( var idx in transactions ) {
 
-               var trans = transactions[idx].transaction;
-               var record = transactions[idx].record;
-               var row = transTemplate.cloneNode(transTemplate);
-
-               $n(row,'myopac_trans_start').
-                       appendChild(text(_trimSeconds(trans.xact_start())));
-               $n(row,'myopac_trans_last_bill').
-                       appendChild(text(_trimSeconds(trans.last_billing_ts())));
-               $n(row,'myopac_trans_last_payment').
-                       appendChild(text(_trimSeconds(trans.last_payment_ts())));
-               $n(row,'myopac_trans_init_amount').
-                       appendChild(text(_finesFormatNumber(trans.total_owed())));
-               $n(row,'myopac_trans_total_paid').
-                       appendChild(text(_finesFormatNumber(trans.total_paid())));
-               $n(row,'myopac_trans_balance').
-                       appendChild(text(_finesFormatNumber(trans.balance_owed())));
-
-               var extra = "";
-               var type = trans.xact_type();
-               if(type == 'circulation') {
-                       unHideMe($('accrue_explanation'));
-                       unHideMe($n(row, 'myopac_trans_balance_recur'));
-               }
-               $n(row,'myopac_trans_type').appendChild(text(type));
-               if( type == "circulation" ) extra = record.title();
-               $n(row, 'myopac_trans_extra').appendChild(text(extra));
+               var trans       = transactions[idx].transaction;
+               var record      = transactions[idx].record;
+               var circ                = transactions[idx].circ;
 
-               tbody.appendChild(row);
+               if(trans.xact_type() == 'circulation') 
+                       myOPACShowCircTransaction(trans, record, circ);
+
+               else if(trans.xact_type() == 'grocery' ) 
+                       myopacShowGenericTransaction( trans );
        }
 }
 
+var myopacGenericTransTemplate;
+function myopacShowGenericTransaction( trans ) {
+       var tbody = $('myopac_trans_tbody');
+
+       if(!myopacGenericTransTemplate) {
+               myopacGenericTransTemplate = 
+                       tbody.removeChild($('myopac_trans_row'));
+               removeChildren(tbody);
+       }
+
+       var row = myopacGenericTransTemplate.cloneNode(true);
+
+       $n(row,'myopac_trans_start').appendChild(
+                       text(_trimSeconds(trans.xact_start())));
+
+       $n(row,'myopac_trans_last_payment').appendChild(
+                       text(_trimSeconds(trans.last_payment_ts())));
+
+       $n(row,'myopac_trans_init_amount').appendChild(
+                       text(_finesFormatNumber(trans.total_owed())));
+
+       $n(row,'myopac_trans_total_paid').appendChild(
+                       text(_finesFormatNumber(trans.total_paid())));
+
+       $n(row,'myopac_trans_balance').appendChild(
+                       text(_finesFormatNumber(trans.balance_owed())));
+
+       var req = new Request(FETCH_MONEY_BILLING, G.user.session, trans.id());
+       req.send(true);
+       var bills = req.result();
+       if(bills && bills[0])
+               $n(row,'myopac_trans_bill_type').appendChild(
+                               text(bills[0].billing_type()));
+
+       tbody.appendChild(row);
+       unHideMe($('myopac_trans_table'));
+}
+
+
+
+/* draws a circulation transaction summary */
+var myopacCircTransTemplate;
+function myOPACShowCircTransaction(trans, record, circ) {
+       var tbody = $('myopac_circ_trans_tbody');
+
+       if(!myopacCircTransTemplate) {
+               myopacCircTransTemplate = tbody.removeChild($('myopac_circ_trans_row'));
+               removeChildren(tbody);
+       }
+
+       var row = myopacCircTransTemplate.cloneNode(true);
+
+       buildTitleDetailLink(record, $n(row,'myopac_circ_trans_title'));
+
+       $n(row,'myopac_circ_trans_author').appendChild(text(
+               normalize(truncate(record.author(), 65))));
+
+       $n(row,'myopac_circ_trans_start').
+               appendChild(text(_trimTime(trans.xact_start())));
+
+   var due = _trimTime(circ.due_date());
+       var checkin = _trimTime(circ.stop_fines_time());
+
+       $n(row,'myopac_circ_trans_due').appendChild(text(due))
+       $n(row,'myopac_circ_trans_finished').appendChild(text(checkin))
+
+       $n(row,'myopac_circ_trans_balance').
+               appendChild(text(_finesFormatNumber(trans.balance_owed())));
+
+       tbody.appendChild(row);
+       unHideMe($('myopac_circ_trans_table'));
+}
+
+
 function myOPACSavePrefs() {
        G.user.prefs[PREF_HITS_PER] = getSelectorVal($('prefs_hits_per'));
        if(commitUserPrefs())
index c2fefc4..c4ff900 100644 (file)
@@ -5,7 +5,7 @@
        <table width='100%' class='data_grid data_grid_center'>
 
                <thead class='color_3'>
-                       <tr><td colspan='3' style='background: none'><b>Summary</b></td></tr>
+                       <tr><td colspan='3' style='padding: 6px'><b>Summary</b></td></tr>
                        <tr>
                                <td width='33%'>Total Owed</td>
                                <td width='33%'>Total Paid</td>
 
                <tbody id='myopac_fines_summary_tbody'>
                        <tr id='myopac_fines_summary_loading'><td>Loading...</td></tr>
-                       <tr id='myopac_fines_summary_row' class='light_border hide_me'>
-                               <td id='myopac_fines_summary_total' class='light_border'>$</td>
-                               <td id='myopac_fines_summary_paid' class='light_border'>$</td>
-                               <td id='myopac_fines_summary_balance' class='light_border' style='color:red;font-weight: bold;'>$</td>
+                       <tr id='myopac_fines_summary_row' class='hide_me'>
+                               <td id='myopac_fines_summary_total' >$</td>
+                               <td id='myopac_fines_summary_paid' >$</td>
+                               <td id='myopac_fines_summary_balance' style='color:red;font-weight: bold;'>$</td>
                        </tr>
                </tbody>
        </table>
 
-       <br/>
-       <br/>
-       <br/>
-
+       <!--
        <div id='accrue_explanation' class='hide_me'>
                <span>Transactions whose balances are marked with a</span>
                <span style='color:red; font-weight: bold'>*</span>
                <span>will continue to accrue fines until the checked out item is returned.</span>
        </div>
-
-       <br/>
-       <!--
-       <table width='100%' class='light_border myopac_table hide_me' id='myopac_trans_table'>
        -->
-       <table width='100%' class='data_grid data_grid_center hide_me' id='myopac_trans_table'>
 
+       <br/><br/><hr/><br/>
+
+       <!-- Table for circulation transactions only -->
+       <table width='100%' class='data_grid data_grid_center hide_me' id='myopac_circ_trans_table'>
+               <thead>
+                       <tr><td colspan='10' style='padding: 6px'><b>Overdue Materials</b></td></tr>
+                       <tr>
+                               <td>Title</td>
+                               <td>Author</td>
+                               <td>Checkout Date</td>
+                               <td>Due Date</td>
+                               <td>Date Returned</td>
+                               <td>Balance Owed</td>
+                       </tr>
+               </thead>
+               <tbody id='myopac_circ_trans_tbody'>
+                       <tr id='myopac_circ_trans_row'>
+                               <td><a class='classic_link' name='myopac_circ_trans_title'> </a></td>
+                               <td name='myopac_circ_trans_author'> </td>
+                               <td name='myopac_circ_trans_start'> </td>
+                               <td name='myopac_circ_trans_due'> </td>
+                               <td name='myopac_circ_trans_finished'> </td>
+                               <td>
+                                       <span style='color: red; font-weight: bold;' 
+                                               name='myopac_circ_trans_balance'>$</span>
+                               </td>
+                       </tr>
+               </tbody>
+       </table>
+
+       <br/><br/><hr/><br/>
+
+       <!-- Table for all non-circulation transactions -->
+       <table width='100%' class='data_grid data_grid_center hide_me' id='myopac_trans_table'>
                <thead>
-                       <tr><td colspan='8' style='background: none'><b>Transaction Details</b></td></tr>
+                       <tr><td colspan='8' style='padding: 6px'><b>Other Transactions</b></td></tr>
                        <tr>
                                <td width='12%'>Transaction Start Time</td>
-                               <td width='12%'>Last Billing Time</td>
                                <td width='12%'>Last Payment Time</td>
                                <td width='12%'>Initial Amount Owed</td>
                                <td width='12%'>Total Amount Paid</td>
                                <td width='12%'>Balance Owed</td>
-                               <td width='12%'>Type</td>
-                               <td width='12%'>Extra Info</td>
+                               <td width='12%'>Billing Type</td>
                        </tr>
                </thead>
 
-               <tbody id='myopac_fines_tbody'>
+               <tbody id='myopac_trans_tbody'>
                        <tr id='myopac_trans_row'>
                                <td name='myopac_trans_start'> </td>
-                               <td name='myopac_trans_last_bill'> </td>
                                <td name='myopac_trans_last_payment'> </td>
                                <td name='myopac_trans_init_amount'>$</td>
                                <td name='myopac_trans_total_paid'>$</td>
@@ -64,8 +87,7 @@
                                        <span name='myopac_trans_balance_recur' class='hide_me'> * </span>
                                        <span name='myopac_trans_balance'>$</span>
                                </td>
-                               <td name='myopac_trans_type'> </td>
-                               <td name='myopac_trans_extra'> </td>
+                               <td name='myopac_trans_bill_type'> </td>
                        </tr>
                </tbody>
        </table>