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(); } 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.temp_copy_ids != 'undefined' && g.data.temp_copy_ids != null) {
54 g.copy_ids = g.copy_ids.concat( JSON2js( g.data.temp_copy_ids ) );
55 g.data.temp_copy_ids = undefined; g.data.stash('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);
72 $('bucket_list').selectedIndex = 0;
73 $('bucket_list').focus();
77 g.error.standard_unexpected_error_alert('Trying to init copy_buckets_quick.xul',E);
84 g.new_bucket = function() {
86 var name = prompt('What would you like to name the bucket?','','Bucket Creation');
88 var bucket = new ccb();
89 bucket.btype('staff_client');
90 bucket.owner( g.data.list.au[0].id() );
93 var bucket_id = g.network.simple_request('BUCKET_CREATE',[ses(),'copy',bucket]);
94 if (typeof bucket_id == 'object') throw bucket_id;
96 g.add_to_bucket(bucket_id);
99 g.error.standard_unexpected_error_alert('Bucket creation failed.',E);
103 g.add_to_bucket = function(b) {
108 if ($('bucket_list').selectedItem) bucket_id = $('bucket_list').selectedItem.getAttribute('id');
110 if (!bucket_id) return;
111 for (var i = 0; i < g.copy_ids.length; i++) {
112 var bucket_item = new ccbi();
113 bucket_item.isnew('1');
114 bucket_item.bucket(bucket_id);
115 bucket_item.target_copy( g.copy_ids[i] );
117 var robj = g.network.simple_request('BUCKET_ITEM_CREATE', [ ses(), 'copy', bucket_item ]);
118 if (typeof robj == 'object') throw robj;
121 g.error.standard_unexpected_error_alert('Addition likely failed for bucket = ' + bucket_id + ' and copy id = ' + g.copy_ids[i],E);
127 g.advanced = function() {
128 JSAN.use('util.window'); var win = new util.window();
129 g.data.temp_copy_ids = js2JSON( g.copy_ids ); g.data.stash('temp_copy_ids');
130 win.open(urls.XUL_COPY_BUCKETS,'adv_copy_buckets','chrome,resizable,modal');
137 <vbox flex="1" style="overflow: auto">
139 <caption label="Item Buckets"/>
140 <description id="desc"/>
141 <listbox id="bucket_list" rows="5" flex="1" style="overflow: auto"/>
143 <button label="Add to Selected Bucket" accesskey="A" oncommand="g.add_to_bucket()"/>
144 <button label="Add to New Bucket" accesskey="N" oncommand="g.new_bucket()"/>
147 <button label="Advanced" accesskey="v" oncommand="g.advanced()"/>
148 <button label="Cancel" accesskey="C" oncommand="window.close()"/>