<link field="order_summary" reltype="might_have" key="lineitem" map="" class="acqlisum"/>
</links>
<permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
- <retrieve permission="CREATE_PURCHASE_ORDER VIEW_PURCHASE_ORDER CREATE_PICKLIST VIEW_PICKLIST">
- <context link="purchase_order" field="ordering_agency"/>
- <context link="picklist" field="org_unit"/>
- </retrieve>
+ <actions>
+ <retrieve permission="CREATE_PURCHASE_ORDER VIEW_PURCHASE_ORDER CREATE_PICKLIST VIEW_PICKLIST">
+ <context link="purchase_order" field="ordering_agency"/>
+ <context link="picklist" field="org_unit"/>
+ </retrieve>
+ </actions>
</permacrud>
</class>
<link field="claim_policy" reltype="has_a" key="id" map="" class="acqclp"/>
</links>
<permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
- <retrieve permission="CREATE_PURCHASE_ORDER VIEW_PURCHASE_ORDER">
- <context link="purchase_order" field="ordering_agency"/>
- <context link="picklist" field="org_unit"/>
- </retrieve>
+ <actions>
+ <retrieve permission="CREATE_PURCHASE_ORDER VIEW_PURCHASE_ORDER">
+ <context link="purchase_order" field="ordering_agency"/>
+ <context link="picklist" field="org_unit"/>
+ </retrieve>
+ </actions>
</permacrud>
</class>
$li->picklist->org_unit, $li->picklist)
);
- $li->clear_purchase_order unless $$options{flesh_po};
- $li->clear_picklist unless $$options{flesh_pl};
+ unless ($$options{flesh_po}) {
+ $li->purchase_order(
+ $li->purchase_order ? $li->purchase_order->id : undef
+ );
+ }
+ unless ($$options{flesh_pl}) {
+ $li->picklist($li->picklist ? $li->picklist->id : undef);
+ }
return $li;
}
method => 'update_lineitem',
api_name => 'open-ils.acq.lineitem.update',
signature => {
- desc => 'Update a lineitem',
+ desc => 'Update one or many lineitems',
params => [
{desc => 'Authentication token', type => 'string'},
{desc => 'lineitem object update', type => 'object'}
my($self, $conn, $auth, $li) = @_;
my $e = new_editor(xact=>1, authtoken=>$auth);
return $e->die_event unless $e->checkauth;
- my $evt = update_lineitem_impl($e, $li);
- return $evt if $evt;
+
+ $li = [$li] unless ref $li eq "ARRAY";
+ foreach (@$li) {
+ my $evt = update_lineitem_impl($e, $_);
+ return $evt if $evt;
+ }
+
$e->commit;
return 1;
}
]) or return $e->die_event;
# the marc may have been cleared on retrieval...
- $li->marc($e->retrieve_acq_lineitem($li->id)->marc)
- unless $li->marc;
+ $li->marc($orig_li->marc) unless $li->marc;
$li->editor($e->requestor->id);
$li->edit_time('now');
'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"
+ 'PRINT': "Print",
+ 'ATTACH_CLAIM_POLICY': "Attach claim policy",
+ 'CHANGE_CLAIM_POLICY': "Change claim policy"
}
td.appendChild(document.createTextNode(val));
};
+ this.setClaimPolicyControl = function(li, row) {
+ if (!self.claimPolicyPicker) {
+ self.claimPolicyPicker = true; /* prevents a race condition */
+ new openils.widget.AutoFieldWidget({
+ "parentNode": "acq-lit-li-claim-policy",
+ "fmClass": "acqclp",
+ "selfReference": true,
+ "dijitArgs": {"required": true}
+ }).build(function(w) { self.claimPolicyPicker = w; });
+ }
+
+ if (typeof(row) == "undefined")
+ row = dojo.query('tr[li="' + li.id() + '"]', "acq-lit-tbody")[0];
+
+ var actViewPolicy = nodeByName("action_view_claim_policy", row);
+ if (li.claim_policy())
+ actViewPolicy.innerHTML = localeStrings.CHANGE_CLAIM_POLICY;
+
+ if (!actViewPolicy.onclick) {
+ actViewPolicy.onclick = function() {
+ if (li.claim_policy())
+ self.claimPolicyPicker.attr("value", li.claim_policy());
+ liClaimPolicyDialog.show();
+ liClaimPolicySave.onClick = function() {
+ self.changeClaimPolicy(
+ [li], self.claimPolicyPicker.attr("value"),
+ function() {
+ self.setClaimPolicyControl(li, row);
+ liClaimPolicyDialog.hide();
+ }
+ );
+ }
+ };
+ }
+ };
+
/**
* Inserts a single lineitem into the growing table of lineitems
* @param {Object} li The lineitem object to insert
this.updateLiNotesCount(li, row);
- if (li.claim_policy()) {
- var actViewInvoice = nodeByName("action_view_claim_policy", row);
- actViewInvoice.disabled = false;
- actViewInvoice.onclick = function() {
- location.href = oilsBasePath + "/conify/global/acq/claim_policy/" +
- li.claim_policy();
- };
- }
+ this.setClaimPolicyControl(li, row);
// show which PO this lineitem is a member of
if(li.purchase_order() && !this.isPO) {
case "cancel_lineitems":
this.maybeCancelLineitems();
break;
+
+ case "change_claim_policy":
+ var li_list = this.getSelected();
+ this.claimPolicyPicker.attr("value", null);
+ liClaimPolicyDialog.show();
+ liClaimPolicySave.onClick = function() {
+ self.changeClaimPolicy(
+ li_list,
+ self.claimPolicyPicker.attr("value"),
+ function() {
+ li_list.forEach(
+ function(li) { self.setClaimPolicyControl(li); }
+ );
+ liClaimPolicyDialog.hide();
+ }
+ )
+ };
+ break;
}
}
+ this.changeClaimPolicy = function(li_list, value, callback) {
+ li_list.forEach(
+ function(li) { li.claim_policy(value); }
+ );
+ fieldmapper.standardRequest(
+ ["open-ils.acq", "open-ils.acq.lineitem.update"], {
+ "params": [openils.User.authtoken, li_list],
+ "async": true,
+ "oncomplete": function(r) {
+ r = openils.Util.readResponse(r);
+ if (callback) callback(r);
+ }
+ }
+ );
+ };
+
this.createAssets = function() {
if(!this.isPO) return;
if(!confirm(localeStrings.CREATE_PO_ASSETS_CONFIRM)) return;
<option mask='sr|pl' value='create_order'>Create Purchase Order</option>
<option mask='po' value='create_assets'>Load Bibs and Items</option>
<option mask='po' value='cancel_lineitems'>Cancel Selected Lineitems</option>
+ <option mask='po' value='change_claim_policy'>Change Claim Policy</option>
<option mask='po' value='receive_po'>Mark Purchase Order as Received</option>
<option mask='po' value='rollback_receive_po'>Un-Receive Purchase Order</option>
<option mask='po' value='print_po'>Print Purchase Order</option>
<td style='width:70%;font-weight:bold;'>
<a attr='title' href='javascript:void(0);'></a>
<span name="worksheet">(<a name="worksheet_link" href="javascript:void(0);">✍</a>)</span>
- <span name="claim_policy" class="hidden">(Claim Policy: <a name="claim_policy_link" href="javascript:void(0);"></a>)</span>
<span name='pl' class='hidden'>(<a name='pl_link' href='javascript:void(0);'></a>)</span>
<span name='po' class='hidden'>(<a name='po_link' href='javascript:void(0);'>PO</a>)</span>
</td>
<option name='action_new_invoice' disabled='disabled'>New Invoice</option>
<option name='action_link_invoice' disabled='disabled'>Link to Invoice</option>
<option name='action_view_invoice' disabled='disabled'>View Invoice(s)</option>
- <option name='action_view_claim_policy' disabled='disabled'>View Claim Policy</option>
+ <option name='action_view_claim_policy'>Apply Claim Policy</option>
</select>
</td>
<td><span name='li_state'></span></td>
<span dojoType="dijit.form.Button"
jsId="acqLidCancelButton">Cancel Copy</span>
</div>
+ <div dojoType="dijit.Dialog" jsId="liClaimPolicyDialog">
+ <label for="acq-lit-li-claim-policy">Claim policy:</label>
+ <span id="acq-lit-li-claim-policy"></span>
+ <span dojoType="dijit.form.Button"
+ jsId="liClaimPolicySave">Save</span>
+ </div>
</div>
<div dojoType="dijit.Dialog" jsId='acqLitChangeLiStateDialog'>