initial support for lineitem notes
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 16 Apr 2009 15:57:49 +0000 (15:57 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 16 Apr 2009 15:57:49 +0000 (15:57 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@12893 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm
Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm
Open-ILS/web/js/ui/default/acq/common/li_table.js
Open-ILS/web/js/ui/default/acq/picklist/view.js
Open-ILS/web/js/ui/default/acq/po/view_po.js
Open-ILS/web/templates/default/acq/common/li_table.tt2

index c25e6b2..06b0938 100644 (file)
@@ -90,14 +90,15 @@ sub retrieve_lineitem {
 
     my $li;
 
-    if($$options{flesh_attrs}) {
-        $li = $e->retrieve_acq_lineitem([
-            $li_id, {flesh => 1, flesh_fields => {jub => ['attributes']}}])
-            or return $e->event;
-    } else {
-        $li = $e->retrieve_acq_lineitem($li_id) or return $e->event;
+    my $flesh = {};
+    if($$options{flesh_attrs} or $$options{flesh_notes}) {
+        $flesh = {flesh => 1, flesh_fields => {jub => []}};
+        push(@{$flesh->{flesh_fields}->{jub}}, 'lineitem_notes') if $$options{flesh_notes};
+        push(@{$flesh->{flesh_fields}->{jub}}, 'attributes') if $$options{flesh_attrs};
     }
 
+    $li = $e->retrieve_acq_lineitem([$li_id, $flesh]);
+
     if($$options{flesh_li_details}) {
         my $ops = {
             flesh => 1,
index 06be586..4c84ead 100644 (file)
@@ -333,6 +333,7 @@ __PACKAGE__->register_method(
                 "idlist", return a list of IDs instead of objects
                 "flesh_attrs", additionaly return the list of flattened attributes
                 "clear_marc", discards the raw MARC data to reduce data size
+                "flesh_notes", flesh lineitem notes
                 /, 
                 type => 'hash'}
         ],
@@ -393,8 +394,12 @@ sub retrieve_pl_lineitem {
         } 
 
         my $entry;
-        my $flesh = ($$options{flesh_attrs}) ? 
-            {flesh => 1, flesh_fields => {jub => ['attributes']}} : {};
+        my $flesh = {};
+        if($$options{flesh_attrs} or $$options{flesh_notes}) {
+            $flesh = {flesh => 1, flesh_fields => {jub => []}};
+            push(@{$flesh->{flesh_fields}->{jub}}, 'lineitem_notes') if $$options{flesh_notes};
+            push(@{$flesh->{flesh_fields}->{jub}}, 'attributes') if $$options{flesh_attrs};
+        }
 
         $entry = $e->retrieve_acq_lineitem([$id, $flesh]);
         my $details = $e->search_acq_lineitem_detail({lineitem => $id}, {idlist=>1});
index f8b760b..c8cc76d 100644 (file)
@@ -125,6 +125,7 @@ function AcqLiTable() {
 
     this.addLineitem = function(li) {
         this.liCache[li.id()] = li;
+        if(!li.lineitem_notes()) li.lineitem_notes([]);
         var liWrapper = new openils.acq.Lineitem({lineitem:li});
         var row = self.rowTemplate.cloneNode(true);
         row.setAttribute('li', li.id());
@@ -140,7 +141,9 @@ function AcqLiTable() {
 
         dojo.query('[attr=title]', row)[0].onclick = function() {self.drawInfo(li.id())};
         dojo.query('[name=copieslink]', row)[0].onclick = function() {self.drawCopies(li.id())};
-        dojo.query('[name=count]', row)[0].appendChild(document.createTextNode(li.item_count()));
+        dojo.query('[name=count]', row)[0].innerHTML = li.item_count();
+        dojo.query('[name=notes_count]', row)[0].innerHTML = li.lineitem_notes().length;
+        dojo.query('[name=noteslink]', row)[0].onclick = function() {self.drawLiNotes(li)};
 
         var priceInput = dojo.query('[name=estimated_price]', row)[0];
         var priceData = liWrapper.getPrice();
@@ -151,7 +154,10 @@ function AcqLiTable() {
         self.selectors.push(dojo.query('[name=selectbox]', row)[0]);
     };
 
-    self.updateLiPrice = function(input, li) {
+    this.drawLiNotes = function(li) {
+    }
+
+    this.updateLiPrice = function(input, li) {
 
         var price = input.value;
         var liWrapper = new openils.acq.Lineitem({lineitem:li});
index 5fd05fc..aad6d64 100644 (file)
@@ -77,7 +77,7 @@ function loadLIs() {
         ['open-ils.acq', 'open-ils.acq.lineitem.picklist.retrieve'],
         {   async: true,
             params: [openils.User.authtoken, plId, 
-                {flesh_attrs:true, clear_marc:true, offset:plOffset, limit:plLimit}],
+                {flesh_notes:true, flesh_attrs:true, clear_marc:true, offset:plOffset, limit:plLimit}],
             onresponse: function(r) {
                 liTable.show('list');
                 liTable.addLineitem(openils.Util.readResponse(r));
index d8900c3..26e61b5 100644 (file)
@@ -24,7 +24,7 @@ function init() {
     fieldmapper.standardRequest(
         ['open-ils.acq', 'open-ils.acq.lineitem.search'],
         {   async: true,
-            params: [openils.User.authtoken, {purchase_order:poId}, {flesh_attrs:true}],
+            params: [openils.User.authtoken, {purchase_order:poId}, {flesh_attrs:true, flesh_notes:true}],
             onresponse: function(r) {
                 liTable.show('list');
                 liTable.addLineitem(openils.Util.readResponse(r));
index 9288d4c..d3e5f34 100644 (file)
@@ -47,7 +47,8 @@
                     <td><span><a id='acq-lit-select-toggle' href='javascript:void(0);'>&#x2713</a></span></td>
                     <td>Line Items</td>
                     <td>Estimated Price</td>
-                    <td>Copies</td>
+                    <td>Items</td>
+                    <td>Notes</td>
                 </tr>
             </tbody>
             <tbody id='acq-lit-tbody'>
                         <input type='text' size='8' name='estimated_price'/>
                     </td>
                     <td>
-                        <a name='copieslink' href='javascript:void(0);' 
-                            style='margin-right:20px;'>Copies(<span name='count'></span>)</a>
+                        <a name='copieslink' href='javascript:void(0);'>Copies(<span name='count'>0</span>)</a>
+                    </td>
+                    <td>
+                        <a name='noteslink' href='javascript:void(0);' 
+                            style='margin-right:15px;'>Notes(<span name='notes_count'>0</span>)</a>
                     </td>
                 </tr>
             </tbody>