KMAIN-1317 Line Item Note Display
authorBill Erickson <berickxx@gmail.com>
Wed, 29 Oct 2014 21:10:11 +0000 (17:10 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
    Cross-port: edb4fe8

Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Lineitem.pm
Open-ILS/xul/staff_client/chrome/content/main/constants.js
Open-ILS/xul/staff_client/server/cat/update_items.js
Open-ILS/xul/staff_client/server/cat/update_items.xul

index af491b6..19ce965 100644 (file)
@@ -880,6 +880,34 @@ sub get_lineitem_attr_defs {
 
 
 __PACKAGE__->register_method(
+       method    => 'get_lineitem_notes_by_id',
+       api_name  => 'open-ils.acq.get_lineitem_notes_by_id',
+       signature => {
+               desc   => 'Retrieve lineitem notes by id',
+               params => [ 
+                       { desc => 'Authentication token', type => 'string' },
+                       { desc => 'Id of lineitem to retrive notes for', type => 'number'},
+               ],
+               return =>
+                       { desc => 'List of notes sorted by edit date' }
+       }
+);
+
+sub get_lineitem_notes_by_id {
+       my($self, $conn, $auth, $lineitem_id) = @_;
+       
+       my $editor = new_editor(authtoken => $auth);
+       my $results = $editor->json_query({
+               'select' => { 'acqlin' => ['value', 'edit_time'] },
+               'from' => 'acqlin',
+               'where' => { lineitem => $lineitem_id },
+               'order_by' => [{ 'class'=>'acqlin', 'field'=>'edit_time', 'direction'=>'desc' }]
+               });
+       
+       return $results;
+}
+
+__PACKAGE__->register_method(
     method    => 'lineitem_note_CUD_batch',
     api_name  => 'open-ils.acq.lineitem_note.cud.batch',
     stream    => 1,
index 96100b4..8f0f14f 100644 (file)
@@ -87,6 +87,7 @@ var api = {
     'FM_ACN_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.callnumber.fleshed.retrieve', 'secure' : false },
     'FM_ACN_RETRIEVE.authoritative' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.callnumber.fleshed.retrieve.authoritative', 'secure' : false },
     'FM_OPEN_LI_RETRIEVE_BY_TCN' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.lineitem.latest_by_tcn', 'secure' : false },
+    'FM_LI_NOTES_RETRIEVE_BY_ID' : { 'app' : 'open-ils.acq', 'method' : 'open-ils.acq.get_lineitem_notes_by_id', 'secure' : false },
     'FM_OPEN_LI_RETRIEVE_BY_ID' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.lineitem.lineitem_by_id', 'secure' : false },
     'FM_CUD_LI_NOTE' : { 'app' : 'open-ils.acq', 'method' : 'open-ils.acq.lineitem_note.cud.batch', 'secure' : false },
     'FM_ACN_TREE_UPDATE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.asset.volume.fleshed.batch.update' },
index 9f10274..b2255ae 100644 (file)
@@ -57,7 +57,7 @@ function my_init() {
             'FM_OPEN_LI_RETRIEVE_BY_TCN',
             [ ses(), xul_param('doc_id') ]
         );
-
+        
         // Create the list of lineitems
         g.lineitem_list = raw_lineitem_data[0][0];
 
@@ -76,6 +76,8 @@ function my_init() {
             g.render_batch_button();
 
             g.render_lineitem_dropdown();
+            
+            g.load_and_render_lineitem_notes(g.lineitem_list[g.current_lineitem_index][0]);
 
             /***********************************************************************************************************/
             /* What record am I dealing with?  */
@@ -201,6 +203,32 @@ function my_init() {
     }
 }
 
+g.load_and_render_lineitem_notes = function(lineitem_id) {
+       // Fetch the notes from the DB
+       var line_item_notes = g.network.simple_request(
+                       'FM_LI_NOTES_RETRIEVE_BY_ID',
+                       [ ses(), lineitem_id ]
+               );
+
+       var rows = document.getElementById('lineitem_rows');
+       
+       // Remove existing notes
+       var row_list = rows.childNodes;
+       while(row_list.length > 1) {
+               rows.removeChild(row_list[1]);
+       }
+               
+       // Render the notes
+       for(var index = 0; index < line_item_notes.length; ++index) {
+               var r = document.createElement('row'); rows.appendChild( r );
+               var x = document.createElement('label'); r.appendChild(x);
+               x.setAttribute('value', line_item_notes[index].edit_time.substring(0,10));
+               x = document.createElement('spacer'); r.appendChild(x);
+               x = document.createElement('label'); r.appendChild(x);
+               x.setAttribute('value', line_item_notes[index].value);
+       }
+}
+
 g.load_lineitem = function(raw_lineitem_data){
 
     var raw_data = raw_lineitem_data[0][1];
@@ -1496,6 +1524,7 @@ g.render_lineitem_dropdown = function() {
 
             g.current_lineitem_index = menulist.getIndexOfItem( menulist.selectedItem );
             g.reset_lineitem();
+            g.load_and_render_lineitem_notes(g.lineitem_list[g.current_lineitem_index][0]);
             g.summarize( g.existing_copies );
             g.render_edit_items_panes();
         },
index 9b83d17..600a892 100644 (file)
                                                <vbox id="right_pane" flex="1"/>
                                        </vbox>
                                </hbox>
+                               <splitter><grippy /></splitter>
+                               <hbox flex="1" style="overflow: scroll">
+                                       <grid flex="1">
+                                               <columns> <column/><column/><column/></columns>
+                                                       <rows id="lineitem_rows">
+                                                               <row><caption id="caption" label="Line Item Notes"/></row>
+                                                       </rows>
+                                       </grid>
+                               </hbox>
                        </groupbox>
         </groupbox>
         <hbox style="border-bottom: solid black thin">