From d7c27823733800717d1634cd074c8ffd01c4fcfe Mon Sep 17 00:00:00 2001
From: phasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Tue, 29 Sep 2009 05:46:49 +0000
Subject: [PATCH] Action in bill details interface for editing notes on
 billings

git-svn-id: svn://svn.open-ils.org/ILS/trunk@14196 dcc99617-32d9-48b4-a31d-7c20da2025e4
---
 Open-ILS/web/opac/locale/en-US/lang.dtd            |  4 +--
 .../staff_client/chrome/content/main/constants.js  |  1 +
 .../server/locale/en-US/patron.properties          |  4 +++
 .../xul/staff_client/server/patron/bill_details.js | 32 ++++++++++++++++++++++
 .../staff_client/server/patron/bill_details.xul    |  1 +
 5 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd
index 72faefc492..87aaa7b2ba 100644
--- a/Open-ILS/web/opac/locale/en-US/lang.dtd
+++ b/Open-ILS/web/opac/locale/en-US/lang.dtd
@@ -2418,10 +2418,8 @@
 <!ENTITY staff.patron.bill_check_info.submit.label "Submit this Information">
 <!ENTITY staff.patron.bill_check_info.submit.accesskey "S">
 <!ENTITY staff.patron.bill_details.bills.label "Bills">
-<!ENTITY staff.patron.bill_details.save_columns.label "Save Columns">
-<!ENTITY staff.patron.bill_details.copy_to_clipboard.label "Copy to Clipboard">
-<!ENTITY staff.patron.bill_details.print_export.label "Print Export">
 <!ENTITY staff.patron.bill_details.void_selection.label "Void selected billings">
+<!ENTITY staff.patron.bill_details.edit_notes.label "Edit note">
 <!ENTITY staff.patron.bill_details.payments.label "Payments">
 <!ENTITY staff.patron.bill_details.show_in_catalog.label "Show in Catalog">
 <!ENTITY staff.patron.bill_details.show_in_catalog.accesskey "S">
diff --git a/Open-ILS/xul/staff_client/chrome/content/main/constants.js b/Open-ILS/xul/staff_client/chrome/content/main/constants.js
index 6bae3475a5..19d9a31f4d 100644
--- a/Open-ILS/xul/staff_client/chrome/content/main/constants.js
+++ b/Open-ILS/xul/staff_client/chrome/content/main/constants.js
@@ -197,6 +197,7 @@ const api = {
 	'FM_MB_RETRIEVE_VIA_MBTS_ID' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.billing.retrieve.all' },
 	'FM_MB_RETRIEVE_VIA_MBTS_ID.authoritative' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.billing.retrieve.all.authoritative' },
 	'FM_MB_VOID' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.billing.void' },
+	'FM_MB_NOTE_EDIT' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.billing.note.edit' },
 	'FM_MBTS_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.billable_xact_summary.retrieve' },
 	'FM_MBTS_RETRIEVE.authoritative' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.billable_xact_summary.retrieve.authoritative' },
 	'FM_MBTS_IDS_RETRIEVE_ALL' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.history' },
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 0956b8601f..914ca9c90b 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
@@ -11,6 +11,10 @@ staff.patron.barcode_entry.patron_consent_confirm=Check here to confirm this mes
 staff.patron.barcode_entry.patron_display_error=spawning patron display
 staff.patron.barcode_entry.user_perm_display_error=spawning user perm editor
 staff.patron.bill_details.my_init.error=bill_details.xul, my_init:
+staff.patron.bill_details.handle_edit_bill_note.note_dialog.title=Replacement Note
+staff.patron.bill_details.handle_edit_bill_note.note_dialog.prompt=Enter new note:
+staff.patron.bill_details.handle_edit_bill_note.note_dialog.default_value=
+staff.patron.bill_details.handle_edit_bill_note.failure=Note for selected bills not likely updated.
 staff.patron.bill_details.handle_void.voided_billings.alert=All selected billings have already voided.
 staff.patron.bill_details.handle_void.confirm_void_billing=Are you sure you would like to void $%1$s worth of line-item billings?
 staff.patron.bill_details.handle_void.confirm_void_billing_title=Voiding Bills
diff --git a/Open-ILS/xul/staff_client/server/patron/bill_details.js b/Open-ILS/xul/staff_client/server/patron/bill_details.js
index c126ef30dc..b586748b83 100644
--- a/Open-ILS/xul/staff_client/server/patron/bill_details.js
+++ b/Open-ILS/xul/staff_client/server/patron/bill_details.js
@@ -129,6 +129,7 @@ function init_lists() {
                 function(o) { return o.getAttribute('retrieve_id'); }
             );
             $('void').disabled = g.bill_list_selection.length == 0;
+            $('edit_bill_note').disabled = g.bill_list_selection.length == 0;
         },
     } );
 
@@ -224,11 +225,42 @@ function my_init() {
             false
         );
 
+        $('edit_bill_note').addEventListener(
+            'command',
+            handle_edit_bill_note,
+            false
+        );
+
     } catch(E) {
         try { g.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.bill_details.my_init.error'),E); } catch(F) { alert(E); }
     }
 }
 
+function handle_edit_bill_note() {
+    try {
+        var mb_list = util.functional.map_list(g.bill_list_selection, function(o){return g.mb_list[o].id();}); 
+        if (mb_list.length == 0) return;
+        var new_note = window.prompt(
+            $("patronStrings").getString('staff.patron.bill_details.handle_edit_bill_note.note_dialog.prompt'),
+            $("patronStrings").getString('staff.patron.bill_details.handle_edit_bill_note.note_dialog.default_value'),
+            $("patronStrings").getString('staff.patron.bill_details.handle_edit_bill_note.note_dialog.title')
+        );
+        if (new_note) {
+            var r = g.network.simple_request('FM_MB_NOTE_EDIT',[ ses(), new_note ].concat(mb_list));
+            if (r == 1 /* success */) {
+                g.bill_list.clear();
+                retrieve_mb();
+            } else {
+                if (r.ilsevent != 5000 /* PERM_FAILURE */) {
+                    alert( $("patronStrings").getString('staff.patron.bill_details.handle_edit_bill_note.failure') );
+                }
+            } 
+        }
+    } catch(E) {
+        try { g.error.standard_unexpected_error_alert('bill_details.xul, handle_edit_bill_note:',E); } catch(F) { alert(E); }
+    }
+};
+
 function handle_void() {
     try {
         var mb_list = util.functional.map_list(g.bill_list_selection, function(o){return g.mb_list[o];}); 
diff --git a/Open-ILS/xul/staff_client/server/patron/bill_details.xul b/Open-ILS/xul/staff_client/server/patron/bill_details.xul
index 8b57f1d7ba..502dcdd6fc 100644
--- a/Open-ILS/xul/staff_client/server/patron/bill_details.xul
+++ b/Open-ILS/xul/staff_client/server/patron/bill_details.xul
@@ -51,6 +51,7 @@
 				<hbox>
                     <hbox id="bill_list_actions" />
 					<spacer flex="1"/>
+					<button id="edit_bill_note" label="&staff.patron.bill_details.edit_notes.label;" disabled="true"/>
 					<button id="void" label="&staff.patron.bill_details.void_selection.label;" disabled="true"/>
 				</hbox>
 			</groupbox>
-- 
2.11.0