[open-ils-commits] r15309 - in trunk/Open-ILS: src/perlmods/OpenILS/Application src/perlmods/OpenILS/Application/Circ web/js/dojo/openils/booking/nls web/js/ui/default/booking xul/staff_client/server/patron (miker)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Jan 13 09:59:49 EST 2010


Author: miker
Date: 2010-01-13 09:59:47 -0500 (Wed, 13 Jan 2010)
New Revision: 15309

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Booking.pm
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm
   trunk/Open-ILS/web/js/dojo/openils/booking/nls/reservation.js
   trunk/Open-ILS/web/js/ui/default/booking/common.js
   trunk/Open-ILS/web/js/ui/default/booking/populator.js
   trunk/Open-ILS/web/js/ui/default/booking/pull_list.js
   trunk/Open-ILS/web/js/ui/default/booking/reservation.js
   trunk/Open-ILS/xul/staff_client/server/patron/display_horiz_overlay.xul
   trunk/Open-ILS/xul/staff_client/server/patron/display_overlay.xul
Log:
Patch from Lebbeous Fogle-Weekley providing final, cut-1 cleanup of booking

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Booking.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Booking.pm	2010-01-12 20:39:22 UTC (rev 15308)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Booking.pm	2010-01-13 14:59:47 UTC (rev 15309)
@@ -197,11 +197,8 @@
     return undef if scalar(@$brsrc_list) < 1; # Empty list not ok.
 
     my $e = new_editor(xact => 1, authtoken => $authtoken);
-    return $e->die_event unless (
-        $e->checkauth and
-        $e->allowed("ADMIN_BOOKING_RESERVATION") and
-        $e->allowed("ADMIN_BOOKING_RESERVATION_ATTR_MAP")
-    );
+    return $e->die_event unless $e->checkauth;
+    return $e->die_event unless $e->allowed("ADMIN_BOOKING_RESERVATION");
 
     my $usr = $U->fetch_user_by_barcode($target_user_barcode);
     return $usr if ref($usr) eq 'HASH' and exists($usr->{"ilsevent"});
@@ -572,8 +569,8 @@
 );
 
 
-sub naive_ts_string { strftime("%F %T", localtime(shift)); }
-sub naive_start_of_day { strftime("%F", localtime(shift)) . " 00:00:00"; }
+sub naive_ts_string {strftime("%F %T", localtime($_[0] || time));}
+sub naive_start_of_day {strftime("%F", localtime($_[0] || time))." 00:00:00";}
 
 # Return a list of bresv or an ilsevent on failure.
 sub get_uncaptured_bresv_for_brsrc {
@@ -891,6 +888,7 @@
         if (!$transit) { # not yet in transit
             $transit = new Fieldmapper::action::reservation_transit_copy;
 
+            $transit->reservation($reservation->id);
             $transit->target_copy($resource->id);
             $transit->copy_status(15);
             $transit->source_send_time('now');
@@ -1034,6 +1032,7 @@
                     "usr" => $patron->id,
                     "capture_time" => {"!=" => undef},
                     "pickup_time" => undef,
+                    "start_time" => {">=" => naive_start_of_day()},
                     "cancel_time" => undef
                 },
                 $bresv_flesh

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm	2010-01-12 20:39:22 UTC (rev 15308)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm	2010-01-13 14:59:47 UTC (rev 15309)
@@ -182,7 +182,7 @@
     # barcode, but a resource barcode, and nothing else in here will work
     # --------------------------------------------------------------------------
 
-    if (my $bc = $circulator->copy_barcode) { # do we have a barcode?
+    if ((my $bc = $circulator->copy_barcode) && $api !~ /checkout|inspect/) { # do we have a barcode?
         my $resources = $circulator->editor->search_booking_resource( { barcode => $bc } ); # any resources by this barcode?
         if (@$resources) { # yes!
 
@@ -200,9 +200,9 @@
                 my $res_type = $circulator->editor->retrieve_booking_resource_type( $reservation->target_resource_type );
 
                 if ($U->is_true($res_type->catalog_item)) { # is there a copy to be had here?
-                    if (my $copy = circulator->editor->search_asset_copy({ barcode => $bc, deleted => 'f' })->[0]) { # got a copy
+                    if (my $copy = $circulator->editor->search_asset_copy({ barcode => $bc, deleted => 'f' })->[0]) { # got a copy
                         $copy->status( $transit->copy_status );
-                        $copy->editor($self->editor->requestor->id);
+                        $copy->editor($circulator->editor->requestor->id);
                         $copy->edit_date('now');
                         $circulator->editor->update_asset_copy( $copy );
                     }
@@ -281,7 +281,7 @@
         $circulator->circ_permit_copy($scripts{circ_permit_copy});      
         $circulator->circ_duration($scripts{circ_duration});             
         $circulator->circ_permit_renew($scripts{circ_permit_renew});
-    } else {
+    } elsif (not $circulator->is_res_checkin) { # mk_env cannot work w/ reservation.return
         $circulator->mk_env();
     }
     return circ_events($circulator) if $circulator->bail_out;
@@ -1823,8 +1823,8 @@
 
         my $booking_ses = OpenSRF::AppSession->create( 'open-ils.booking' );
         my $bookings = $booking_ses->request(
-            'open-ils.booking.reservations.filtered_id_list',
-            { resource => $booking_item->id, start_time => 'now', end_time => $circ->due_date }
+            'open-ils.booking.reservations.filtered_id_list', $self->editor->authtoken,
+            { resource => $booking_item->id, search_start => 'now', search_end => $circ->due_date }
         )->gather(1);
         $booking_ses->disconnect;
         
@@ -1849,6 +1849,14 @@
                 $self->bail_on_events( OpenILS::Event->new('COPY_RESERVED') ) if ($due_date < DateTime->now); 
             }
             
+            # We set the circ duration here only to affect the logic that will
+            # later (in a DB trigger) mangle the time part of the due date to
+            # 11:59pm. Having any circ duration that is not a whole number of
+            # days is enough to prevent the "correction."
+            my $new_circ_duration = $due_date->epoch - time;
+            $new_circ_duration++ if $new_circ_duration % 86400 == 0;
+            $circ->duration("$new_circ_duration seconds");
+
             $circ->due_date(clense_ISO8601($due_date->strftime('%FT%T%z')));
             $changed = 1;
         }

Modified: trunk/Open-ILS/web/js/dojo/openils/booking/nls/reservation.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/booking/nls/reservation.js	2010-01-12 20:39:22 UTC (rev 15308)
+++ trunk/Open-ILS/web/js/dojo/openils/booking/nls/reservation.js	2010-01-13 14:59:47 UTC (rev 15309)
@@ -48,6 +48,10 @@
         "You must choose a valid start and end time for the reservation.",
     'BRSRC_NOT_FOUND': "Could not locate that resource.",
     'BRSRC_RETRIVE_ERROR': "Error retrieving resource: ",
+    'ON_FLY_NO_RESPONSE':
+        "No response from server attempting to make item a bookable resource.",
+    'ON_FLY_ERROR':
+        "Error attempting to make item a bookable resource:",
     'ANY': "ANY",
 
     'AUTO_choose_a_brt': "Choose a Bookable Resource Type",

Modified: trunk/Open-ILS/web/js/ui/default/booking/common.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/booking/common.js	2010-01-12 20:39:22 UTC (rev 15308)
+++ trunk/Open-ILS/web/js/ui/default/booking/common.js	2010-01-13 14:59:47 UTC (rev 15309)
@@ -48,7 +48,7 @@
     var timeparts = parts[1].split("-")[0].split(":");
     return parts[0] + " " + timeparts[0] + ":" + timeparts[1];
 }
-function is_ils_error(e) { return (e.ilsevent != undefined); }
+function is_ils_event(e) { return (e.ilsevent != undefined); }
 function is_ils_actor_card_error(e) {
     return (e.textcode == "ACTOR_CARD_NOT_FOUND");
 }

Modified: trunk/Open-ILS/web/js/ui/default/booking/populator.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/booking/populator.js	2010-01-12 20:39:22 UTC (rev 15308)
+++ trunk/Open-ILS/web/js/ui/default/booking/populator.js	2010-01-13 14:59:47 UTC (rev 15309)
@@ -139,12 +139,17 @@
         "open-ils.booking.reservations.by_returnable_resource_barcode"],
         [xulG.auth.session.key, barcode]
     );
-    if (!r) {
+    if (!r || r.length < 1) {
         alert(localeStrings.NO_SUCH_RETURNABLE_RESOURCE);
-    } else if (is_ils_error(r)) {
+    } else if (is_ils_event(r)) {
         alert(my_ils_error(localeStrings.RETURNABLE_RESOURCE_ERROR, r));
     } else {
-        var new_barcode = r.usr().card().barcode();
+        try {
+            var new_barcode = r.usr().card().barcode();
+        } catch (E) {
+            alert(localeStrings.RETURN_ERROR + "\nr: " + js2JSON(r) + "\n" + E);
+            return;
+        }
         if (this.patron_barcode && this.patron_barcode != new_barcode) {
             /* XXX make this more subtle, i.e. flash something in background */
             alert(localeStrings.NOTICE_CHANGE_OF_PATRON);
@@ -153,7 +158,7 @@
         var ret = this.return(r);
         if (!ret) {
             alert(localeStrings.RETURN_NO_RESPONSE);
-        } else if (is_ils_error(ret)) {
+        } else if (is_ils_event(ret) && ret.textcode != "SUCCESS") {
             alert(my_ils_error(localeStrings.RETURN_ERROR, ret));
         } else {
             /* XXX speedbump should go, but something has to happen else
@@ -190,7 +195,7 @@
     if (!result) {
         this.patron_barcode = undefined;
         alert(localeStrings.RESERVATIONS_NO_RESPONSE);
-    } else if (is_ils_error(result)) {
+    } else if (is_ils_event(result)) {
         this.patron_barcode = undefined;
         alert(my_ils_error(localeStrings.RESERVATIONS_ERROR, result));
     } else {
@@ -252,7 +257,7 @@
         var result = this[how](reservations[i]);
         if (!result) {
             alert(no_response_msg);
-        } else if (is_ils_error(result)) {
+        } else if (is_ils_event(result) && result.textcode != "SUCCESS") {
             alert(my_ils_error(error_msg, result));
         } else {
             continue;

Modified: trunk/Open-ILS/web/js/ui/default/booking/pull_list.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/booking/pull_list.js	2010-01-12 20:39:22 UTC (rev 15308)
+++ trunk/Open-ILS/web/js/ui/default/booking/pull_list.js	2010-01-13 14:59:47 UTC (rev 15309)
@@ -113,7 +113,7 @@
         if (!results) {
             alert(localeStrings.COPY_LOOKUP_NO_RESPONSE);
             return null;
-        } else if (is_ils_error(results)) {
+        } else if (is_ils_event(results)) {
             alert(my_ils_error(localeStrings.COPY_LOOKUP_ERROR, results));
             return null;
         } else {
@@ -170,7 +170,7 @@
     if (results == null) {
         alert(localeStrings.PULL_LIST_NO_RESPONSE);
         return;
-    } else if (is_ils_error(results)) {
+    } else if (is_ils_event(results)) {
         alert(my_ils_error(localeStrings.PULL_LIST_ERROR, results));
         return;
     }

Modified: trunk/Open-ILS/web/js/ui/default/booking/reservation.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/booking/reservation.js	2010-01-12 20:39:22 UTC (rev 15308)
+++ trunk/Open-ILS/web/js/ui/default/booking/reservation.js	2010-01-13 14:59:47 UTC (rev 15309)
@@ -299,7 +299,7 @@
         alert(localeStrings.CREATE_BRESV_LOCAL_ERROR + E);
     }
     if (results) {
-        if (is_ils_error(results)) {
+        if (is_ils_event(results)) {
             if (is_ils_actor_card_error(results)) {
                 alert(localeStrings.ACTOR_CARD_NOT_FOUND);
             } else {
@@ -373,7 +373,7 @@
     );
     if (usr == null) {
         alert(localeStrings.GET_PATRON_NO_RESULT);
-    } else if (is_ils_error(usr)) {
+    } else if (is_ils_event(usr)) {
         return null; /* XXX inelegant: this function is quiet about errors
                         here because to report them would be redundant with
                         another function that gets called right after this one.
@@ -400,7 +400,7 @@
     if (result == null) {
         set_datagrid_empty_store(bresvGrid, flatten_to_dojo_data);
         alert(localeStrings.GET_BRESV_LIST_NO_RESULT);
-    } else if (is_ils_error(result)) {
+    } else if (is_ils_event(result)) {
         set_datagrid_empty_store(bresvGrid, flatten_to_dojo_data);
         if (is_ils_actor_card_error(result)) {
             alert(localeStrings.ACTOR_CARD_NOT_FOUND);
@@ -433,14 +433,19 @@
 }
 
 function cancel_reservations(bresv_id_list) {
-    var result = fieldmapper.standardRequest(
-        ["open-ils.booking", "open-ils.booking.reservations.cancel"],
-        [xulG.auth.session.key, bresv_id_list]
-    );
+    try {
+        var result = fieldmapper.standardRequest(
+            ["open-ils.booking", "open-ils.booking.reservations.cancel"],
+            [xulG.auth.session.key, bresv_id_list]
+        );
+    } catch (E) {
+        alert(localeStrings.CXL_BRESV_FAILURE2 + E);
+        return;
+    }
     setTimeout(update_bresv_grid, 0);
     if (!result) {
         alert(localeStrings.CXL_BRESV_FAILURE);
-    } else if (is_ils_error(result)) {
+    } else if (is_ils_event(result)) {
         alert(my_ils_error(localeStrings.CXL_BRESV_FAILURE2, result));
     } else {
         alert(localeStrings.CXL_BRESV_SUCCESS(result.length));
@@ -449,16 +454,28 @@
 
 function munge_specific_resource(barcode) {
     try {
-        var brsrc_list = pcrud.search('brsrc', {'barcode': barcode});
-        if (brsrc_list && brsrc_list.length > 0) {
-            opts.booking_results = {
-                "brt": [[brsrc_list[0].type(), 0, 1]],
-                "brsrc": [[brsrc_list[0].id(), 0, 1]],
-            };
-            if (!(our_brt = get_brt_by_id(opts.booking_results.brt[0][0]))) {
-                alert(localeStrings.COULD_NOT_RETRIEVE_BRT_PASSED_IN);
+        var copy_list = pcrud.search(
+            "acp", {"barcode": barcode, "deleted": "f"}
+        );
+        if (copy_list && copy_list.length > 0) {
+            var r = fieldmapper.standardRequest(
+                ["open-ils.booking",
+                    "open-ils.booking.resources.create_from_copies"],
+                [xulG.auth.session.key,
+                    copy_list.map(function(o) { return o.id(); })]
+            );
+
+            if (!r) {
+                alert(localeStrings.ON_FLY_NO_RESPONSE);
+            } else if (is_ils_event(r)) {
+                alert(my_ils_error(localeStrings.ON_FLY_ERROR, r));
             } else {
-                init_reservation_interface();
+                if (!(our_brt = get_brt_by_id(r.brt[0][0]))) {
+                    alert(localeStrings.COULD_NOT_RETRIEVE_BRT_PASSED_IN);
+                } else {
+                    opts.booking_results = r;
+                    init_reservation_interface();
+                }
             }
         } else {
             alert(localeStrings.BRSRC_NOT_FOUND);
@@ -692,7 +709,9 @@
 }
 
 function cancel_selected_bresv(bresv_dojo_items) {
-    if (bresv_dojo_items && bresv_dojo_items.length > 0) {
+    if (bresv_dojo_items && bresv_dojo_items.length > 0 &&
+        (bresv_dojo_items[0].length == undefined ||
+            bresv_dojo_items[0].length > 0)) {
         cancel_reservations(
             bresv_dojo_items.map(function(o) { return o.id[0]; })
         );

Modified: trunk/Open-ILS/xul/staff_client/server/patron/display_horiz_overlay.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/patron/display_horiz_overlay.xul	2010-01-12 20:39:22 UTC (rev 15308)
+++ trunk/Open-ILS/xul/staff_client/server/patron/display_horiz_overlay.xul	2010-01-13 14:59:47 UTC (rev 15309)
@@ -92,9 +92,13 @@
                                     <menuitem label="&staff.patron.info.notes.label;" accesskey="&staff.patron.info.notes.accesskey;" command="cmd_patron_info_notes"/>
                                     <menuitem label="&staff.patron.info.triggered_events.label;" accesskey="&staff.patron.info.triggered_events.accesskey;" command="cmd_patron_info_triggered_events"/>
                                     <menuitem label="&staff.patron.info.stat_cats.label;" accesskey="&staff.patron.info.stat_cats.accesskey;" command="cmd_patron_info_stats"/>
-                                    <menuitem label="&staff.main.menu.booking.reservation.label;" accesskey="&staff.main.menu.booking.reservation.accesskey;" command="cmd_patron_reservation" />
-                                    <menuitem label="&staff.main.menu.booking.reservation_pickup.label;" accesskey="&staff.main.menu.booking.reservation_pickup.accesskey;" command="cmd_patron_reservation_pickup" />
-                                    <menuitem label="&staff.main.menu.booking.reservation_return.label;" accesskey="&staff.main.menu.booking.reservation_return.accesskey;" command="cmd_patron_reservation_return" />
+                                    <menu id="PatronNavBar_other_booking" label="&staff.main.menu.booking.label;" accesskey="&staff.main.menu.booking.accesskey;">
+                                        <menupopup id="PatronNavBar_other_booking_popup">
+                                            <menuitem label="&staff.main.menu.booking.reservation.label;" accesskey="&staff.main.menu.booking.reservation.accesskey;" command="cmd_patron_reservation" />
+                                            <menuitem label="&staff.main.menu.booking.reservation_pickup.label;" accesskey="&staff.main.menu.booking.reservation_pickup.accesskey;" command="cmd_patron_reservation_pickup" />
+                                            <menuitem label="&staff.main.menu.booking.reservation_return.label;" accesskey="&staff.main.menu.booking.reservation_return.accesskey;" command="cmd_patron_reservation_return" />
+                                        </menupopup>
+                                    </menu>
                                     <menuitem label="&staff.patron.info.surveys.label;" accesskey="&staff.patron.info.surveys.accesskey;" command="cmd_patron_info_surveys"/>
                                     <menuitem label="&staff.patron.info.group.label;" accesskey="&staff.patron.info.group.accesskey;" command="cmd_patron_info_groups"/>
                                     <menuitem label="&staff.patron_display.verify_password.label;" accesskey="&staff.patron_display.verify_password.accesskey;" command="cmd_verify_credentials"/>

Modified: trunk/Open-ILS/xul/staff_client/server/patron/display_overlay.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/patron/display_overlay.xul	2010-01-12 20:39:22 UTC (rev 15308)
+++ trunk/Open-ILS/xul/staff_client/server/patron/display_overlay.xul	2010-01-13 14:59:47 UTC (rev 15309)
@@ -92,9 +92,13 @@
                                     <menuitem label="&staff.patron.info.notes.label;" accesskey="&staff.patron.info.notes.accesskey;" command="cmd_patron_info_notes"/>
                                     <menuitem label="&staff.patron.info.triggered_events.label;" accesskey="&staff.patron.info.triggered_events.accesskey;" command="cmd_patron_info_triggered_events"/>
                                     <menuitem label="&staff.patron.info.stat_cats.label;" accesskey="&staff.patron.info.stat_cats.accesskey;" command="cmd_patron_info_stats"/>
-                                    <menuitem label="&staff.main.menu.booking.reservation.label;" accesskey="&staff.main.menu.booking.reservation.accesskey;" command="cmd_patron_reservation" />
-                                    <menuitem label="&staff.main.menu.booking.reservation_pickup.label;" accesskey="&staff.main.menu.booking.reservation_pickup.accesskey;" command="cmd_patron_reservation_pickup" />
-                                    <menuitem label="&staff.main.menu.booking.reservation_return.label;" accesskey="&staff.main.menu.booking.reservation_return.accesskey;" command="cmd_patron_reservation_return" />
+                                    <menu id="PatronNavBar_other_booking" label="&staff.main.menu.booking.label;" accesskey="&staff.main.menu.booking.accesskey;">
+                                        <menupopup id="PatronNavBar_other_booking_popup">
+                                            <menuitem label="&staff.main.menu.booking.reservation.label;" accesskey="&staff.main.menu.booking.reservation.accesskey;" command="cmd_patron_reservation" />
+                                            <menuitem label="&staff.main.menu.booking.reservation_pickup.label;" accesskey="&staff.main.menu.booking.reservation_pickup.accesskey;" command="cmd_patron_reservation_pickup" />
+                                            <menuitem label="&staff.main.menu.booking.reservation_return.label;" accesskey="&staff.main.menu.booking.reservation_return.accesskey;" command="cmd_patron_reservation_return" />
+                                        </menupopup>
+                                    </menu>
                                     <menuitem label="&staff.patron.info.surveys.label;" accesskey="&staff.patron.info.surveys.accesskey;" command="cmd_patron_info_surveys"/>
                                     <menuitem label="&staff.patron.info.group.label;" accesskey="&staff.patron.info.group.accesskey;" command="cmd_patron_info_groups"/>
                                     <menuitem label="&staff.patron_display.verify_password.label;" accesskey="&staff.patron_display.verify_password.accesskey;" command="cmd_verify_credentials"/>



More information about the open-ils-commits mailing list