display more info from sip2 partron info
[Biblio-RFID.git] / examples / selfcheck.js
index e1917c2..9436d79 100644 (file)
@@ -48,12 +48,14 @@ function change_page(new_state) {
                        circulation_type = 'checkout';
                        book_barcodes = {};
                        $('ul#books').html(''); // clear book list
+                       $('#books_count').html( 0 );
                        scan_tags();
                }
 
                if ( state == 'end' ) {
                        window.setTimeout(function(){
-                               change_page('start');
+                               //change_page('start');
+                               location.reload(); // force js VM to GC?
                        },end_timeout);
                }
 
@@ -155,23 +157,20 @@ function start( cardnumber ) {
                return;
        }
 
-       borrower_cardnumber = cardnumber;
-
-       change_page('borrower_check');
-}
-
-function borrower_check() {
+       borrower_cardnumber = cardnumber; // for circulation
 
-       fill_in( 'borrower_number', borrower_cardnumber );
+       fill_in( 'borrower_number', cardnumber );
 
        pending_jsonp++;
-       $.getJSON('/sip2/patron_info/'+borrower_cardnumber)
+       $.getJSON('/sip2/patron_info/'+cardnumber)
        .done( function( data ) {
                console.info('patron', data);
                fill_in( 'borrower_name', data['AE'] );
                fill_in( 'borrower_email', data['BE'] );
                fill_in( 'hold_items',    data['fixed'].substr( 2 + 14 + 3 + 18 + ( 0 * 4 ), 4 ) ) * 1;
                fill_in( 'overdue_items', data['fixed'].substr( 2 + 14 + 3 + 18 + ( 1 * 4 ), 4 ) ) * 1;
+               fill_in( 'charged_items', data['fixed'].substr( 2 + 14 + 3 + 18 + ( 2 * 4 ), 4 ) ) * 1;
+               fill_in( 'fine_items',    data['fixed'].substr( 2 + 14 + 3 + 18 + ( 3 * 4 ), 4 ) ) * 1;
                pending_jsonp--;
                change_page('borrower_info');
        }).fail( function(data) {
@@ -195,6 +194,7 @@ function circulation( barcode, sid ) {
                $.getJSON('/sip2/'+circulation_type+'/'+borrower_cardnumber+'/'+barcode+'/'+sid , function( data ) {
                        console.info( circulation_type, data );
                        $('ul#books').append('<li>' + ( data['AJ'] || barcode ) + ( data['AF'] ? ' <b>' + data['AF'] + '</b>' : '' ) + '</li>');
+                       $('#books_count').html( $('ul#books > li').length );
                        console.debug( book_barcodes );
                        pending_jsonp--;
                }).fail( function() {