From ae1071554983fa0c852d89fc5b71a2f4a5294ed5 Mon Sep 17 00:00:00 2001 From: miker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4> Date: Wed, 13 Jan 2010 14:59:47 +0000 Subject: [PATCH] Patch from Lebbeous Fogle-Weekley providing final, cut-1 cleanup of booking git-svn-id: svn://svn.open-ils.org/ILS/trunk@15309 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../src/perlmods/OpenILS/Application/Booking.pm | 13 +++-- .../perlmods/OpenILS/Application/Circ/Circulate.pm | 20 +++++--- .../web/js/dojo/openils/booking/nls/reservation.js | 4 ++ Open-ILS/web/js/ui/default/booking/common.js | 2 +- Open-ILS/web/js/ui/default/booking/populator.js | 17 ++++--- Open-ILS/web/js/ui/default/booking/pull_list.js | 4 +- Open-ILS/web/js/ui/default/booking/reservation.js | 55 +++++++++++++++------- .../server/patron/display_horiz_overlay.xul | 10 ++-- .../staff_client/server/patron/display_overlay.xul | 10 ++-- 9 files changed, 89 insertions(+), 46 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Booking.pm b/Open-ILS/src/perlmods/OpenILS/Application/Booking.pm index dddd7eb6bb..142fb23f10 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Booking.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Booking.pm @@ -197,11 +197,8 @@ sub create_bresv { 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 @@ NOTES ); -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 @@ sub capture_reservation { 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 @@ sub get_captured_reservations { "usr" => $patron->id, "capture_time" => {"!=" => undef}, "pickup_time" => undef, + "start_time" => {">=" => naive_start_of_day()}, "cancel_time" => undef }, $bresv_flesh diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm index 939cf0fdf6..bf7a14c5e8 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm @@ -182,7 +182,7 @@ sub run_method { # 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 @@ sub run_method { 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 @@ sub run_method { $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 @@ sub booking_adjusted_due_date { 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 @@ sub booking_adjusted_due_date { $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; } diff --git a/Open-ILS/web/js/dojo/openils/booking/nls/reservation.js b/Open-ILS/web/js/dojo/openils/booking/nls/reservation.js index 2f1402ba15..76cf080732 100644 --- a/Open-ILS/web/js/dojo/openils/booking/nls/reservation.js +++ b/Open-ILS/web/js/dojo/openils/booking/nls/reservation.js @@ -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", diff --git a/Open-ILS/web/js/ui/default/booking/common.js b/Open-ILS/web/js/ui/default/booking/common.js index 7f46073cbf..cc6f302255 100644 --- a/Open-ILS/web/js/ui/default/booking/common.js +++ b/Open-ILS/web/js/ui/default/booking/common.js @@ -48,7 +48,7 @@ function humanize_timestamp_string(ts) { 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"); } diff --git a/Open-ILS/web/js/ui/default/booking/populator.js b/Open-ILS/web/js/ui/default/booking/populator.js index 7dd6df13cf..dc0d757d16 100644 --- a/Open-ILS/web/js/ui/default/booking/populator.js +++ b/Open-ILS/web/js/ui/default/booking/populator.js @@ -139,12 +139,17 @@ Populator.prototype.return_by_resource = function(barcode) { "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 @@ Populator.prototype.return_by_resource = function(barcode) { 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 @@ Populator.prototype.populate = function(barcode, which) { 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 @@ Populator.prototype.act_on_selected = function(how, which) { 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; diff --git a/Open-ILS/web/js/ui/default/booking/pull_list.js b/Open-ILS/web/js/ui/default/booking/pull_list.js index 38f130b095..996cc42756 100644 --- a/Open-ILS/web/js/ui/default/booking/pull_list.js +++ b/Open-ILS/web/js/ui/default/booking/pull_list.js @@ -113,7 +113,7 @@ function get_all_relevant_acp(list) { 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 @@ function populate_pull_list(form) { 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; } diff --git a/Open-ILS/web/js/ui/default/booking/reservation.js b/Open-ILS/web/js/ui/default/booking/reservation.js index a1187774cd..8e97b22556 100644 --- a/Open-ILS/web/js/ui/default/booking/reservation.js +++ b/Open-ILS/web/js/ui/default/booking/reservation.js @@ -299,7 +299,7 @@ function create_bresv(resource_list) { 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 @@ function get_actor_by_barcode(barcode) { ); 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 @@ function init_bresv_grid(barcode) { 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 init_bresv_grid(barcode) { } 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 cancel_reservations(bresv_id_list) { 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 init_timestamp_widgets() { } 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]; }) ); diff --git a/Open-ILS/xul/staff_client/server/patron/display_horiz_overlay.xul b/Open-ILS/xul/staff_client/server/patron/display_horiz_overlay.xul index 3481ca21e0..17094e6a20 100644 --- a/Open-ILS/xul/staff_client/server/patron/display_horiz_overlay.xul +++ b/Open-ILS/xul/staff_client/server/patron/display_horiz_overlay.xul @@ -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"/> diff --git a/Open-ILS/xul/staff_client/server/patron/display_overlay.xul b/Open-ILS/xul/staff_client/server/patron/display_overlay.xul index 3137c531ed..bfdea6fdb5 100644 --- a/Open-ILS/xul/staff_client/server/patron/display_overlay.xul +++ b/Open-ILS/xul/staff_client/server/patron/display_overlay.xul @@ -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"/> -- 2.11.0