From 95c32e215d883b38613a02964c4dda2101d607bc Mon Sep 17 00:00:00 2001 From: phasefx Date: Mon, 2 Nov 2009 03:07:37 +0000 Subject: [PATCH] FEATURE: Renew with Specific Due Date option for Items Out interface. DEV NOTES: Some refactoring. Would this style of commit message be useful for change logs? Some keywords like FEATURE or BUGFIX for stuff meant to be more widely read? Or alternately, we could use development branches for intermediate work/commits, and reserve trunk and the release branches for changelog worthy commits? I personally don't mind reviewing 'typo' and 'oops' changesets that fly by. :) git-svn-id: svn://svn.open-ils.org/ILS/trunk@14716 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/opac/locale/en-US/lang.dtd | 1 + .../server/locale/en-US/patron.properties | 3 + Open-ILS/xul/staff_client/server/patron/items.js | 70 +++++++++++++++++++--- .../staff_client/server/patron/items_overlay.xul | 6 ++ 4 files changed, 71 insertions(+), 9 deletions(-) diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index 3eb55a61c2..684db2691a 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -2788,6 +2788,7 @@ + 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 e6b5fc330b..8cee5b888f 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 @@ -263,6 +263,9 @@ staff.patron.items.items_renew.not_renewed=%1$s not renewed.\n%2$s staff.patron.items.items_renew.err_in_renew_via_barcode=Error in renew_via_barcode callback\nRenew probably did not happen for barcode %1$s 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.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 diff --git a/Open-ILS/xul/staff_client/server/patron/items.js b/Open-ILS/xul/staff_client/server/patron/items.js index ec1547c8a4..d2973adf1e 100644 --- a/Open-ILS/xul/staff_client/server/patron/items.js +++ b/Open-ILS/xul/staff_client/server/patron/items.js @@ -8,6 +8,7 @@ patron.items = function (params) { JSAN.use('util.error'); this.error = new util.error(); JSAN.use('util.network'); this.network = new util.network(); JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init({'via':'stash'}); + JSAN.use('util.sound'); this.sound = new util.sound(); } patron.items.prototype = { @@ -91,9 +92,11 @@ patron.items.prototype = { 'cmd_items_print2' : [ ['command'], function() { obj.items_print(2); } ], 'cmd_items_export' : [ ['command'], function() { obj.items_export(1); } ], 'cmd_items_export2' : [ ['command'], function() { obj.items_export(2); } ], - 'cmd_items_renew' : [ ['command'], function() { obj.items_renew(1); /* obj.retrieve();*/ } ], - 'cmd_items_renew_all' : [ ['command'], function() { obj.items_renew_all(); } ], - 'cmd_items_renew2' : [ ['command'], function() { obj.items_renew(2); /* obj.retrieve();*/ } ], + 'cmd_items_renew' : [ ['command'], function() { obj.items_renew({which_list:1}); } ], + 'cmd_items_renew_with_date' : [ ['command'], function() { obj.items_renew({which_list:1,skip_prompt:true,get_date:true}); } ], + 'cmd_items_renew_all' : [ ['command'], function() { obj.items_renew_all({which_list:1}); } ], + 'cmd_items_renew2' : [ ['command'], function() { obj.items_renew({which_list:2}); } ], + 'cmd_items_renew_with_date2' : [ ['command'], function() { obj.items_renew({which_list:2,skip_prompt:true,get_date:true}); } ], 'cmd_items_edit' : [ ['command'], function() { obj.items_edit(1); /*obj.retrieve();*/ } ], 'cmd_items_edit2' : [ ['command'], function() { obj.items_edit(2); /*obj.retrieve();*/ } ], 'cmd_items_mark_lost' : [ ['command'], function() { obj.items_mark_lost(1); /*obj.retrieve();*/ } ], @@ -127,12 +130,14 @@ patron.items.prototype = { obj.controller.view.sel_patron2.setAttribute('disabled','true'); obj.controller.view.cmd_items_claimed_returned.setAttribute('disabled','true'); obj.controller.view.cmd_items_renew.setAttribute('disabled','true'); + obj.controller.view.cmd_items_renew_with_date.setAttribute('disabled','true'); obj.controller.view.cmd_items_checkin.setAttribute('disabled','true'); obj.controller.view.cmd_items_edit.setAttribute('disabled','true'); obj.controller.view.cmd_items_mark_lost.setAttribute('disabled','true'); obj.controller.view.cmd_show_catalog.setAttribute('disabled','true'); obj.controller.view.cmd_items_claimed_returned2.setAttribute('disabled','true'); obj.controller.view.cmd_items_renew2.setAttribute('disabled','true'); + obj.controller.view.cmd_items_renew_with_date2.setAttribute('disabled','true'); obj.controller.view.cmd_items_checkin2.setAttribute('disabled','true'); obj.controller.view.cmd_items_edit2.setAttribute('disabled','true'); obj.controller.view.cmd_items_mark_lost2.setAttribute('disabled','true'); @@ -223,8 +228,9 @@ patron.items.prototype = { } }, - 'items_renew_all' : function() { + 'items_renew_all' : function(params) { try { + if (!params) params = {}; var obj = this; var list = obj.list; if (list.on_all_fleshed != null) { var r = window.confirm($("patronStrings").getString('staff.patron.items.items_renew_all.list_is_busy')); @@ -235,7 +241,9 @@ patron.items.prototype = { function flesh_callback() { try { obj.list.select_all(); - obj.items_renew(1,true); + params.skip_prompt = true; + if (!params.which_list) params.which_list = 1; + obj.items_renew(params); setTimeout(function(){list.on_all_fleshed = null; /* obj.retrieve();*/ },0); } catch(E) { obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.items.items_renew_all.items_not_renewed', ['2']),E); @@ -248,14 +256,15 @@ patron.items.prototype = { } }, - 'items_renew' : function(which,skip_prompt) { + 'items_renew' : function(params) { var obj = this; try{ + if (!params) { params = {}; } JSAN.use('circ.util'); - var retrieve_ids = ( which == 2 ? obj.retrieve_ids2 : obj.retrieve_ids ); + var retrieve_ids = ( params.which_list == 2 ? obj.retrieve_ids2 : obj.retrieve_ids ); if (!retrieve_ids || retrieve_ids.length == 0) return; JSAN.use('util.functional'); - if (!skip_prompt) { + if (!params.skip_prompt) { var msg = ''; if(retrieve_ids.length > 1) { msg += $("patronStrings").getFormattedString('staff.patron.items.items_renew.renew_item_plural',[util.functional.map_list( retrieve_ids, function(o){return o.barcode;}).join(', ')]); @@ -268,6 +277,44 @@ 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; + } + } + params.due_date = due_date; + } + function gen_renew(bc,circ_id) { var x = document.getElementById('renew_msgs'); if (x) { @@ -275,7 +322,10 @@ patron.items.prototype = { l.setAttribute('value', $("patronStrings").getFormattedString('staff.patron.items.items_renew.renewing',[bc])); x.appendChild(l); } - var renew = circ.util.renew_via_barcode( { 'barcode' : bc, 'patron' : obj.patron_id }, + var p = { 'barcode' : bc, 'patron' : obj.patron_id }; + if (params.due_date) p.due_date = params.due_date; + var renew = circ.util.renew_via_barcode( + p, function(r) { try { if ( (typeof r[0].ilsevent != 'undefined' && r[0].ilsevent == 0) ) { @@ -813,6 +863,7 @@ patron.items.prototype = { obj.controller.view.cmd_items_claimed_returned.setAttribute('disabled','false'); obj.controller.view.cmd_items_renew.setAttribute('disabled','false'); + obj.controller.view.cmd_items_renew_with_date.setAttribute('disabled','false'); obj.controller.view.cmd_items_checkin.setAttribute('disabled','false'); obj.controller.view.cmd_items_edit.setAttribute('disabled','false'); obj.controller.view.cmd_items_mark_lost.setAttribute('disabled','false'); @@ -834,6 +885,7 @@ patron.items.prototype = { obj.controller.view.cmd_items_claimed_returned2.setAttribute('disabled','false'); obj.controller.view.cmd_items_renew2.setAttribute('disabled','false'); + obj.controller.view.cmd_items_renew_with_date2.setAttribute('disabled','false'); obj.controller.view.cmd_items_checkin2.setAttribute('disabled','false'); obj.controller.view.cmd_items_edit2.setAttribute('disabled','false'); obj.controller.view.cmd_items_mark_lost2.setAttribute('disabled','false'); diff --git a/Open-ILS/xul/staff_client/server/patron/items_overlay.xul b/Open-ILS/xul/staff_client/server/patron/items_overlay.xul index 200c7cb427..b1b5b95dfa 100644 --- a/Open-ILS/xul/staff_client/server/patron/items_overlay.xul +++ b/Open-ILS/xul/staff_client/server/patron/items_overlay.xul @@ -17,6 +17,7 @@ + @@ -36,6 +37,7 @@ + @@ -61,6 +63,7 @@