1 /* ---------------------------------------------------------------------------
2 * Copyright (C) 2008 Georgia Public Library Service
3 * Bill Erickson <erickson@esilibrary.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * ---------------------------------------------------------------------------
17 if(!dojo._hasResource['openils.acq.PO']) {
19 dojo._hasResource['openils.acq.PO'] = true;
20 dojo.provide('openils.acq.PO');
21 dojo.require('fieldmapper.Fieldmapper');
22 dojo.require('fieldmapper.dojoData');
23 dojo.require('openils.Util');
25 /** Declare the PO class with dojo */
26 dojo.declare('openils.acq.PO', null, {
27 /* add instance methods here if necessary */
30 openils.acq.PO.cache = {};
32 openils.acq.PO.retrieve = function(id, oncomplete, args) {
34 var req = ['open-ils.acq', 'open-ils.acq.purchase_order.retrieve'];
35 var par = [openils.User.authtoken, id, args];
38 fieldmapper.standardRequest(
42 oncomplete:function(r) {
43 var po = openils.Util.extractResponse(r)
45 openils.acq.PO.cache[po.id()] = po;
52 return openils.acq.PO.cache[po.id()] =
53 fieldmapper.standardRequest(req, par);
57 openils.acq.PO.create = function(po, oncomplete) {
58 var req = ['open-ils.acq', 'open-ils.acq.purchase_order.create'];
59 var par = [openils.User.authtoken, po];
61 fieldmapper.standardRequest(
65 oncomplete: function(r) {
66 var po_id = r.recv().content();
68 openils.acq.PO.cache[po_id] = po;