]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/web/js/dojo/openils/acq/CurrencyType.js
LP#1350371 PO name on create w/ dupe detect
[working/Evergreen.git] / Open-ILS / web / js / dojo / openils / acq / CurrencyType.js
1 /* ---------------------------------------------------------------------------
2  * Copyright (C) 2008  Georgia Public Library Service
3  * Bill Erickson <erickson@esilibrary.com>
4  *
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.
9  *
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  * ---------------------------------------------------------------------------
15  */
16
17 if(!dojo._hasResource["openils.acq.CurrencyType"]) {
18
19     dojo._hasResource["openils.acq.CurrencyType"] = true;
20     dojo.provide("openils.acq.CurrencyType");
21     dojo.require('openils.User');
22     dojo.require('openils.Util');
23     dojo.require('openils.PermaCrud');
24
25     dojo.declare('openils.acq.CurrencyType', null, {
26     });
27
28     openils.acq.CurrencyType.cache = {};
29
30     /**
31      * Retrieves all of the currency types
32      */
33     openils.acq.CurrencyType.fetchAll = function(onComplete) {
34         var list = [];
35         var pcrud = new openils.PermaCrud();
36         pcrud.retrieveAll('acqct', {
37             async : true,
38             oncomplete : function(r) {
39                 var types = openils.Util.readResponse(r);
40                 for(var idx in types)
41                     openils.acq.CurrencyType.cache[types[idx].code()] = types[idx];
42                 onComplete(types);
43             }
44         });
45     };
46
47     openils.acq.CurrencyType.loadSelectWidget = function(selector) {
48         openils.acq.CurrencyType.fetchAll(
49             function(ctypes) {
50                 selector.store = new dojo.data.ItemFileReadStore(
51                     {data:acqct.toStoreData(ctypes, 'code', {identifier:'code'})});
52                 selector.setValue(ctypes[0].code()); /* XXX get from setting */
53             }
54         );
55     };
56 }
57