]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/patron/items.js
saving initial user groups
[Evergreen.git] / Open-ILS / xul / staff_client / server / patron / items.js
1 dump('entering patron.items.js\n');
2
3 if (typeof patron == 'undefined') patron = {};
4 patron.items = function (params) {
5
6         JSAN.use('util.error'); this.error = new util.error();
7         JSAN.use('util.network'); this.network = new util.network();
8         this.OpenILS = {}; JSAN.use('OpenILS.data'); this.OpenILS.data = new OpenILS.data(); this.OpenILS.data.init({'via':'stash'});
9 }
10
11 patron.items.prototype = {
12
13         'init' : function( params ) {
14
15                 var obj = this;
16
17                 obj.session = params['session'];
18                 obj.patron_id = params['patron_id'];
19
20                 JSAN.use('circ.util');
21                 var columns = circ.util.columns( 
22                         { 
23                                 'title' : { 'hidden' : false, 'flex' : '3' },
24                                 'due_date' : { 'hidden' : false },
25                                 'renewal_remaining' : { 'hidden' : false },
26                         } 
27                 );
28
29                 JSAN.use('util.list'); obj.list = new util.list('items_list');
30                 obj.list.init(
31                         {
32                                 'columns' : columns,
33                                 'map_row_to_column' : circ.util.std_map_row_to_column(),
34                         }
35                 );
36                 
37                 JSAN.use('util.controller'); obj.controller = new util.controller();
38                 obj.controller.init(
39                         {
40                                 'control_map' : {
41                                         'cmd_broken' : [
42                                                 ['command'],
43                                                 function() { alert('Not Yet Implemented'); }
44                                         ],
45                                         'cmd_item_print' : [
46                                                 ['command'],
47                                                 function() {
48                                                 }
49                                         ],
50                                         'cmd_item_reprint' : [
51                                                 ['command'],
52                                                 function() {
53                                                 }
54                                         ],
55                                 }
56                         }
57                 );
58
59                 obj.retrieve();
60
61         },
62
63         'retrieve' : function() {
64                 var obj = this;
65                 if (window.xulG && window.xulG.checkouts) {
66                         obj.checkouts = window.xulG.checkouts;
67                 } else {
68                         obj.checkouts = obj.network.request(
69                                 api.blob_checkouts_retrieve.app,
70                                 api.blob_checkouts_retrieve.method,
71                                 [ obj.session, obj.patron_id ]
72                         );
73                                 
74                 }
75
76                 function gen_list_append(checkout) {
77                         return function() {
78                                 obj.list.append(
79                                         {
80                                                 'row' : {
81                                                         'my' : {
82                                                                 'circ' : checkout.circ,
83                                                                 'mvr' : checkout.record,
84                                                                 'acp' : checkout.copy
85                                                         }
86                                                 }
87                                         }
88                                 );
89                         };
90                 }
91
92                 JSAN.use('util.exec'); var exec = new util.exec();
93                 var rows = [];
94                 for (var i in obj.checkouts) {
95                         rows.push( gen_list_append(obj.checkouts[i]) );
96                 }
97                 exec.chain( rows );
98         },
99 }
100
101 dump('exiting patron.items.js\n');