]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/patron/items.js
stub out items Claims Returned
[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                                 'retrieve_row' : function(params) {
34
35                                         var row = params.row;
36
37                                         var funcs = [
38                                                 
39                                                 function() {
40
41                                                         row.my.mvr = obj.network.request(
42                                                                 api.mods_slim_record_retrieve_via_copy.app,
43                                                                 api.mods_slim_record_retrieve_via_copy.method,
44                                                                 [ row.my.circ.target_copy() ]
45                                                         );
46
47                                                 },
48                                                 
49                                                 function() {
50
51
52                                                         row.my.acp = obj.network.request(
53                                                                 api.fm_acp_retrieve.app,
54                                                                 api.fm_acp_retrieve.method,
55                                                                 [ obj.session, row.my.circ.target_copy() ]
56                                                         );
57
58                                                 },
59
60                                                 function() {
61
62                                                         if (typeof params.on_retrieve == 'function') {
63                                                                 params.on_retrieve(row);
64                                                         }
65
66                                                 },
67                                         ];
68
69                                         JSAN.use('util.exec'); var exec = new util.exec();
70                                         exec.on_error = function(E) {
71                                                 //var err = 'items chain: ' + js2JSON(E);
72                                                 //obj.error.sdump('D_ERROR',err);
73                                                 return true; /* keep going */
74                                         }
75                                         exec.chain( funcs );
76
77                                         return row;
78                                 },
79                                 'map_row_to_column' : circ.util.std_map_row_to_column(),
80                         }
81                 );
82                 
83                 JSAN.use('util.controller'); obj.controller = new util.controller();
84                 obj.controller.init(
85                         {
86                                 'control_map' : {
87                                         'cmd_broken' : [
88                                                 ['command'],
89                                                 function() { alert('Not Yet Implemented'); }
90                                         ],
91                                         'cmd_item_print' : [
92                                                 ['command'],
93                                                 function() {
94                                                 }
95                                         ],
96                                         'cmd_item_claimed_returned' : [
97                                                 ['command'],
98                                                 function() {
99                                                 }
100                                         ],
101                                         'cmd_item_renew' : [
102                                                 ['command'],
103                                                 function() {
104                                                 }
105                                         ],
106                                         'cmd_item_checkin' : [
107                                                 ['command'],
108                                                 function() {
109                                                 }
110                                         ],
111                                         'cmd_show_catalog' : [
112                                                 ['command'],
113                                                 function() {
114                                                 }
115                                         ],
116                                 }
117                         }
118                 );
119
120                 obj.retrieve();
121
122         },
123
124         'retrieve' : function() {
125                 var obj = this;
126                 if (window.xulG && window.xulG.checkouts) {
127                         obj.checkouts = window.xulG.checkouts;
128                 } else {
129                         obj.checkouts = obj.network.request(
130                                 api.fm_circ_retrieve_via_user.app,
131                                 api.fm_circ_retrieve_via_user.method,
132                                 [ obj.session, obj.patron_id ]
133                         );
134                                 
135                 }
136
137                 function gen_list_append(checkout) {
138                         return function() {
139                                 obj.list.append(
140                                         {
141                                                 'row' : {
142                                                         'my' : {
143                                                                 'circ' : checkout,
144                                                         }
145                                                 }
146                                         }
147                                 );
148                         };
149                 }
150
151                 JSAN.use('util.exec'); var exec = new util.exec();
152                 var rows = [];
153                 for (var i in obj.checkouts) {
154                         rows.push( gen_list_append(obj.checkouts[i]) );
155                 }
156                 exec.chain( rows );
157         },
158 }
159
160 dump('exiting patron.items.js\n');