[open-ils-commits] r13964 - in trunk/Open-ILS: src/perlmods/OpenILS/Application/Acq web/js/ui/default/acq/common web/js/ui/default/acq/po web/templates/default/acq/common web/templates/default/acq/po (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Sep 4 15:26:12 EDT 2009
Author: erickson
Date: 2009-09-04 15:26:08 -0400 (Fri, 04 Sep 2009)
New Revision: 13964
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm
trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js
trunk/Open-ILS/web/js/ui/default/acq/po/view_po.js
trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2
trunk/Open-ILS/web/templates/default/acq/po/view.tt2
Log:
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'
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm 2009-09-04 17:26:25 UTC (rev 13963)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm 2009-09-04 19:26:08 UTC (rev 13964)
@@ -683,6 +683,7 @@
$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 @@
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 @@
$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 @@
+__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;
Modified: trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js 2009-09-04 17:26:25 UTC (rev 13963)
+++ trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js 2009-09-04 19:26:08 UTC (rev 13964)
@@ -155,6 +155,10 @@
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 @@
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 @@
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 @@
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 @@
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 @@
self.liNotesTbody.appendChild(row);
}
+ /**
+ * Updates any new/changed/deleted notes on the server
+ */
this.updateLiNotes = function(li, newNote) {
var notes;
Modified: trunk/Open-ILS/web/js/ui/default/acq/po/view_po.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/po/view_po.js 2009-09-04 17:26:25 UTC (rev 13963)
+++ trunk/Open-ILS/web/js/ui/default/acq/po/view_po.js 2009-09-04 19:26:08 UTC (rev 13964)
@@ -22,6 +22,10 @@
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 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;
Modified: trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2 2009-09-04 17:26:25 UTC (rev 13963)
+++ trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2 2009-09-04 19:26:08 UTC (rev 13964)
@@ -52,6 +52,7 @@
<td></td>
<td>Items</td>
<td>Notes</td>
+ <td>Status</td>
<td>Price</td>
</tr>
</tbody>
@@ -88,6 +89,7 @@
<a name='noteslink' href='javascript:void(0);'
style='margin-right:15px;'>Notes(<span name='notes_count'>0</span>)</a>
</td>
+ <td><span name='li_state'></span></td>
<td><input type='text' size='8' name='price'/></td>
</tr>
</tbody>
Modified: trunk/Open-ILS/web/templates/default/acq/po/view.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/acq/po/view.tt2 2009-09-04 17:26:25 UTC (rev 13963)
+++ trunk/Open-ILS/web/templates/default/acq/po/view.tt2 2009-09-04 19:26:08 UTC (rev 13964)
@@ -8,10 +8,12 @@
</div>
<table class='oils-generic-table'>
<tr><td>ID</td><td><a id='acq-po-view-id'/></td></tr>
- <tr><td>Name</td><td><a id='acq-po-view-name' href='javascript:void(0);' onclick='updatePoName()'/></td></tr>
+ <tr><td>Name</td><td><a id='acq-po-view-name' href='javascript:void(0);' onclick='updatePoName()'></a></td></tr>
<tr><td>Total Lineitems</td><td><span id='acq-po-view-total-li'/></td></tr>
<tr><td>Total Encumbered</td><td>$<span id='acq-po-view-total-enc'/></td></tr>
<tr><td>Total Spent</td><td>$<span id='acq-po-view-total-spent'/></td></tr>
+ <tr><td>Status</td><td><span id='acq-po-view-state'/></td></tr>
+ <tr><td><a class='hidden' id='acq-po-activate' href='javascript:void(0);' onclick='activatePo()'>Activate Order</a></td></tr>
</table>
</div>
</div>
More information about the open-ils-commits
mailing list