From a79ae51fe92c2ccdb74a6c3050eb2fedd9c74841 Mon Sep 17 00:00:00 2001 From: phasefx Date: Thu, 15 Jul 2010 21:34:21 +0000 Subject: [PATCH] Have open-ils.circ.circulation.due_date.update return the circ instead of the circ id so that modified rows in Items Out refresh correctly, and have Items Out -> Edit Due Date, -> Renew with Specific Date, and -> Mark Claimed Returned use the date/timepicker dialog git-svn-id: svn://svn.open-ils.org/ILS/trunk@16951 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/Application/Circ.pm | 2 +- .../server/locale/en-US/patron.properties | 7 +- Open-ILS/xul/staff_client/server/patron/items.js | 157 ++++++++------------- 3 files changed, 65 insertions(+), 101 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm index 483fc4539..2cbc4bd5e 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm @@ -514,7 +514,7 @@ sub set_circ_due_date { $e->update_action_circulation($circ) or return $e->die_event; $e->commit; - return $circ->id; + return $circ; } diff --git a/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties b/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties index b2d59b721..49afcfd70 100644 --- a/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties +++ b/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties @@ -301,19 +301,18 @@ staff.patron.items.items_renew.err_in_renew_via_barcode=Error in renew_via_barco staff.patron.items.items_renew.no_renew_for_barcode=Renew probably did not happen for barcode %1$s staff.patron.items.items_renew.no_renew=Renew probably did not happen. staff.patron.items.items_edit.renew_with_date.title=Renew with Due Date +staff.patron.items.items_edit.renew_with_date.description=Renew with Due Date staff.patron.items.items_edit.renew_with_date.prompt=Enter a new due date for these items to be renewed: %1$s -staff.patron.items.items_edit.cancel_renew_with_date=Missing Due Date. Renewal canceled. -staff.patron.items.items_edit.invalid_date=Invalid Date -staff.patron.items.items_edit.need_later_date=Due date needs to be after today. staff.patron.items.items_edit.edit_due_date.singular=Edit Due Date staff.patron.items.items_edit.edit_due_date.plural=Edit Due Dates +staff.patron.items.items_edit.edit_due_date.description=Due Date staff.patron.items.items_edit.new_due_date=Enter a new due date for these items: %1$s staff.patron.items.items_edit.dates_not_modified=The due dates were not likely modified. staff.patron.items.items_edit.mark_barcode_lost=Mark barcode lost = %1$s staff.patron.items.items_edit.item_barcode=Item Barcode %1$s\n%2$s staff.patron.items.items_edit.items_not_marked_lost=The items were not likely marked lost. -staff.patron.items.items_claimed_returned.date_cannot_be_in_future=Claims Returned Date cannot be in the future. staff.patron.items.items_claimed_returned.claimed_returned=Claimed Returned +staff.patron.items.items_claimed_returned.claimed_returned.description=Date Claimed staff.patron.items.items_claimed_returned.enter_returned_date=Enter a claimed returned date for these items: %1$s staff.patron.items.items_claimed_returned.not_marked_claimed_returned=The items were not likely marked Claimed Returned. staff.patron.items.set_claim_returned_failure=Override set claimed returned failure? diff --git a/Open-ILS/xul/staff_client/server/patron/items.js b/Open-ILS/xul/staff_client/server/patron/items.js index aee4f64d5..cd26fbc07 100644 --- a/Open-ILS/xul/staff_client/server/patron/items.js +++ b/Open-ILS/xul/staff_client/server/patron/items.js @@ -320,42 +320,30 @@ patron.items.prototype = { var count = 0; - function check_date(value) { - JSAN.use('util.date'); - try { - if (! util.date.check('YYYY-MM-DD',value) ) { - throw($("patronStrings").getString('staff.patron.items.items_edit.invalid_date')); - } - if (util.date.check_past('YYYY-MM-DD',value) ) { - throw($("patronStrings").getString('staff.patron.items.items_edit.need_later_date')); - } - if ( util.date.formatted_date(new Date(),'%F') == value) { - throw($("patronStrings").getString('staff.patron.items.items_edit.need_later_date')); - } - return true; - } catch(E) { - alert(E); - return false; - } - } - if (params.get_date) { JSAN.use('util.functional'); var title = $("patronStrings").getString('staff.patron.items.items_edit.renew_with_date.title'); - var value = 'YYYY-MM-DD'; - var text = $("patronStrings").getFormattedString('staff.patron.items.items_edit.renew_with_date.prompt', [util.functional.map_list(retrieve_ids,function(o){return o.barcode;}).join(', ')]); - var due_date; var invalid = true; - while(invalid) { - due_date = window.prompt(text,value,title); - if (due_date) { - invalid = ! check_date(due_date); - if (invalid) obj.sound.circ_bad(); - } else { - alert( $("patronStrings").getString('staff.patron.items.items_edit.cancel_renew_with_date') ); - return; + var msg = $("patronStrings").getFormattedString('staff.patron.items.items_edit.renew_with_date.prompt', [util.functional.map_list(retrieve_ids,function(o){return o.barcode;}).join(', ')]); + var desc = $("patronStrings").getString('staff.patron.items.items_edit.renew_with_date.description'); + + JSAN.use('util.window'); var win = new util.window(); + var my_xulG = win.open( + urls.XUL_TIMESTAMP_DIALOG, 'edit_renew_due_date', 'chrome,resizable,modal', + { + 'title' : title, + 'description' : desc, + 'msg' : msg, + 'allow_unset' : false, + 'disallow_future_dates' : false, + 'disallow_past_dates' : false, + 'disallow_today' : false, + 'time_readonly' : false } + ); + + if (my_xulG.complete) { + params.due_date = my_xulG.timestamp; } - params.due_date = due_date; } function gen_renew(bc,circ_id) { @@ -412,26 +400,6 @@ patron.items.prototype = { try { var retrieve_ids = ( which == 2 ? obj.retrieve_ids2 : obj.retrieve_ids ); if (!retrieve_ids || retrieve_ids.length == 0) return; - function check_date(value) { - JSAN.use('util.date'); - try { - if (! util.date.check('YYYY-MM-DD',value) ) { - throw($("patronStrings").getString('staff.patron.items.items_edit.invalid_date')); - } - if (util.date.check_past('YYYY-MM-DD',value) ) { - throw($("patronStrings").getString('staff.patron.items.items_edit.need_later_date')); - } - /* - if ( util.date.formatted_date(new Date(),'%F') == value) { - throw('Due date needs to be after today.'); - } - */ - return true; - } catch(E) { - alert(E); - return false; - } - } JSAN.use('util.functional'); var title = ''; @@ -441,28 +409,36 @@ patron.items.prototype = { title += $("patronStrings").getString('staff.patron.items.items_edit.edit_due_date.singular'); } var value = 'YYYY-MM-DD'; - var text = $("patronStrings").getFormattedString('staff.patron.items.items_edit.new_due_date', [util.functional.map_list(retrieve_ids,function(o){return o.barcode;}).join(', ')]); - var due_date; var invalid = true; - while(invalid) { - due_date = window.prompt(text,value,title); - if (due_date) { - invalid = ! check_date(due_date); - } else { - invalid = false; + var msg = $("patronStrings").getFormattedString('staff.patron.items.items_edit.new_due_date', [util.functional.map_list(retrieve_ids,function(o){return o.barcode;}).join(', ')]); + var desc = $("patronStrings").getString('staff.patron.items.items_edit.edit_due_date.description'); + + JSAN.use('util.window'); var win = new util.window(); + var my_xulG = win.open( + urls.XUL_TIMESTAMP_DIALOG, 'edit_due_date', 'chrome,resizable,modal', + { + 'title' : title, + 'description' : desc, + 'msg' : msg, + 'allow_unset' : false, + 'disallow_future_dates' : false, + 'disallow_past_dates' : false, + 'disallow_today' : false, + 'time_readonly' : false } - } - if (due_date) { + ); + + if (my_xulG.complete) { // XXX We need to append the time component from the original due date to the entered // date here, if (circ interval % 1 day == 0) + // XXX I think the middle layer is doing this now var circs = util.functional.map_list(retrieve_ids,function(o){return o.circ_id;}); for (var i = 0; i < circs.length; i++) { - var robj = obj.network.simple_request('FM_CIRC_EDIT_DUE_DATE',[ses(),circs[i],due_date]); + var robj = obj.network.simple_request('FM_CIRC_EDIT_DUE_DATE',[ses(),circs[i],my_xulG.timestamp]); if (typeof robj.ilsevent != 'undefined') { if (robj.ilsevent != 0) throw(robj); } + obj.list_circ_map[ circs[i] ].row.my.circ = robj; + obj.refresh(circs[i]); } } - for (var i = 0; i < retrieve_ids.length; i++) { - obj.refresh(retrieve_ids[i].circ_id); - } } catch(E) { obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.items.items_edit.dates_not_modified'),E); } @@ -498,48 +474,37 @@ patron.items.prototype = { try { JSAN.use('util.date'); var retrieve_ids = ( which == 2 ? obj.retrieve_ids2 : obj.retrieve_ids ); - if (!retrieve_ids || retrieve_ids.length == 0) return; - function check_date(value) { - try { - if (! util.date.check('YYYY-MM-DD',value) ) { - throw($("patronStrings").getString('staff.patron.items.items_edit.invalid_date')); - } - if ( util.date.formatted_date(new Date(),'%F') == value) { - return true; - } - if (! util.date.check_past('YYYY-MM-DD',value) ) { - throw($("patronStrings").getString('staff.patron.items.items_claimed_returned.date_cannot_be_in_future')); - } - return true; - } catch(E) { - alert(E); - return false; - } - } JSAN.use('util.functional'); var title = $("patronStrings").getString('staff.patron.items.items_claimed_returned.claimed_returned'); var value = 'YYYY-MM-DD'; - var text = $("patronStrings").getFormattedString('staff.patron.items.items_claimed_returned.enter_returned_date', + var msg = $("patronStrings").getFormattedString('staff.patron.items.items_claimed_returned.enter_returned_date', [util.functional.map_list(retrieve_ids,function(o){return o.barcode;}).join(', ')]); - var backdate; var invalid = true; - while(invalid) { - backdate = window.prompt(text,value,title); - if (backdate) { - invalid = ! check_date(backdate); - } else { - invalid = false; + var desc = $("patronStrings").getString('staff.patron.items.items_claimed_returned.claimed_returned.description'); + + JSAN.use('util.window'); var win = new util.window(); + var my_xulG = win.open( + urls.XUL_TIMESTAMP_DIALOG, 'edit_claimed_returned', 'chrome,resizable,modal', + { + 'title' : title, + 'description' : desc, + 'msg' : msg, + 'allow_unset' : false, + 'disallow_future_dates' : true, + 'disallow_past_dates' : false, + 'disallow_today' : false, + 'time_readonly' : false } - } - //alert('backdate = ' + backdate); - if (backdate) { - backdate = util.date.formatted_date(backdate,'%{iso8601}'); + ); + + + if (my_xulG.complete) { var barcodes = util.functional.map_list(retrieve_ids,function(o){return o.barcode;}); var do_not_move_these = {}; for (var i = 0; i < barcodes.length; i++) { var robj = obj.network.simple_request( 'MARK_ITEM_CLAIM_RETURNED', - [ ses(), { barcode: barcodes[i], backdate: backdate } ], + [ ses(), { barcode: barcodes[i], backdate: my_xulG.timestamp } ], null, { 'title' : $("patronStrings").getString('staff.patron.items.set_claim_returned_failure'), -- 2.11.0