]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/server/circ/alternate_copy_summary.js
Toward a new look for XUL Record Summary. bib_brief.xul modified for existing instan...
[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("copy_creator", '');
105         set("deleted", '');
106         set("deposit", '');
107         set("deposit_amount", '');
108         set("dummy_author", '');
109         set("dummy_title", '');
110         set("copy_edit_date", '');
111         set("copy_editor", '');
112         set("fine_level", '');
113         set("holdable", '');
114         set("copy_id", '');
115         set("loan_duration", '');
116         set("location", '');
117         set("opac_visible", '');
118         set("price", '');
119         set("ref", '');
120         set("status", '');
121         set("notes", '');
122         set("stat_cat_entry_copy_maps", '');
123         set("circulations", '');
124         set("total_circ_count", '');
125         set_tooltip("total_circ_count", '');
126         set("total_circ_count_prev_year", '');
127         set("total_circ_count_curr_year", '');
128         set("holds", '');
129
130         if (details.copy) {
131             set("stat_cat_entries", details.copy.stat_cat_entries()); 
132             set("age_protect", details.copy.age_protect()); 
133             set("alert_message", details.copy.alert_message()); 
134             set("barcode", details.copy.barcode()); 
135             set("call_number", details.copy.call_number()); 
136             set("circ_as_type", details.copy.circ_as_type()); 
137             set("copy_circ_lib" , details.copy.circ_lib()); 
138             set("circ_modifier", details.copy.circ_modifier()); 
139             set("circulate", details.copy.circulate()); 
140             set("copy_number", details.copy.copy_number()); 
141             set("copy_create_date", details.copy.create_date()); 
142             set("copy_creator", details.copy.creator()); 
143             set("deleted", details.copy.deleted()); 
144             set("deposit", details.copy.deposit()); 
145             set("deposit_amount", details.copy.deposit_amount()); 
146             set("dummy_author", details.copy.dummy_author()); 
147             set("dummy_title", details.copy.dummy_title()); 
148             set("copy_edit_date", details.copy.edit_date()); 
149             set("copy_editor", details.copy.editor()); 
150             set("fine_level", details.copy.fine_level()); 
151             set("holdable", details.copy.holdable()); 
152             set("copy_id", details.copy.id()); 
153             set("loan_duration", details.copy.loan_duration()); 
154             set("location", details.copy.location()); 
155             set("opac_visible", details.copy.opac_visible()); 
156             set("price", details.copy.price()); 
157             set("ref", details.copy.ref()); 
158             set("status", details.copy.status()); 
159             set("notes", details.copy.notes()); 
160             set("stat_cat_entry_copy_maps", details.copy.stat_cat_entry_copy_maps()); 
161             set("circulations", details.copy.circulations()); 
162             set("holds", details.copy.holds()); 
163
164             network.simple_request('FM_CIRC_IMPROVED_COUNT_VIA_COPY', [ses(), { 'copy' : details.copy.id() } ], function(req) {
165                 var r = req.getResultObject();
166                 var total = 0; var tooltip = ''; var year = {};
167                 for (var i = 0; i < r.length; i++) {
168                     total += Number( r[i].count() );
169                     if (typeof year[ r[i].year() ] == 'undefined') year[ r[i].year() ] = 0;
170                     year[ r[i].year() ] += Number( r[i].count() ); // Add original circs and renewals together
171                 }
172                 set( 'total_circ_count', total );
173                 var curr_year = (new Date()).getFullYear();
174                 var prev_year = curr_year - 1;
175                 set( 'total_circ_count_curr_year', year[ curr_year ] || 0 );
176                 set( 'total_circ_count_prev_year', year[ prev_year ] || 0 );
177                 var keys = []; for (var i in year) { keys.push( i ); }; keys.sort();
178                 for (var i = 0; i < keys.length; i++) {
179                     tooltip += document.getElementById('circStrings').getFormattedString( 
180                         'staff.circ.copy_details.circ_count_by_year', [ 
181                             keys[i] == -1 ? document.getElementById('circStrings').getString('staff.circ.copy_details.circ_count_by_year.legacy_label') : keys[i], 
182                             year[keys[i]]
183                         ] 
184                     ) + '\n';
185                 }
186                 set_tooltip( 'total_circ_count', tooltip );
187             } );
188         }
189
190         set("copies", '');
191         set("volume_create_date", '');
192         set("volume_creator", '');
193         set("deleted", '');
194         set("volume_edit_date", '');
195         set("volume_editor", '');
196         set("volume_id", '');
197         set("label", '');
198         set("owning_lib" , '');
199         set("record", '');
200         set("notes", '');
201         set("uri_maps", '');
202         set("uris", '');
203
204         if (details.volume) {
205             set("copies", details.volume.copies()); 
206             set("volume_create_date", details.volume.create_date()); 
207             set("volume_creator", details.volume.creator()); 
208             set("deleted", details.volume.deleted()); 
209             set("volume_edit_date", details.volume.edit_date()); 
210             set("volume_editor", details.volume.editor()); 
211             set("volume_id", details.volume.id()); 
212             set("label", details.volume.label()); 
213             set("owning_lib" , details.volume.owning_lib()); 
214             set("record", details.volume.record()); 
215             set("notes", details.volume.notes()); 
216             set("uri_maps", details.volume.uri_maps()); 
217             set("uris", details.volume.uris()); 
218         }
219
220         set("copy_status", '');
221         set("dest", '');
222         set("dest_recv_time", '');
223         set("transit_id", '');
224         set("persistant_transfer", '');
225         set("prev_hop", '');
226         set("source", '');
227         set("source_send_time", '');
228         set("target_copy", '');
229         set("hold_transit_copy", '');
230
231         if (details.transit) {
232             set("copy_status", details.transit.copy_status()); 
233             set("dest", details.transit.dest()); 
234             set("dest_recv_time", details.transit.dest_recv_time()); 
235             set("transit_id", details.transit.id()); 
236             set("persistant_transfer", details.transit.persistant_transfer()); 
237             set("prev_hop", details.transit.prev_hop()); 
238             set("source", details.transit.source()); 
239             set("source_send_time", details.transit.source_send_time()); 
240             set("target_copy", details.transit.target_copy()); 
241             set("hold_transit_copy", details.transit.hold_transit_copy()); 
242         }
243
244         set("checkin_lib", '');
245         set("checkin_workstation",""); 
246         set("checkin_staff", '');
247         set("checkin_time", '');
248         set("checkin_scan_time", '');
249         set("circ_circ_lib" , '');
250         set("circ_staff", '');
251         set("desk_renewal", '');
252         set("due_date", '');
253         set("duration", '');
254         set("duration_rule", '');
255         set("fine_interval", '');
256         set("circ_id", '');
257         set("max_fine", '');
258         set("max_fine_rule", '');
259         set("opac_renewal", '');
260         set("phone_renewal", '');
261         set("recuring_fine", '');
262         set("recuring_fine_rule", '');
263         set("renewal_remaining", '');
264         set("stop_fines", '');
265         set("stop_fines_time", '');
266         set("target_copy", '');
267         set("usr", '');
268         set("xact_finish", '');
269         set("xact_start", '');
270         set("create_time", '');
271         set("workstation", '');
272         set("billings", '');
273         set("payments", '');
274         set("billable_transaction", '');
275         set("circ_type", '');
276         set("billing_total", '');
277         set("payment_total", '');
278
279         if (details.circ) {
280             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) {};
281             if (details.circ.checkin_workstation()) {
282                 set("checkin_workstation", details.circ.checkin_workstation().name()); 
283             }
284             set("checkin_staff", details.circ.checkin_staff()); 
285             set("checkin_time", details.circ.checkin_time()); 
286             set("checkin_scan_time", details.circ.checkin_scan_time()); 
287             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) {};
288             set("circ_staff", details.circ.circ_staff()); 
289             set("desk_renewal", details.circ.desk_renewal()); 
290             set("due_date", details.circ.due_date()); 
291             set("duration", details.circ.duration()); 
292             set("duration_rule", details.circ.duration_rule()); 
293             set("fine_interval", details.circ.fine_interval()); 
294             set("circ_id", details.circ.id()); 
295             set("max_fine", details.circ.max_fine()); 
296             set("max_fine_rule", details.circ.max_fine_rule()); 
297             set("opac_renewal", details.circ.opac_renewal()); 
298             set("phone_renewal", details.circ.phone_renewal()); 
299             set("recuring_fine", details.circ.recuring_fine()); 
300             set("recuring_fine_rule", details.circ.recuring_fine_rule()); 
301             set("renewal_remaining", details.circ.renewal_remaining()); 
302             set("stop_fines", details.circ.stop_fines()); 
303             set("stop_fines_time", details.circ.stop_fines_time()); 
304             set("target_copy", details.circ.target_copy()); 
305             set("usr", details.circ.usr()); 
306             set("xact_finish", details.circ.xact_finish()); 
307             set("xact_start", details.circ.xact_start()); 
308             set("create_time", details.circ.create_time()); 
309             set("workstation", details.circ.workstation()); 
310             set("billings", details.circ.billings()); 
311             set("payments", details.circ.payments()); 
312             set("billable_transaction", details.circ.billable_transaction()); 
313             set("circ_type", details.circ.circ_type()); 
314             set("billing_total", details.circ.billing_total()); 
315             set("payment_total", details.circ.payment_total()); 
316         }
317
318         set("status", '');
319         set("transit", '');
320         set("capture_time", '');
321         set("current_copy", '');
322         set("email_notify", '');
323         set("expire_time", '');
324         set("fulfillment_lib", '');
325         set("fulfillment_staff", '');
326         set("fulfillment_time", '');
327         set("hold_type", '');
328         set("holdable_formats", '');
329         set("hold_id", '');
330         set("phone_notify", '');
331         set("pickup_lib", '');
332         set("prev_check_time", '');
333         set("request_lib", '');
334         set("request_time", '');
335         set("requestor", '');
336         set("selection_depth", '');
337         set("selection_ou", '');
338         set("target", '');
339         set("usr", '');
340         set("cancel_time", '');
341         set("notify_time", '');
342         set("notify_count", '');
343         set("notifications", '');
344         set("bib_rec", '');
345         set("eligible_copies", '');
346         set("frozen", '');
347         set("thaw_date", '');
348         set("shelf_time", '');
349         set("cancel_cause", '');
350         set("cancel_note", '');
351         set("notes", '');
352
353         if (details.hold) {
354             set("status", details.hold.status()); 
355             set("transit", details.hold.transit()); 
356             set("capture_time", details.hold.capture_time()); 
357             set("current_copy", details.hold.current_copy()); 
358             set("email_notify", details.hold.email_notify()); 
359             set("expire_time", details.hold.expire_time()); 
360             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) {}
361             set("fulfillment_staff", details.hold.fulfillment_staff()); 
362             set("fulfillment_time", details.hold.fulfillment_time()); 
363             set("hold_type", details.hold.hold_type()); 
364             set("holdable_formats", details.hold.holdable_formats()); 
365             set("hold_id", details.hold.id()); 
366             set("phone_notify", details.hold.phone_notify()); 
367             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) {}
368             set("prev_check_time", details.hold.prev_check_time()); 
369             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) {}
370             set("request_time", details.hold.request_time()); 
371             set("requestor", details.hold.requestor()); 
372             set("selection_depth", details.hold.selection_depth()); 
373             set("selection_ou" , typeof details.hold.selection_ou() == 'object' ? details.hold.selection_ou().shortname() : data.hash.aou[ details.hold.selection_ou() ].shortname() ); 
374             set("target", details.hold.target()); 
375             set("usr", details.hold.usr()); 
376             set("cancel_time", details.hold.cancel_time()); 
377             set("notify_time", details.hold.notify_time()); 
378             set("notify_count", details.hold.notify_count()); 
379             set("notifications", details.hold.notifications()); 
380             set("bib_rec", details.hold.bib_rec()); 
381             set("eligible_copies", details.hold.eligible_copies()); 
382             set("frozen", details.hold.frozen()); 
383             set("thaw_date", details.hold.thaw_date()); 
384             set("shelf_time", details.hold.shelf_time()); 
385             set("cancel_cause", details.hold.cancel_cause()); 
386             set("cancel_note", details.hold.cancel_note()); 
387             set("notes", details.hold.notes()); 
388         } 
389
390         var x = document.getElementById('cat_deck');
391         if (x) {
392             JSAN.use('util.deck');
393             var d = new util.deck('cat_deck');
394             d.reset_iframe( urls.XUL_MARC_VIEW, {}, { 'docid' : details.mvr ? details.mvr.doc_id() : -1 } );
395         }
396
397     } catch(E) {
398         alert(E);
399     }
400 }