]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/cat/copy_buckets_quick.xul
forgot to add this
[Evergreen.git] / Open-ILS / xul / staff_client / server / cat / copy_buckets_quick.xul
1 <?xml version="1.0"?>
2 <!-- Application: Evergreen Staff Client -->
3 <!-- Screen: Patron Display -->
4
5 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
6 <!-- STYLESHEETS -->
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"?>
11
12 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
13 <!-- LOCALIZATION -->
14 <!DOCTYPE window PUBLIC "" ""[
15         <!--#include virtual="/opac/locale/en-US/lang.dtd"-->
16 ]>
17
18 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
19 <!-- OVERLAYS -->
20 <?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
21
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">
25
26         <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
27         <!-- BEHAVIOR -->
28         <script type="text/javascript">var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};</script>
29         <scripts id="openils_util_scripts"/>
30
31         <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
32         <script>
33         <![CDATA[
34                 function $(id) { return document.getElementById(id); }
35                 function $c(n) { return document.createElement(n); }
36
37                 function my_init() {
38                         try {
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'});
47
48                                 g.cgi = new CGI();
49                                 g.copy_ids = [];
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 (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 = null; g.data.stash('temp_copy_ids');
56                                 }
57
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?') 
62                                 ) );
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);
65
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);
71                                 }
72                                 $('bucket_list').selectedIndex = 0;
73                                 $('bucket_list').focus();
74
75                         } catch(E) {
76                                 try { 
77                                         g.error.standard_unexpected_error_alert('Trying to init copy_buckets_quick.xul',E); 
78                                 } catch(F) { 
79                                         alert(E); 
80                                 }
81                         }
82                 }
83
84                 g.new_bucket = function() {
85                         try {
86                                 var name = prompt('What would you like to name the bucket?','','Bucket Creation');
87                                 if (name) {
88                                         var bucket = new ccb();
89                                         bucket.btype('staff_client');
90                                         bucket.owner( g.data.list.au[0].id() );
91                                         bucket.name( name );
92
93                                         var bucket_id = g.network.simple_request('BUCKET_CREATE',[ses(),'copy',bucket]);
94                                         if (typeof bucket_id == 'object') throw bucket_id;
95
96                                         g.add_to_bucket(bucket_id);
97                                 }
98                         } catch(E) {
99                                 g.error.standard_unexpected_error_alert('Bucket creation failed.',E);
100                         }
101                 }
102
103                 g.add_to_bucket = function(b) {
104                         var bucket_id;
105                         if (b) {
106                                 bucket_id = b;
107                         } else {
108                                 if ($('bucket_list').selectedItem) bucket_id = $('bucket_list').selectedItem.getAttribute('id');
109                         }
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] );
116                                 try {
117                                         var robj = g.network.simple_request('BUCKET_ITEM_CREATE', [ ses(), 'copy', bucket_item ]);
118                                         if (typeof robj == 'object') throw robj;
119
120                                 } catch(E) {
121                                         g.error.standard_unexpected_error_alert('Addition likely failed for bucket = ' + bucket_id + ' and copy id = ' + g.copy_ids[i],E);
122                                 }
123                         }
124                         window.close();
125                 }
126
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');
131                         window.close();
132                 }
133
134         ]]>
135         </script>
136
137         <vbox flex="1" style="overflow: auto">
138         <groupbox flex="1">
139                 <caption label="Item Buckets"/>
140                 <description id="desc"/>
141                 <listbox id="bucket_list" rows="5" flex="1" style="overflow: auto"/>
142                 <hbox>
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()"/>
145                 </hbox>
146                 <hbox>
147                         <button label="Advanced" accesskey="v" oncommand="g.advanced()"/>
148                         <button label="Cancel" accesskey="C" oncommand="window.close()"/>
149                 </hbox>
150         </groupbox>
151         </vbox>
152
153 </window>
154