From 0c316fcbefbcbf02c2d346c1df4eeb74e51452dc Mon Sep 17 00:00:00 2001 From: erickson Date: Fri, 4 Sep 2009 19:26:08 +0000 Subject: [PATCH] tighter control over displaying mark-recived and update-barcodes links in lineitem table. showing lineitem and PO state in the UI. Added PO activate routine which effectively marks a PO as 'ready to send to vendor' git-svn-id: svn://svn.open-ils.org/ILS/trunk@13964 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../src/perlmods/OpenILS/Application/Acq/Order.pm | 48 +++++++++++++++++++++- Open-ILS/web/js/ui/default/acq/common/li_table.js | 28 ++++++++++--- Open-ILS/web/js/ui/default/acq/po/view_po.js | 21 ++++++++++ .../web/templates/default/acq/common/li_table.tt2 | 2 + Open-ILS/web/templates/default/acq/po/view.tt2 | 4 +- 5 files changed, 96 insertions(+), 7 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm index 8a1e86f312..9c60eb8753 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm @@ -683,6 +683,7 @@ sub create_purchase_order { $po->owner($mgr->editor->requestor->id); $po->edit_time('now'); $po->create_time('now'); + $po->state('pending'); $po->ordering_agency($mgr->editor->requestor->ws_ou); $po->$_($args{$_}) for keys %args; $po->clear_id; @@ -979,7 +980,8 @@ sub upload_records { if($create_po) { $po = create_purchase_order($mgr, ordering_agency => $ordering_agency, - provider => $provider->id + provider => $provider->id, + state => 'on-order' ) or return $mgr->editor->die_event; } @@ -1306,6 +1308,7 @@ sub create_purchase_order_api { $li->provider($po->provider); $li->purchase_order($po->id); + $li->state('pending-order'); update_lineitem($mgr, $li) or return $e->die_event; $mgr->respond; @@ -1781,4 +1784,47 @@ sub delete_picklist_api { +__PACKAGE__->register_method( + method => 'activate_purchase_order', + api_name => 'open-ils.acq.purchase_order.activate', + signature => { + desc => q/Activates a purchase order. This updates the status of the PO + and Lineitems to 'on-order'. Activated PO's are ready for EDI delivery + if appropriate./, + params => [ + {desc => 'Authentication token', type => 'string'}, + {desc => 'Purchase ID', type => 'number'} + ], + return => {desc => '1 on success, Event on error'} + } +); + +sub activate_purchase_order { + my($self, $conn, $auth, $po_id) = @_; + my $e = new_editor(xact=>1, authtoken=>$auth); + return $e->die_event unless $e->checkauth; + my $mgr = OpenILS::Application::Acq::BatchManager->new(editor => $e, conn => $conn); + + my $po = $e->retrieve_acq_purchase_order($po_id) or return $e->die_event; + return $e->die_event unless $e->allowed('CREATE_PURCHASE_ORDER', $po->ordering_agency); + + $po->state('on-order'); + update_purchase_order($mgr, $po) or return $e->die_event; + + my $query = [ + {purchase_order => $po_id, state => 'pending-order'}, + {limit => 1} + ]; + + while( my $li = $e->search_acq_lineitem($query)->[0] ) { + $li->state('on-order'); + update_lineitem($mgr, $li) or return $e->die_event; + $mgr->respond; + } + + $e->commit; + return 1; +} + + 1; diff --git a/Open-ILS/web/js/ui/default/acq/common/li_table.js b/Open-ILS/web/js/ui/default/acq/common/li_table.js index 310f50ec11..d77af1274c 100644 --- a/Open-ILS/web/js/ui/default/acq/common/li_table.js +++ b/Open-ILS/web/js/ui/default/acq/common/li_table.js @@ -155,6 +155,10 @@ function AcqLiTable() { td.appendChild(document.createTextNode(val)); }; + /** + * Inserts a single lineitem into the growing table of lineitems + * @param {Object} li The lineitem object to insert + */ this.addLineitem = function(li) { this.liCache[li.id()] = li; @@ -183,6 +187,10 @@ function AcqLiTable() { countNode.innerHTML = li.item_count() || 0; countNode.id = 'acq-lit-copy-count-label-' + li.id(); + // lineitem state + nodeByName('li_state', row).innerHTML = li.state(); // TODO i18n state labels + + // lineitem price var priceInput = dojo.query('[name=price]', row)[0]; var priceData = liWrapper.getPrice(); priceInput.value = (priceData) ? priceData.price : ''; @@ -190,17 +198,18 @@ function AcqLiTable() { var recv_link = dojo.query('[name=receive_link]', row)[0]; - if(li.state() == 'received') { - // if the LI is received, hide the receive link and show the 'update barcodes' link - openils.Util.hide(recv_link) - } else { + if(li.state == 'on-order') { recv_link.onclick = function() { self.receiveLi(li); openils.Util.hide(recv_link) } + } else { + openils.Util.hide(recv_link); } - if(li.eg_bib_id()) { + // TODO we should allow editing before receipt, in which case the + // test should be "if 1 or more real (acp) copies exist + if(li.state() == 'received') { var real_copies_link = dojo.query('[name=real_copies_link]', row)[0]; openils.Util.show(real_copies_link); real_copies_link.onclick = function() { @@ -212,6 +221,9 @@ function AcqLiTable() { self.selectors.push(dojo.query('[name=selectbox]', row)[0]); }; + /** + * Draws and shows the lineitem notes pane + */ this.drawLiNotes = function(li) { var self = this; @@ -245,6 +257,9 @@ function AcqLiTable() { dojo.forEach(li.lineitem_notes(), function(note) { self.addLiNote(li, note) }); } + /** + * Draws a single lineitem note in the notes pane + */ this.addLiNote = function(li, note) { if(note.isdeleted()) return; var self = this; @@ -266,6 +281,9 @@ function AcqLiTable() { self.liNotesTbody.appendChild(row); } + /** + * Updates any new/changed/deleted notes on the server + */ this.updateLiNotes = function(li, newNote) { var notes; diff --git a/Open-ILS/web/js/ui/default/acq/po/view_po.js b/Open-ILS/web/js/ui/default/acq/po/view_po.js index 10ff472df5..5d09dc9a87 100644 --- a/Open-ILS/web/js/ui/default/acq/po/view_po.js +++ b/Open-ILS/web/js/ui/default/acq/po/view_po.js @@ -22,6 +22,10 @@ function init() { dojo.byId('acq-po-view-total-li').innerHTML = PO.lineitem_count(); dojo.byId('acq-po-view-total-enc').innerHTML = PO.amount_encumbered(); dojo.byId('acq-po-view-total-spent').innerHTML = PO.amount_spent(); + dojo.byId('acq-po-view-state').innerHTML = PO.state(); // TODO i18n + + if(PO.state() == 'pending') + openils.Util.show('acq-po-activate'); } } ); @@ -38,6 +42,23 @@ function init() { ); } +function activatePo() { + progressDialog.show(true); + try { + fieldmapper.standardRequest( + ['open-ils.acq', 'open-ils.acq.purchase_order.activate'], + { async: true, + params: [openils.User.authtoken, PO.id()], + oncomplete : function() { + location.href = location.href; + } + } + ); + } catch(E) { + progressDialog.hide(); + } +} + function updatePoName() { var value = prompt('Enter new purchase order name:', PO.name()); // TODO i18n if(!value || value == PO.name()) return; diff --git a/Open-ILS/web/templates/default/acq/common/li_table.tt2 b/Open-ILS/web/templates/default/acq/common/li_table.tt2 index f317ff8d70..c1b79c3ef5 100644 --- a/Open-ILS/web/templates/default/acq/common/li_table.tt2 +++ b/Open-ILS/web/templates/default/acq/common/li_table.tt2 @@ -52,6 +52,7 @@ Items Notes + Status Price @@ -88,6 +89,7 @@ Notes(0) + diff --git a/Open-ILS/web/templates/default/acq/po/view.tt2 b/Open-ILS/web/templates/default/acq/po/view.tt2 index a5b6546ae6..4b7073a66a 100644 --- a/Open-ILS/web/templates/default/acq/po/view.tt2 +++ b/Open-ILS/web/templates/default/acq/po/view.tt2 @@ -8,10 +8,12 @@ - + + +
ID
Name
Name
Total Lineitems
Total Encumbered$
Total Spent$
Status
-- 2.11.0