]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/server/circ/alternate_copy_summary.js
Status Changed Time field in item details
[working/Evergreen.git] / Open-ILS / xul / staff_client / server / circ / alternate_copy_summary.js
1 var error; 
2 var network;
3 var data;
4
5 function my_init() {
6     try {
7         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
8         if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
9         JSAN.errorLevel = "die"; // none, warn, or die
10         JSAN.addRepository('/xul/server/');
11         JSAN.use('util.error'); error = new util.error();
12         error.sdump('D_TRACE','my_init() for alternate_copy_summary.xul');
13
14         JSAN.use('util.network'); network = new util.network();
15         JSAN.use('OpenILS.data'); data = new OpenILS.data(); data.stash_retrieve();
16
17         setTimeout( function() { load_item(); }, 1000 ); // timeout so xulG gets a chance to get pushed in
18
19     } catch(E) {
20         try { error.standard_unexpected_error_alert('main/test.xul',E); } catch(F) { alert(E); }
21     }
22 }
23
24 function set(name,value) { 
25     var nodes = document.getElementsByAttribute('name',name); 
26     for (var i = 0; i < nodes.length; i++) {
27         nodes[i].setAttribute('value',value); nodes[i].value = value; 
28     }
29 }
30
31 function set_tooltip(name,value) { 
32     var nodes = document.getElementsByAttribute('name',name); 
33     for (var i = 0; i < nodes.length; i++) {
34         nodes[i].setAttribute('tooltiptext',value);
35     }
36 }
37
38 function load_item() {
39     try {
40         if (! xulG.barcode) return;
41
42         var details = network.simple_request('FM_ACP_DETAILS_VIA_BARCODE.authoritative', [ ses(), xulG.barcode ]);
43         // Should get back .mvr, .copy, .volume, .transit, .circ, .hold
44
45         if (typeof bib_brief_overlay == 'function') bib_brief_overlay( { 'mvr' : details.mvr, 'acp' : details.copy } );
46 /*
47         set('title', '');
48         set('author', '');
49         set('doc_id', '');
50         set('doc_type', '');
51         set('pubdate', '');
52         set('isbn', '');
53         set('publisher', '');
54         set('tcn', '');
55         set('subject', '');
56         set('types_of_resource', '');
57         set('call_numbers', '');
58         set('edition', '');
59         set('online_loc', '');
60         set('synopsis', '');
61         set('physical_description', '');
62         set('toc', '');
63         set('copy_count', '');
64         set('series', '');
65         set('serials', '');
66
67         if (details.mvr) {
68             set('title',details.mvr.title()); 
69             set('author',details.mvr.author());
70             set('doc_id', details.mvr.doc_id());
71             set('doc_type', details.mvr.doc_type());
72             set('pubdate', details.mvr.pubdate());
73             set('isbn',details.mvr.isbn());
74             set('publisher', details.mvr.publisher());
75             set('tcn', details.mvr.tcn());
76             set('subject', details.mvr.subject());
77             set('types_of_resource', details.mvr.types_of_resource());
78             set('call_numbers', details.mvr.call_numbers());
79             set('edition', details.mvr.edition());
80             set('online_loc', details.mvr.online_loc());
81             set('synopsis', details.mvr.synopsis());
82             set('physical_description', details.mvr.physical_description());
83             set('toc', details.mvr.toc());
84             set('copy_count', details.mvr.copy_count());
85             set('series', details.mvr.series());
86             set('serials', details.mvr.serials());
87         } else {
88             set('title',details.copy.dummy_title());
89             set('author',details.copy.dummy_author()); 
90             set('isbn',details.copy.dummy_isbn());
91         }
92 */
93         set("stat_cat_entries", '');
94         set("age_protect", '');
95         set("alert_message", '');
96         set("barcode", '');
97         set("call_number", '');
98         set("circ_as_type", '');
99         set("copy_circ_lib" , '');
100         set("circ_modifier", '');
101         set("circulate", '');
102         set("copy_number", '');
103         set("copy_create_date", '');
104         set("status_changed_time", '');
105         set("copy_creator", '');
106         set("deleted", '');
107         set("deposit", '');
108         set("deposit_amount", '');
109         set("dummy_author", '');
110         set("dummy_title", '');
111         set("copy_edit_date", '');
112         set("copy_editor", '');
113         set("fine_level", '');
114         set("holdable", '');
115         set("copy_id", '');
116         set("loan_duration", '');
117         set("location", '');
118         set("opac_visible", '');
119         set("price", '');
120         set("ref", '');
121         set("status", '');
122         set("notes", '');
123         set("stat_cat_entry_copy_maps", '');
124         set("circulations", '');
125         set("total_circ_count", '');
126         set_tooltip("total_circ_count", '');
127         set("total_circ_count_prev_year", '');
128         set("total_circ_count_curr_year", '');
129         set("holds", '');
130
131         if (details.copy) {
132             set("stat_cat_entries", details.copy.stat_cat_entries()); 
133             set("age_protect", details.copy.age_protect()); 
134             set("alert_message", details.copy.alert_message()); 
135             set("barcode", details.copy.barcode()); 
136             set("call_number", details.copy.call_number()); 
137             set("circ_as_type", details.copy.circ_as_type()); 
138             set("copy_circ_lib" , details.copy.circ_lib()); 
139             set("circ_modifier", details.copy.circ_modifier()); 
140             set("circulate", details.copy.circulate()); 
141             set("copy_number", details.copy.copy_number()); 
142             set("copy_create_date", details.copy.create_date()); 
143             set("status_changed_time", details.copy.status_changed_time()); 
144             set("copy_creator", details.copy.creator()); 
145             set("deleted", details.copy.deleted()); 
146             set("deposit", details.copy.deposit()); 
147             set("deposit_amount", details.copy.deposit_amount()); 
148             set("dummy_author", details.copy.dummy_author()); 
149             set("dummy_title", details.copy.dummy_title()); 
150             set("copy_edit_date", details.copy.edit_date()); 
151             set("copy_editor", details.copy.editor()); 
152             set("fine_level", details.copy.fine_level()); 
153             set("holdable", details.copy.holdable()); 
154             set("copy_id", details.copy.id()); 
155             set("loan_duration", details.copy.loan_duration()); 
156             set("location", details.copy.location()); 
157             set("opac_visible", details.copy.opac_visible()); 
158             set("price", details.copy.price()); 
159             set("ref", details.copy.ref()); 
160             set("status", details.copy.status()); 
161             set("notes", details.copy.notes()); 
162             set("stat_cat_entry_copy_maps", details.copy.stat_cat_entry_copy_maps()); 
163             set("circulations", details.copy.circulations()); 
164             set("holds", details.copy.holds()); 
165
166             network.simple_request('FM_CIRC_IMPROVED_COUNT_VIA_COPY', [ses(), { 'copy' : details.copy.id() } ], function(req) {
167                 var r = req.getResultObject();
168                 var total = 0; var tooltip = ''; var year = {};
169                 for (var i = 0; i < r.length; i++) {
170                     total += Number( r[i].count() );
171                     if (typeof year[ r[i].year() ] == 'undefined') year[ r[i].year() ] = 0;
172                     year[ r[i].year() ] += Number( r[i].count() ); // Add original circs and renewals together
173                 }
174                 set( 'total_circ_count', total );
175                 var curr_year = (new Date()).getFullYear();
176                 var prev_year = curr_year - 1;
177                 set( 'total_circ_count_curr_year', year[ curr_year ] || 0 );
178                 set( 'total_circ_count_prev_year', year[ prev_year ] || 0 );
179                 var keys = []; for (var i in year) { keys.push( i ); }; keys.sort();
180                 for (var i = 0; i < keys.length; i++) {
181                     tooltip += document.getElementById('circStrings').getFormattedString( 
182                         'staff.circ.copy_details.circ_count_by_year', [ 
183                             keys[i] == -1 ? document.getElementById('circStrings').getString('staff.circ.copy_details.circ_count_by_year.legacy_label') : keys[i], 
184                             year[keys[i]]
185                         ] 
186                     ) + '\n';
187                 }
188                 set_tooltip( 'total_circ_count', tooltip );
189             } );
190         }
191
192         set("copies", '');
193         set("volume_create_date", '');
194         set("volume_creator", '');
195         set("deleted", '');
196         set("volume_edit_date", '');
197         set("volume_editor", '');
198         set("volume_id", '');
199         set("label", '');
200         set("owning_lib" , '');
201         set("record", '');
202         set("notes", '');
203         set("uri_maps", '');
204         set("uris", '');
205
206         if (details.volume) {
207             set("copies", details.volume.copies()); 
208             set("volume_create_date", details.volume.create_date()); 
209             set("volume_creator", details.volume.creator()); 
210             set("deleted", details.volume.deleted()); 
211             set("volume_edit_date", details.volume.edit_date()); 
212             set("volume_editor", details.volume.editor()); 
213             set("volume_id", details.volume.id()); 
214             set("label", details.volume.label()); 
215             set("owning_lib" , details.volume.owning_lib()); 
216             set("record", details.volume.record()); 
217             set("notes", details.volume.notes()); 
218             set("uri_maps", details.volume.uri_maps()); 
219             set("uris", details.volume.uris()); 
220         }
221
222         set("copy_status", '');
223         set("dest", '');
224         set("dest_recv_time", '');
225         set("transit_id", '');
226         set("persistant_transfer", '');
227         set("prev_hop", '');
228         set("source", '');
229         set("source_send_time", '');
230         set("target_copy", '');
231         set("hold_transit_copy", '');
232
233         if (details.transit) {
234             set("copy_status", details.transit.copy_status()); 
235             set("dest", details.transit.dest()); 
236             set("dest_recv_time", details.transit.dest_recv_time()); 
237             set("transit_id", details.transit.id()); 
238             set("persistant_transfer", details.transit.persistant_transfer()); 
239             set("prev_hop", details.transit.prev_hop()); 
240             set("source", details.transit.source()); 
241             set("source_send_time", details.transit.source_send_time()); 
242             set("target_copy", details.transit.target_copy()); 
243             set("hold_transit_copy", details.transit.hold_transit_copy()); 
244         }
245
246         set("checkin_lib", '');
247         set("checkin_workstation",""); 
248         set("checkin_staff", '');
249         set("checkin_time", '');
250         set("checkin_scan_time", '');
251         set("circ_circ_lib" , '');
252         set("circ_staff", '');
253         set("desk_renewal", '');
254         set("due_date", '');
255         set("duration", '');
256         set("duration_rule", '');
257         set("fine_interval", '');
258         set("circ_id", '');
259         set("max_fine", '');
260         set("max_fine_rule", '');
261         set("opac_renewal", '');
262         set("phone_renewal", '');
263         set("recuring_fine", '');
264         set("recuring_fine_rule", '');
265         set("renewal_remaining", '');
266         set("stop_fines", '');
267         set("stop_fines_time", '');
268         set("target_copy", '');
269         set("usr", '');
270         set("xact_finish", '');
271         set("xact_start", '');
272         set("create_time", '');
273         set("workstation", '');
274         set("billings", '');
275         set("payments", '');
276         set("billable_transaction", '');
277         set("circ_type", '');
278         set("billing_total", '');
279         set("payment_total", '');
280
281         if (details.circ) {
282             try { set("checkin_lib", typeof details.circ.checkin_lib() == 'object' ? details.circ.checkin_lib().shortname() : data.hash.aou[ details.circ.checkin_lib() ].shortname() );  } catch(E) {};
283             if (details.circ.checkin_workstation()) {
284                 set("checkin_workstation", details.circ.checkin_workstation().name()); 
285             }
286             set("checkin_staff", details.circ.checkin_staff()); 
287             set("checkin_time", details.circ.checkin_time()); 
288             set("checkin_scan_time", details.circ.checkin_scan_time()); 
289             try { set("circ_circ_lib" , typeof details.circ.circ_lib() == 'object' ? details.circ.circ_lib().shortname() : data.hash.aou[ details.circ.circ_lib() ].shortname() );  } catch(E) {};
290             set("circ_staff", details.circ.circ_staff()); 
291             set("desk_renewal", details.circ.desk_renewal()); 
292             set("due_date", details.circ.due_date()); 
293             set("duration", details.circ.duration()); 
294             set("duration_rule", details.circ.duration_rule()); 
295             set("fine_interval", details.circ.fine_interval()); 
296             set("circ_id", details.circ.id()); 
297             set("max_fine", details.circ.max_fine()); 
298             set("max_fine_rule", details.circ.max_fine_rule()); 
299             set("opac_renewal", details.circ.opac_renewal()); 
300             set("phone_renewal", details.circ.phone_renewal()); 
301             set("recuring_fine", details.circ.recuring_fine()); 
302             set("recuring_fine_rule", details.circ.recuring_fine_rule()); 
303             set("renewal_remaining", details.circ.renewal_remaining()); 
304             set("stop_fines", details.circ.stop_fines()); 
305             set("stop_fines_time", details.circ.stop_fines_time()); 
306             set("target_copy", details.circ.target_copy()); 
307             set("usr", details.circ.usr()); 
308             set("xact_finish", details.circ.xact_finish()); 
309             set("xact_start", details.circ.xact_start()); 
310             set("create_time", details.circ.create_time()); 
311             set("workstation", details.circ.workstation()); 
312             set("billings", details.circ.billings()); 
313             set("payments", details.circ.payments()); 
314             set("billable_transaction", details.circ.billable_transaction()); 
315             set("circ_type", details.circ.circ_type()); 
316             set("billing_total", details.circ.billing_total()); 
317             set("payment_total", details.circ.payment_total()); 
318         }
319
320         set("status", '');
321         set("transit", '');
322         set("capture_time", '');
323         set("current_copy", '');
324         set("email_notify", '');
325         set("expire_time", '');
326         set("fulfillment_lib", '');
327         set("fulfillment_staff", '');
328         set("fulfillment_time", '');
329         set("hold_type", '');
330         set("holdable_formats", '');
331         set("hold_id", '');
332         set("phone_notify", '');
333         set("pickup_lib", '');
334         set("prev_check_time", '');
335         set("request_lib", '');
336         set("request_time", '');
337         set("requestor", '');
338         set("selection_depth", '');
339         set("selection_ou", '');
340         set("target", '');
341         set("usr", '');
342         set("cancel_time", '');
343         set("notify_time", '');
344         set("notify_count", '');
345         set("notifications", '');
346         set("bib_rec", '');
347         set("eligible_copies", '');
348         set("frozen", '');
349         set("thaw_date", '');
350         set("shelf_time", '');
351         set("cancel_cause", '');
352         set("cancel_note", '');
353         set("notes", '');
354
355         if (details.hold) {
356             set("status", details.hold.status()); 
357             set("transit", details.hold.transit()); 
358             set("capture_time", details.hold.capture_time()); 
359             set("current_copy", details.hold.current_copy()); 
360             set("email_notify", details.hold.email_notify()); 
361             set("expire_time", details.hold.expire_time()); 
362             try { set("fulfillment_lib" , typeof details.hold.fulfillment_lib() == 'object' ? details.hold.fulfillment_lib().shortname() : data.hash.aou[ details.hold.fulfillment_lib() ].shortname() );  } catch(E) {}
363             set("fulfillment_staff", details.hold.fulfillment_staff()); 
364             set("fulfillment_time", details.hold.fulfillment_time()); 
365             set("hold_type", details.hold.hold_type()); 
366             set("holdable_formats", details.hold.holdable_formats()); 
367             set("hold_id", details.hold.id()); 
368             set("phone_notify", details.hold.phone_notify()); 
369             try { set("pickup_lib" , typeof details.hold.pickup_lib() == 'object' ? details.hold.pickup_lib().shortname() : data.hash.aou[ details.hold.pickup_lib() ].shortname() );  } catch(E) {}
370             set("prev_check_time", details.hold.prev_check_time()); 
371             try { set("request_lib" , typeof details.hold.request_lib() == 'object' ? details.hold.request_lib().shortname() : data.hash.aou[ details.hold.request_lib() ].shortname() ); } catch(E) {}
372             set("request_time", details.hold.request_time()); 
373             set("requestor", details.hold.requestor()); 
374             set("selection_depth", details.hold.selection_depth()); 
375             set("selection_ou" , typeof details.hold.selection_ou() == 'object' ? details.hold.selection_ou().shortname() : data.hash.aou[ details.hold.selection_ou() ].shortname() ); 
376             set("target", details.hold.target()); 
377             set("usr", details.hold.usr()); 
378             set("cancel_time", details.hold.cancel_time()); 
379             set("notify_time", details.hold.notify_time()); 
380             set("notify_count", details.hold.notify_count()); 
381             set("notifications", details.hold.notifications()); 
382             set("bib_rec", details.hold.bib_rec()); 
383             set("eligible_copies", details.hold.eligible_copies()); 
384             set("frozen", details.hold.frozen()); 
385             set("thaw_date", details.hold.thaw_date()); 
386             set("shelf_time", details.hold.shelf_time()); 
387             set("cancel_cause", details.hold.cancel_cause()); 
388             set("cancel_note", details.hold.cancel_note()); 
389             set("notes", details.hold.notes()); 
390         } 
391
392         var x = document.getElementById('cat_deck');
393         if (x) {
394             JSAN.use('util.deck');
395             var d = new util.deck('cat_deck');
396             d.reset_iframe( urls.XUL_MARC_VIEW, {}, { 'docid' : details.mvr ? details.mvr.doc_id() : -1 } );
397         }
398
399     } catch(E) {
400         alert(E);
401     }
402 }