From: senator Date: Fri, 23 Apr 2010 20:53:11 +0000 (+0000) Subject: Acq: more work on the claiming UI. It begins to be workable, but still rough. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=17065dfab6f8531ab8de02830886b3acaa433e9b;p=contrib%2FConifer.git Acq: more work on the claiming UI. It begins to be workable, but still rough. Definitely still have to fix at least these things: Changes to lineitems' claim policies and initiation of claims against LIs aren't reflected in realtime in the LI table. You still need a reload for that so far. The "Consider individual copies for claiming" needs to take you to the speicific lineitems' claim copies dialog, not just to the PO in general. git-svn-id: svn://svn.open-ils.org/ILS/trunk@16290 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 9afdd90bbe..23c156557a 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -5590,6 +5590,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + @@ -5600,6 +5601,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Claims.pm b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Claims.pm index bffb25c51e..0873fa373c 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Claims.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Claims.pm @@ -96,8 +96,10 @@ __PACKAGE__->register_method( created. This is an array of acqclpa IDs./, type => "array"}, ], - return => {desc => "The claim events on success, Event on error", - type => "object", class => "acrlid"} + return => { + desc => "The claim voucher events on success, Event on error", + type => "object", class => "acrlid" + } } ); @@ -122,7 +124,10 @@ __PACKAGE__->register_method( type => 'array' }, ], - return => {desc => 'The claim events on success, Event on error', type => 'object', class => 'acrlid'} + return => { + desc => "The claim voucher events on success, Event on error", + type => "object", class => "acrlid" + } } ); @@ -165,12 +170,17 @@ sub claim_item { } if($self->api_name =~ /claim.lineitem_detail/) { - - my $lid = $e->retrieve_acq_lineitem_detail([$object_id, $lid_flesh]) or - return $e->die_event; - return $evt if - $evt = claim_lineitem_detail( - $e, $lid, $claim, $claim_type, $policy_actions, $note, $claim_events); + my $lids = $e->search_acq_lineitem_detail([ + {"id" => $object_id, "cancel_reason" => undef}, + $lid_flesh + ]) or return $e->die_event; + foreach my $lid (@$lids) { + return $evt if + $evt = claim_lineitem_detail( + $e, $lid, $claim, $claim_type, $policy_actions, + $note, $claim_events + ); + } } elsif($self->api_name =~ /claim.lineitem/) { my $lids = $e->search_acq_lineitem_detail([ diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm index fe5e8b95df..c504769a3c 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm @@ -131,6 +131,19 @@ sub retrieve_lineitem_impl { $li->item_count(scalar(@$details)); } + # attach claims to LIDs + if($$options{flesh_li_details}) { + foreach (@{$li->lineitem_details}) { + $_->claims( + $e->search_acq_claim([ + {"lineitem_detail", $_->id}, { + "flesh" => 1, "flesh_fields" => {"acqcl" => ["type"]} + } + ]) + ); + } + } + return $e->event unless ( $li->purchase_order and $e->allowed(['VIEW_PURCHASE_ORDER', 'CREATE_PURCHASE_ORDER'], diff --git a/Open-ILS/web/css/skin/default/acq.css b/Open-ILS/web/css/skin/default/acq.css index 0a3836892a..896aa1114a 100644 --- a/Open-ILS/web/css/skin/default/acq.css +++ b/Open-ILS/web/css/skin/default/acq.css @@ -163,6 +163,7 @@ label[for="attr_search_type_scalar"] { vertical-align: top; } .acq-lit-table-spacer { height:20px; } .acq-lit-row td[name="selector"] { width:1.5em; font-weight:bold; color:blue; font-size:110%;} span[name="worksheet"] { padding: 0 6px; } +#acq-lit-li-claim-dia-lid-list-init { margin-left: 8px; } #acq-worksheet-contents thead th { font-weight: bold; background-color: #ccc; text-align: center; border-bottom: 1px #000 solid; border-right: 1px #000 solid; padding: 0 6px; } #acq-worksheet-contents tbody td { text-align: left; vertical-align: top; border: 1px #999 inset; padding: 0 2px; } diff --git a/Open-ILS/web/js/dojo/openils/acq/nls/acq.js b/Open-ILS/web/js/dojo/openils/acq/nls/acq.js index 6918435087..b21b999777 100644 --- a/Open-ILS/web/js/dojo/openils/acq/nls/acq.js +++ b/Open-ILS/web/js/dojo/openils/acq/nls/acq.js @@ -70,8 +70,10 @@ 'UNNAMED': "Unnamed", 'NO_FIND_INVOICE': "Could not find that invoice.\nNote that the Invoice # field is case-sensitive.", 'NO_LI_TO_CLAIM': "You have not selected any lineitems to claim.", - 'CLAIM_VOUCHERS': "Claim Vouchers", - 'PRINT': "Print", - 'ATTACH_CLAIM_POLICY': "Attach claim policy", - 'CHANGE_CLAIM_POLICY': "Change claim policy" + 'NO_LID_TO_CLAIM': "You have not selected any lineitem details to claim.", + 'CHANGE_CLAIM_POLICY': "Change claim policy", + 'CANCELED': "Canceled", + 'RECVD': "Recv'd", + 'NOT_RECVD': "Not recv'd", + 'PRINT': "Print" } diff --git a/Open-ILS/web/js/ui/default/acq/common/claim_dialog.js b/Open-ILS/web/js/ui/default/acq/common/claim_dialog.js new file mode 100644 index 0000000000..b13edfd981 --- /dev/null +++ b/Open-ILS/web/js/ui/default/acq/common/claim_dialog.js @@ -0,0 +1,206 @@ +function ClaimDialogManager(dialog, finalDialog, eligibleLidByLi) { + var self = this; + + this.anyLids = false; + this.anyEligible = false; + this.showingLidNodes = {}; + + this.dialog = dialog; + this.finalDialog = finalDialog; + this.eligibleLidByLi = eligibleLidByLi; + + this.showingList = dojo.byId("acq-lit-li-claim-dia-lid-list"); + this.eligibleList = dojo.byId("acq-lit-li-claim-dia-lid-list-init"); + + this.showingLidTemplate = this.showingList.removeChild( + nodeByName("lid", this.showingList) + ); + this.showingClaimTemplate = + nodeByName("claims", this.showingLidTemplate).removeChild( + nodeByName("claim", this.showingLidTemplate) + ); + this.eligibleTemplate = this.eligibleList.removeChild( + nodeByName("lid_to_claim", this.eligibleList) + ); + + dojo.byId("acq-lit-li-claim-dia-claim").onclick = function() { + var lid_ids = self.getSelectedEligible(); + if (lid_ids.length) { + dojo.byId("acq-eligible-claim-submit").onclick = function() { + self.finalDialog.hide(); + self.claim(lid_ids); + }; + self.dialog.hide(); + self.finalDialog.show(); + } + else { + alert(localeStrings.NO_LID_TO_CLAIM); + } + }; + + new openils.widget.AutoFieldWidget({ + "fmClass": "acqclt", + "selfReference": true, + "dijitArgs": {"required": true}, + "parentNode": dojo.byId("acq-eligible-claim-type") + }).build(function(w) { self.claimType = w; }); + + this.reset = function(li) { + this.anyLids = false; + this.showingLidNodes = {}; + + openils.Util.hide("acq-lit-li-claim-dia-initiate"); + openils.Util.hide("acq-lit-li-claim-dia-show"); + + dojo.empty(this.showingList); + dojo.empty(this.eligibleList); + }; + + this.show = function(li) { + this.reset(); + this.prepare(li); + this.dialog.show(); + }; + + this.hide = function() { this.dialog.hide(); }; + + this.prepare = function(li) { + dojo.byId("acq-lit-li-claim-dia-li-title").innerHTML = + li.attributes().filter( + function(o) { return Boolean(o.attr_name() == "title"); } + )[0].attr_value(); + dojo.byId("acq-lit-li-claim-dia-li-id").innerHTML = li.id(); + + li.lineitem_details().forEach( + function(lid) { + lid.claims().forEach( + function(claim) { self.addClaim(lid, claim); } + ); + if (self.eligibleLidByLi[li.id()].indexOf(lid.id()) != -1) { + self.addEligible(lid); + } + } + ); + }; + + this._reprReceived = function(lid) { + if (lid.cancel_reason()) + return localeStrings.CANCELED + ": " + lid.cancel_reason().label(); + else if (lid.recv_time()) + return localeStrings.RECVD + " " + lid.recv_time(); + else + return localeStrings.NOT_RECVD; + }; + + this.addClaim = function(lid, claim) { + if (!this.anyLids) + openils.Util.show("acq-lit-li-claim-dia-show"); + this.anyLids = true; + + var lidNode = this.showingLidNodes[lid.id()]; + if (!lidNode) { + lidNode = dojo.clone(this.showingLidTemplate); + nodeByName("barcode", lidNode).innerHTML = lid.barcode(); + nodeByName("recvd", lidNode).innerHTML = this._reprReceived(lid); + + this.showingLidNodes[lid.id()] = lidNode; + dojo.place(lidNode, this.showingList, "last"); + } + + var claimNode = dojo.clone(this.showingClaimTemplate); + nodeByName("type", claimNode).innerHTML = claim.type().code(); + nodeByName("voucher", claimNode).onclick = function() { + alert("unimplemented"); // XXX + // TODO For some reason, the format.acqcle.html events that get + // fired by claim_item() in Claims.pm don't stick around in + // the database. Must find out why and fix this before writing + // the ML method that the following code would call. + /* + var win; + fieldmapper.standardRequest( + ["open-ils.acq", "open-ils.acq.claim.get_format_events"], { + "params": [openils.User.authtoken, lid.id()], + "async": true, + "onresponse": function(r) { + if (r = openils.Util.readResponse(r)) { + if (!win) + win = openClaimVoucherWindow(); + } + dojo.byId("main", win.document).innerHTML += + (contents + "
"); + }, + "oncomplete": function() { + var print_button = dojo.byId("print", win.document); + print_button.innerHTML = localeStrings.PRINT; + print_button.disabled = false; + } + } + ); + */ + }; + + dojo.place( + claimNode, nodeByName("claims", lidNode), "last" + ); + }; + + this.addEligible = function(lid) { + if (!this.anyEligible) + openils.Util.show("acq-lit-li-claim-dia-initiate"); + this.anyEligible = true; + + var eligibleNode = dojo.clone(this.eligibleTemplate); + nodeByName("claimable_lid", eligibleNode).value = lid.id(); + dojo.attr( + nodeByName("claimable_lid", eligibleNode), + "id", "claim-lid-" + lid.id() + ); + dojo.attr( + nodeByName("claimable_lid_label", eligibleNode), + "for", "claim-lid-" + lid.id() + ); + nodeByName("barcode", eligibleNode).innerHTML = lid.barcode(); + nodeByName("recvd", eligibleNode).innerHTML = this._reprReceived(lid); + + dojo.place(eligibleNode, this.eligibleList, "last"); + }; + + this.getSelectedEligible = function() { + return dojo.query("input[name='claimable_lid']", this.eligibleList). + filter(function(o) { return o.checked; }). + map(function(o) { return o.value; }); + }; + + this.claim = function(lid_ids) { + progressDialog.show(true); + var win = null; + + fieldmapper.standardRequest( + ["open-ils.acq", "open-ils.acq.claim.lineitem_detail"], { + "params": [ + openils.User.authtoken, lid_ids, null, + this.claimType.attr("value"), + dijit.byId("acq-eligible-claim-note").attr("value") + ], + "async": true, + "onresponse": function(r) { + if (r = openils.Util.readResponse(r)) { + if (!win) + win = openClaimVoucherWindow(); + dojo.byId("main", win.document).innerHTML += + (r.template_output().data() + "
"); + } + else { + progressDialog.hide(); + } + }, + "oncomplete": function() { + progressDialog.hide(); + dojo.byId("print", win.document).innerHTML = + localeStrings.PRINT; + dojo.byId("print", win.document).disabled = false; + } + } + ); + }; +} 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 57160bb209..55b8284994 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 @@ -49,6 +49,7 @@ function AcqLiTable() { this.virtDfaCounts = {}; this.virtDfaId = -1; this.dfeOffset = 0; + this.claimEligibleLidByLi = {}; this.toggleState = false; this.tbody = dojo.byId('acq-lit-tbody'); this.selectors = []; @@ -66,6 +67,9 @@ function AcqLiTable() { this.realCopiesRow = this.realCopiesTbody.removeChild(dojo.byId('acq-lit-real-copies-row')); this._copy_fields_for_acqdf = ['owning_lib', 'location']; this.invoiceLinkDialogManager = new InvoiceLinkDialogManager("li"); + this.claimDialog = new ClaimDialogManager( + liClaimDialog, finalClaimDialog, this.claimEligibleLidByLi + ); dojo.connect(acqLitLiActionsSelector, 'onChange', function() { @@ -254,6 +258,16 @@ function AcqLiTable() { dojo.query('[name=copieslink]', row)[0].onclick = function() {self.drawCopies(li.id())}; dojo.query('[name=noteslink]', row)[0].onclick = function() {self.drawLiNotes(li)}; + /* XXX note how checkClaimEligibility() is getting called once per LI + * when in some use cases we should be able to do that job with one + * call per PO or per PL or whatever... */ + this._fetchLineitem( + li.id(), function(full) { + self.liCache[full.id()] = full; + self.checkClaimEligibility(full, row); + } + ); + this.updateLiNotesCount(li, row); this.setClaimPolicyControl(li, row); @@ -319,6 +333,49 @@ function AcqLiTable() { } }; + this._liCountClaims = function(li) { + var total = 0; + for (var i = 0; i < li.lineitem_details().length; i++) + total += li.lineitem_details()[i].claims().length; + return total; + }; + + this.reconsiderClaimControl = function(li, row) { + var option = nodeByName("action_manage_claims", row); + var eligible = this.claimEligibleLidByLi[li.id()].length; + var count = this._liCountClaims(li); + + option.disabled = !(count || eligible); + + /* of course I'd rather just populate a element inside the + * option element, but it seems you can't actually have any elements + * inside option elements */ + option.innerHTML = option.innerHTML.replace( + /(^.+)(.*)( existing.+$)/, "$1" + String(count) + "$3" + ); + option.onclick = function() { self.claimDialog.show(li); }; + }; + + this.checkClaimEligibility = function(li, row) { + this.claimEligibleLidByLi[li.id()] = []; + fieldmapper.standardRequest( + ["open-ils.acq", "open-ils.acq.claim.eligible.lineitem_detail"], { + "params": [openils.User.authtoken, {"lineitem": li.id()}], + "async": true, + "onresponse": function(r) { + if (r = openils.Util.readResponse(r)) { + self.claimEligibleLidByLi[li.id()].push( + r.lineitem_detail() + ); + } + }, + "oncomplete": function() { + self.reconsiderClaimControl(li, row); + } + } + ); + }; + this.updateLiNotesCount = function(li, row) { if (typeof(row) == "undefined") row = dojo.query('tr[li="' + li.id() + '"]', "acq-lit-tbody")[0]; diff --git a/Open-ILS/web/js/ui/default/acq/financial/claim_eligible.js b/Open-ILS/web/js/ui/default/acq/financial/claim_eligible.js index c98936535b..500ce20589 100644 --- a/Open-ILS/web/js/ui/default/acq/financial/claim_eligible.js +++ b/Open-ILS/web/js/ui/default/acq/financial/claim_eligible.js @@ -53,6 +53,22 @@ function EligibleLiTable(filter) { } ); + dojo.byId("acq-eligible-claim-submit").onclick = function() { + finalClaimDialog.hide(); + self.claim(self.getSelected()); + }; + + dojo.query("button[name='claim_submit']").forEach( + function(button) { + button.onclick = function() { + if (self.getSelected().length) + finalClaimDialog.show(); + else + alert(localeStrings.NO_LI_TO_CLAIM); + }; + } + ); + this.showEmpty = function() { dojo.place(dojo.clone(this.emptyTemplate), this.tBody, "only"); openils.Util.hide("acq-eligible-claim-controls"); @@ -147,29 +163,19 @@ function EligibleLiTable(filter) { this.resetVoucher = function() { this.voucherWin = null; }; this.addToVoucher = function(contents) { - if (!this.voucherWin) { - this.voucherWin = window.open( - "", "", "resizable,width=800,height=600,scrollbars=1" - ); - this.voucherWin.document.title = localeStrings.CLAIM_VOUCHERS; - this.voucherWin.document.body.innerHTML = ( - "
" - ); - } - dojo.byId("main", this.voucherWin.document).innerHTML += ( - contents + "
" - ); + if (!this.voucherWin) + this.voucherWin = openClaimVoucherWindow(); + dojo.byId("main", this.voucherWin.document).innerHTML += + (contents + "
"); }; - this.claim = function() { - var lineitems = this.getSelected(); - if (!lineitems.length) { - alert(localeStrings.NO_LI_TO_CLAIM); - return; - } + this.finishVoucher = function() { + var print_btn = dojo.byId("print", this.voucherWin.document); + print_btn.disabled = false; + print_btn.innerHTML = localeStrings.PRINT; + }; + this.claim = function(lineitems) { progressDialog.show(true); self.resetVoucher(); @@ -192,6 +198,8 @@ function EligibleLiTable(filter) { ); if (!nodeByName("selector", self.tBody)) // emptiness test self.showEmpty(); + + self.finishVoucher(); progressDialog.hide(); } } diff --git a/Open-ILS/web/js/ui/default/acq/financial/claim_voucher.js b/Open-ILS/web/js/ui/default/acq/financial/claim_voucher.js new file mode 100644 index 0000000000..c6191f84dc --- /dev/null +++ b/Open-ILS/web/js/ui/default/acq/financial/claim_voucher.js @@ -0,0 +1,22 @@ +function openClaimVoucherWindow() { + var win = window.open( + "", "", "resizable,width=800,height=600,scrollbars=1" + ); + /* XXX i18n - also, the reason this isn't loaded from a server-side page + * has to do with problems of knowing when the page has loaded, so we + * can begin maniuplating it. we could retrieve content with an xhr call + * though... + */ + win.document.title = "Claim Voucher"; + win.document.body.innerHTML = + '

Claim Voucher

' + + '
' + + '' + + '
' + + '
' + + '
' + ; + return win; +}; diff --git a/Open-ILS/web/templates/default/acq/common/claim_dialog.tt2 b/Open-ILS/web/templates/default/acq/common/claim_dialog.tt2 new file mode 100644 index 0000000000..edc9aa111e --- /dev/null +++ b/Open-ILS/web/templates/default/acq/common/claim_dialog.tt2 @@ -0,0 +1,39 @@ +
+ +
Claims
+
Against item: + + () +
+ + +
diff --git a/Open-ILS/web/templates/default/acq/common/final_claim_dialog.tt2 b/Open-ILS/web/templates/default/acq/common/final_claim_dialog.tt2 new file mode 100644 index 0000000000..882741cb6d --- /dev/null +++ b/Open-ILS/web/templates/default/acq/common/final_claim_dialog.tt2 @@ -0,0 +1,8 @@ +
+ + + + + +
+ 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 de3d0c8c1d..627286e07d 100644 --- a/Open-ILS/web/templates/default/acq/common/li_table.tt2 +++ b/Open-ILS/web/templates/default/acq/common/li_table.tt2 @@ -1,5 +1,6 @@ +
- -   - Save + +   + Save +
+
+ [% INCLUDE "default/acq/common/claim_dialog.tt2" %] +
+
+ [% INCLUDE "default/acq/common/final_claim_dialog.tt2" %]
diff --git a/Open-ILS/web/templates/default/acq/financial/claim_eligible.tt2 b/Open-ILS/web/templates/default/acq/financial/claim_eligible.tt2 index 8232f7f3ff..fa8a40f069 100644 --- a/Open-ILS/web/templates/default/acq/financial/claim_eligible.tt2 +++ b/Open-ILS/web/templates/default/acq/financial/claim_eligible.tt2 @@ -4,6 +4,9 @@ +

Items Eligible For Claiming

@@ -15,6 +18,9 @@
+
+ +
@@ -43,12 +49,13 @@
- + [% END %]