2 <!-- Application: Evergreen Staff Client -->
3 <!-- Screen: Patron Display -->
5 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
7 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
8 <?xml-stylesheet href="chrome://open_ils_staff_client/skin/global.css" type="text/css"?>
9 <?xml-stylesheet href="/xul/server/skin/global.css" type="text/css"?>
10 <?xml-stylesheet href="/xul/server/skin/cat.css" type="text/css"?>
12 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
14 <!DOCTYPE window PUBLIC "" ""[
15 <!--#include virtual="/opac/locale/en-US/lang.dtd"-->
18 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
20 <?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
22 <window id="copy_buckets_win" title="Add to Bucket"
23 onload="try { my_init(); font_helper(); } catch(E) { alert(E); }" persist="height,width"
24 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
26 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
28 <script type="text/javascript">var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};</script>
29 <scripts id="openils_util_scripts"/>
31 <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
34 function $(id) { return document.getElementById(id); }
35 function $c(n) { return document.createElement(n); }
39 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
40 if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
41 JSAN.errorLevel = "die"; // none, warn, or die
42 JSAN.addRepository('/xul/server/');
43 JSAN.use('util.error'); g.error = new util.error();
44 g.error.sdump('D_TRACE','my_init() for copy_buckets.xul');
45 JSAN.use('util.network'); g.network = new util.network();
46 JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
50 if (g.cgi.param('copy_ids')) g.copy_ids = g.copy_ids.concat( JSON2js( g.cgi.param('copy_ids') ) );
51 if (typeof window.xuLG == 'object' && typeof window.xulG.copy_ids != 'undefined')
52 g.copy_ids = g.copy_ids.concat( window.xulG.copy_ids );
53 if (typeof g.data.cb_temp_copy_ids != 'undefined' && g.data.cb_temp_copy_ids != null) {
54 g.copy_ids = g.copy_ids.concat( JSON2js( g.data.cb_temp_copy_ids ) );
55 g.data.cb_temp_copy_ids = undefined; g.data.stash('cb_temp_copy_ids');
58 $('desc').appendChild( document.createTextNode(
59 (g.copy_ids.length == 1 ?
60 'Copy this 1 item into which bucket?' :
61 'Copy these ' + g.copy_ids.length + ' items into which bucket?')
63 var robj = g.network.simple_request('BUCKET_RETRIEVE_VIA_USER',[ ses(), g.data.list.au[0].id() ]);
64 if (typeof robj.ilsevent != 'undefined') throw(robj);
66 for (var i = 0; i < robj.copy.length; i++) {
67 var listitem = $c('listitem');
68 listitem.setAttribute('label', robj.copy[i].name());
69 listitem.setAttribute('id', robj.copy[i].id());
70 $('bucket_list').appendChild(listitem);
73 try { $('bucket_list').selectedIndex = 0; } catch(E) { }
75 $('bucket_list').focus();
79 g.error.standard_unexpected_error_alert('Trying to init copy_buckets_quick.xul',E);
86 g.new_bucket = function() {
88 var name = prompt('What would you like to name the bucket?','','Bucket Creation');
90 var bucket = new ccb();
91 bucket.btype('staff_client');
92 bucket.owner( g.data.list.au[0].id() );
95 var bucket_id = g.network.simple_request('BUCKET_CREATE',[ses(),'copy',bucket]);
96 if (typeof bucket_id == 'object') throw bucket_id;
98 g.add_to_bucket(bucket_id);
101 g.error.standard_unexpected_error_alert('Bucket creation failed.',E);
105 g.add_to_bucket = function(b) {
111 if ($('bucket_list').selectedItem) bucket_id = $('bucket_list').selectedItem.getAttribute('id');
115 if (!bucket_id) return;
116 for (var i = 0; i < g.copy_ids.length; i++) {
117 var bucket_item = new ccbi();
118 bucket_item.isnew('1');
119 bucket_item.bucket(bucket_id);
120 bucket_item.target_copy( g.copy_ids[i] );
122 var robj = g.network.simple_request('BUCKET_ITEM_CREATE', [ ses(), 'copy', bucket_item ]);
123 if (typeof robj == 'object') throw robj;
126 g.error.standard_unexpected_error_alert('Addition likely failed for bucket = ' + bucket_id + ' and copy id = ' + g.copy_ids[i],E);
132 g.advanced = function() {
133 JSAN.use('util.window'); var win = new util.window();
134 g.data.cb_temp_copy_ids = js2JSON( g.copy_ids ); g.data.stash('cb_temp_copy_ids');
135 win.open(urls.XUL_COPY_BUCKETS,'adv_copy_buckets','chrome,resizable,modal');
142 <vbox flex="1" style="overflow: auto">
144 <caption label="Item Buckets"/>
145 <description id="desc"/>
146 <listbox id="bucket_list" rows="5" flex="1" style="overflow: auto"/>
148 <button label="Add to Selected Bucket" accesskey="A" oncommand="g.add_to_bucket()"/>
149 <button label="Add to New Bucket" accesskey="N" oncommand="g.new_bucket()"/>
153 <button label="Advanced" accesskey="v" oncommand="g.advanced()"/>
155 <button label="Cancel" accesskey="C" oncommand="window.close()"/>