]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/server/cat/spine_labels.xul
in support of spine labels
[working/Evergreen.git] / Open-ILS / xul / staff_client / server / cat / spine_labels.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/circ.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="spine_labels_win" 
23         onload="my_init()"
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 my_init() {
35                         try {
36                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
37                                 if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
38                                 JSAN.errorLevel = "die"; // none, warn, or die
39                                 JSAN.addRepository('/xul/server/');
40                                 JSAN.use('util.error'); g.error = new util.error();
41                                 g.error.sdump('D_TRACE','my_init() for spine_labels.xul');
42
43                                 JSAN.use('util.network'); g.network = new util.network();
44
45                                 g.cgi = new CGI();
46
47                                 g.barcodes = JSON2js(g.cgi.param('barcodes'));
48                                 g.copies = [];
49                                 g.volumes = {};
50                                 g.volume_count = {};
51
52                                 for (var i = 0; i < g.barcodes.length; i++) {
53                                         var copy = g.network.simple_request( 'FM_ACP_RETRIEVE_VIA_BARCODE', [ g.barcodes[i] ] );
54                                         if (typeof copy.ilsevent != 'undefined') throw(copy);
55                                         g.copies.push( copy );
56                                         if (!g.volumes[ copy.call_number() ]) {
57                                                 var volume = g.network.simple_request( 'FM_ACN_RETRIEVE', [ copy.call_number() ] );
58                                                 if (typeof volume.ilsevent != 'undefined') throw(volume);
59                                                 g.volumes[ copy.call_number() ] = volume;
60                                                 g.volume_count[ copy.call_number() ] = 1;
61                                         } else {
62                                                 g.volume_count[ copy.call_number() ] += 1;
63                                         }
64                                 }
65         
66                         } catch(E) {
67                                 try {
68                                         g.error.standard_unexpected_error_alert('/xul/server/cat/spine_labels.xul',E);
69                                 } catch(F) {
70                                         alert('FIXME: ' + js2JSON(E));
71                                 }
72                         }
73                 }
74
75                 function $(id) { return document.getElementById(id); }
76
77                 function generate() {
78                         try {
79                                 JSAN.use('util.widgets'); util.widgets.remove_children('panel'); var pn = $('panel'); $('preview').disabled = false;
80                                 var lw = parseInt($('lw').value) || 8;
81                                 var ll = parseInt($('ll').value) || 9;
82                                 for (var i in g.volumes) {
83                                         var hb = document.createElement('vbox'); pn.appendChild(hb); hb.setAttribute('name','template');
84                                         var ds = document.createElement('description'); hb.appendChild(ds);
85                                         ds.appendChild( document.createTextNode( g.volumes[i].label() ) );
86                                         var gb = document.createElement('groupbox'); hb.appendChild(gb); 
87                                         var names = g.volumes[i].label().split(/\s+/).reverse();
88                                         for (var j = 0; j < ll; j++) {
89                                                 var hb2 = document.createElement('hbox'); gb.appendChild(hb2);
90                                                 var tb = document.createElement('textbox'); hb2.appendChild(tb); 
91                                                 tb.setAttribute('class','plain'); tb.setAttribute('style','font-family: monospace');
92                                                 tb.setAttribute('size',lw+1); tb.setAttribute('maxlength',lw);
93                                                 var name = names.pop(); if (!name) continue;
94                                                 if (name.length > lw) {
95                                                         var sname = name.split(/\./);
96                                                         if (sname.length > 1) {
97                                                                 for (var k = 1; k < sname.length; k++) sname[k] = '.' + sname[k];
98                                                                 names = sname.slice(1).concat( names );
99                                                                 if (sname[0].length > lw) {
100                                                                         tb.value = sname[0].substr(0,lw);
101                                                                         names = [ sname[0].substr(lw) ].concat( names );
102                                                                 } else {
103                                                                         tb.value = sname[0];
104                                                                 }
105                                                         } else {
106                                                                 tb.value = name.substr(0,lw);
107                                                                 names = [ name.substr(lw) ].concat( names );
108                                                         }
109                                                 } else {
110                                                         tb.value = name;
111                                                 }
112                                         }
113                                         var vb = document.createElement('vbox'); hb.appendChild(vb);
114                                         var label = document.createElement('label'); vb.appendChild(label);
115                                         label.setAttribute('value','Print how many?');
116                                         var tb = document.createElement('textbox'); vb.appendChild(tb);
117                                         tb.setAttribute('value', g.volume_count[ i ]); tb.setAttribute('name','count');
118                                         var btn = document.createElement('button'); vb.appendChild(btn);
119                                         btn.setAttribute('label','Test Print');
120                                         btn.setAttribute('oncommand',"alert('Not Yet Implemented')");
121                                 }
122                         } catch(E) {
123                                 g.error.standard_unexpected_error_alert('Generate',E);
124                         }
125                 }
126
127                 function preview() {
128                         try {
129                                         netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
130                                         var pt = parseInt( $('pt').value ) || 10; var lm = parseInt($('lm').value) || 11; var lw = parseInt($('lw').value) || 8;
131                                         var ll = parseInt($('ll').value) || 9; var sbl = parseInt($('sbl').value) || 2;
132                                         alert('pt = ' + pt + ' lm = ' + lm + ' lw = ' + lw + ' ll = ' + ll + ' sbl = ' + sbl);
133                                         var html = "<html><head><link type='text/css' rel='stylesheet' href='data:text/css,pre{font-size:" + pt;
134                                         html += "pt}'></link><title>Spine Labels</title></head><body><pre>\n";
135                                         var nl = document.getElementsByAttribute('name','template');
136                                         for (var i = 0; i < nl.length; i++) {
137                                                 var count = parseInt( nl[i].getElementsByAttribute('name','count')[0].value ) || 1;
138                                                 for (var j = 0; j < count; j++) {
139                                                         var gb = nl[i].childNodes[1];
140                                                         var nl2 = gb.getElementsByTagName('textbox');
141                                                         for (var k = 0; k < nl2.length; k++) {
142                                                                 for (var m = 0; m < lm; m++) html += ' ';
143                                                                 html += nl2[k].value + '\n';
144                                                         }
145                                                         for (var k = 0; k < sbl; k++) html += '\n';
146                                                 }
147                                         }
148                                         html += '</pre></body></html>';
149                                         JSAN.use('util.window'); var win = new util.window();
150                                         var loc = xulG.url_prefix( urls.XUL_REMOTE_BROWSER ) + '?url=' + window.escape( 'data:text/html,' + window.escape(html) );
151                                         var w = win.open(
152                                                 loc + '&title=' + window.escape('Spine Labels'),
153                                                 'spine_preview',
154                                                 'chrome,resizable,width=750,height=550'
155                                         );
156                                         w.xulG = { 'show_print_button' : true , 'alternate_print' : true, 'passthru_content_params' : { } };
157                         } catch(E) {
158                                 g.error.standard_unexpected_error_alert('Preview and Print',E);
159                         }
160                 }
161
162         ]]>
163         </script>
164
165         <vbox id="spine_labels_main" flex="1">
166                 <hbox>
167                         <grid><columns><column/><column/><column/><column/></columns><rows>
168                                 <row>
169                                         <label value="Font size (in pts):" control="pt"/><textbox id="pt" value="10"/>
170                                 </row>
171                                 <row>
172                                         <label value="Left Margin (in characters):" control="lm"/><textbox id="lm" value="11"/>
173                                         <label value="Include Copy Numbers?" control="cpn"/><checkbox id="cpn" oncommand="alert('Not Yet Implemented'); this.checked = false;"/>
174                                 </row>
175                                 <row>
176                                         <label value="Label Width (in characters):" control="lw"/><textbox id="lw" value="8"/>
177                                         <label value="Include Copy Locations?" control="cbl"/><checkbox id="cbl" oncommand="alert('Not Yet Implemented'); this.checked = false;"/>
178                                 </row>
179                                 <row>
180                                         <label value="Label Length (in lines):" control="ll"/><textbox id="ll" value="9"/>
181                                         <label value="Include Library Code?" control="lsn"/><checkbox id="lsn" oncommand="alert('Not Yet Implemented'); this.checked = false;"/>
182                                 </row>
183                                 <row>
184                                         <label value="Space Between Labels (in lines):" control="sbl"/><textbox id="sbl" value="2"/>
185                                         <description control="pb">Use form feeds instead of line feeds between labels?</description><checkbox id="pb" oncommand="alert('Not Yet Implemented');this.checked = false;"/>
186                                 </row>
187                         </rows></grid>
188                         <groupbox flex="1">
189                                 <description>Currently, this interface is designed for and tested with an OKI MICROLINE 320 Turbo 9 Pin Printer using SP1 stock (thank you Uncle Remus!).  More to come as time, money, and printer/ink/label donations permit. ;)  Please join the PINES-DEV or OPEN-ILS-DEV mailing lists (at http://open-ils.org/) for discussion on spine labels.</description>
190                                 <spacer style="height: 1em"/>
191                                 <description>PINES: In Windows, we're assuming a generic/text printer device.  The instructions for creating one should be available on the helpdesk.</description>
192                         </groupbox>
193                 </hbox>
194                 <hbox>
195                         <button label="Generate" accesskey="G" oncommand="generate()"/>
196                         <spacer />
197                         <button id="preview" disabled="true" label="Preview and Print" accesskey="P" oncommand="preview()"/>
198                 </hbox>
199                 <hbox id="panel" flex="1" style="overflow: auto"/>
200         </vbox>
201
202 </window>
203