missing </row>
[Evergreen.git] / Evergreen / staff_client / chrome / content / evergreen / cat / spine_label_wizard.xul
1 <?xml version="1.0"?>
2 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
3 <!-- This DTD declaration needs to be fixed for Mozilla locales -->
4 <!DOCTYPE wizard SYSTEM "chrome://evergreen/locale/cat.dtd">
5 <wizard id="spine_label" title="Spine Label Wizard"
6         orient="vertical" style="overflow: auto"
7         onload="spine_label_init()" width="800" height="600"
8         onwizardfinish="print_all_labels()"
9         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
10
11         <!-- Overlays for this XUL file -->
12         <?xul-overlay href="chrome://evergreen/content/OpenSRF/OpenSRF_overlay.xul"?>
13         <?xul-overlay href="chrome://evergreen/content/util/util_overlay.xul"?>
14
15         <!-- OpenSRF -->
16         <script>var myPackageDir = "evergreen";</script>
17         <OpenSRF id="OpenSRF_js" />
18
19         <script>
20         <![CDATA[
21
22                 var spine_labels;
23
24                 function spine_label_init() {
25                         try { spine_labels = params.spine_labels; } catch(E) { sdump('D_ERROR',js2JSON(E) + '\n'); }
26                         if (!spine_labels) spine_labels = [ [ 'A Call Number', '1' ] ];
27                         var rows = document.getElementById('page1_rows');
28                         for (var i = 0; i < spine_labels.length; i++) {
29                                 var sl = spine_labels[i];
30                                 var label = sl[0];
31                                 var count = sl[1];
32                                 var row = document.createElement('row'); rows.appendChild(row);
33                                 var btn = document.createElement('button'); row.appendChild(btn);
34                                         btn.setAttribute('label','Test Print');
35                                 var label_tb = document.createElement('textbox'); row.appendChild(label_tb);
36                                         label_tb.setAttribute('multiline','true');
37                                         label_tb.setAttribute('value',label);
38                                         label_tb.setAttribute('name','label_' + i);
39                                 var count_tb = document.createElement('textbox'); row.appendChild(count_tb);
40                                         count_tb.setAttribute('multiline','true');
41                                         count_tb.setAttribute('value',count);
42                                         count_tb.setAttribute('name','count_' + i);
43                                 btn.addEventListener('command',
44                                         function() {
45                                                 sPrint(label2html(label_tb.value), false, { 'marginLeft' : document.getElementById('margin') } );       
46                                         }, false
47                                 );
48                         }
49                 }
50
51                 function print_all_labels() {
52                         var html = '';
53                         for (var i = 0; i < spine_labels.length; i++) {
54                                 var label = document.getElementsByAttribute('name','label_'+i)[0].value;
55                                 var count = document.getElementsByAttribute('name','count_'+i)[0].value;
56                                 for (var j = 0; j < count; j++) {
57                                         html += label2html(label);
58                                 }
59                         }
60                         sPrint(html, false);
61                 }
62
63                 function label2html(s) {
64                         var html = '';
65                         var a = s.split('\n');
66                         for (var i = 0; i < document.getElementById('rows').value; i++) {
67                                 if (typeof a[i] != 'undefined' ) {
68                                         html += a[i].substr(0,document.getElementById('cols').value);
69                                 }
70                                 html += print_crlf;
71                         }
72                         for (var i = 0; i < document.getElementById('between').value; i++) {
73                                 html += print_crlf;
74                         }
75                         return html;
76                 }
77
78         ]]>
79         </script>
80
81
82         <wizardpage id="page1" description="Printing Spine Labels" onpageadvanced="">
83                 <grid>
84                         <columns> <column flex="0" /> <column flex="1" /> <column flex="0" /> </columns>
85                         <rows id="page1_rows">
86                                 <row><spacer/><description>For this Pre-Beta release, we're focusing on the dot-matrix printers used by PINES (OKI MICROLINE 320 Turbo 9 Pin Printer).  In the future, we will support all manner of label sheets with various printers.  We'll also have optional template variables for things like shelving location, copy number, and barcode.  For now, please check the character dimensions for a spine label, the number of lines between labels, and the left-margin for the printer:</description><grid><columns><column/><column/></columns><rows><row><label value="Left Margin"/><textbox id="margin" value=".63"/></row><row><label value="Columns"/><textbox id="cols" value="9"/></row><row><label value="Rows"/><textbox id="rows" value="9"/></row><row><label value="Lines Between"/><textbox id="between" value="2"/></row></rows></grid></row>
87                                 <row><spacer/></row>
88                                 <row><spacer/><label value="Label" /><label value="Print This Many"/></row>
89                         </rows>
90                 </grid>
91         </wizardpage>
92
93 </wizard>
94
95