Bug 13618: Add html filters to all the variables
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / stage-marc-import.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% SET footerjs = 1 %]
4 [% INCLUDE 'doc-head-open.inc' %]
5 <title>Koha &rsaquo; Tools &rsaquo; Stage MARC records for import</title>
6 [% INCLUDE 'doc-head-close.inc' %]
7 <style type="text/css">
8     #fileuploadstatus,#fileuploadfailed,#fileuploadcancel,#jobpanel,#jobstatus,#jobfailed { display : none; }
9 </style>
10
11 </head>
12 <body id="tools_stage-marc-import" class="tools">
13 [% INCLUDE 'header.inc' %]
14 [% INCLUDE 'cat-search.inc' %]
15
16 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; [% IF ( uploadmarc ) %]<a href="/cgi-bin/koha/tools/stage-marc-import.pl">Stage MARC records for import</a> &rsaquo; Upload Results[% ELSE %]Stage MARC records for import[% END %]</div>
17
18 <div id="doc3" class="yui-t2">
19    
20    <div id="bd">
21         <div id="yui-main">
22         <div class="yui-b">
23
24 [% IF ( uploadmarc ) %]
25 <div id="toolbar" class="btn-toolbar">
26         <a class="btn btn-default btn-sm" href="/cgi-bin/koha/tools/stage-marc-import.pl"><i class="fa fa-plus"></i> Stage MARC records</a>
27         <a class="btn btn-default btn-sm" href="/cgi-bin/koha/tools/manage-marc-import.pl?import_batch_id=[% import_batch_id | html %]"><i class="fa fa-list-ul"></i> Manage staged records</a>
28 </div>
29 [% END %]
30
31 <h1>Stage MARC records for import</h1>
32 [% IF ( uploadmarc ) %]
33 <p>MARC staging results :</p>
34 <ul>
35     [% SWITCH (record_type) %]
36     [% CASE 'biblio' %]
37         <li>Processing bibliographic records</li>
38     [% CASE 'auth' %]
39         <li>Processing authority records</li>
40     [% END %]
41         <li>[% total | html %]  records in file</li>
42         <li>[% import_errors | html %] records not staged because of MARC error</li>
43         <li>[% staged | html %] records staged</li>
44     [% IF ( checked_matches ) %]
45         <li>[% matched | html %] records with at least one match in catalog per matching rule 
46         &quot;[% matcher_code | html %]&quot;</li>
47     [% ELSE %]
48         [% IF ( matcher_failed ) %]
49           <li>Record matching failed -- unable to retrieve selected matching rule.</li>
50         [% ELSE %]
51           <li>Did not check for matches with existing records in catalog</li>
52         [% END %]
53     [% END %]
54     [% IF record_type == 'biblio' %]
55         <li>[% num_items | html %] item records found and staged</li>
56     [% END %]
57         [% IF ( label_batch ) %]
58           <li>New label batch created: # [% label_batch | html %] </li>
59     [% END %]
60 </ul>
61 [% ELSE %]
62 <ul>
63     <li>Select a MARC file to stage in the import reservoir.  It will be parsed, and each valid record staged for later import into the catalog.</li>
64     <li>You can enter a name for this import. It may be useful, when creating a record, to remember where the suggested MARC data comes from!</li>
65 </ul>
66 <form method="post" action="[% SCRIPT_NAME | html %]" id="uploadfile" enctype="multipart/form-data">
67 <fieldset class="rows" id="uploadform">
68 <legend>Stage records into the reservoir</legend>
69 <ol>
70         <li>
71         <div id="fileuploadform">
72                 <label for="fileToUpload">Select the file to stage: </label>
73                 <input type="file" id="fileToUpload" name="fileToUpload" />
74         </div>  </li>
75 </ol>
76     <fieldset class="action">
77         <button id="fileuploadbutton">Upload file</button>
78         <button id="fileuploadcancel">Cancel</button>
79     </fieldset>
80 </fieldset>
81                 
82     <div id="fileuploadpanel">
83         <div id="fileuploadstatus" class="progress_panel">Upload progress:
84             <progress id="fileuploadprogress" max="100" value="0">
85             </progress>
86             <span class="fileuploadpercent">0</span>%
87         </div>
88         <div id="fileuploadfailed"></div>
89     </div>
90 </form>
91
92     <form method="post" id="processfile" action="[% SCRIPT_NAME | html %]" enctype="multipart/form-data">
93 <fieldset class="rows">
94         <input type="hidden" name="uploadedfileid" id="uploadedfileid" value="" />
95         <input type="hidden" name="runinbackground" id="runinbackground" value="" />
96         <input type="hidden" name="completedJobID" id="completedJobID" value="" />
97         <ol><li>
98                 <label for="comments">Comments about this file: </label>
99                 <input type="text" id="comments" name="comments" />
100                 
101         </li>
102     <li>
103         <label for='record_type'>Record type:</label>
104         <select name='record_type' id='record_type'>
105             <option value='biblio' selected='selected'>Bibliographic</option>
106             <option value='auth'>Authority</option>
107         </select>
108     </li>
109         <li>
110                 <label for="encoding">Character encoding: </label>
111             <select name="encoding" id="encoding">
112                 <option value="UTF-8" selected="selected">UTF-8 (Default)</option>
113                 <option value="MARC-8">MARC 8</option>
114                 <option value="ISO_5426">ISO 5426</option>
115                 <option value="ISO_6937">ISO 6937</option>
116                 <option value="ISO_8859-1">ISO 8859-1</option>
117                 <option value="EUC-KR">EUC-KR</option>
118             </select>
119         </li>
120     <li>
121         <label for='format'>Format:</label>
122         <select name='format' id='format'>
123             <option value='ISO2709'>MARC</option>
124             <option value='MARCXML'>MARCXML</option>
125             [% FOREACH p IN plugins %]
126                 <option value="[% p.metadata.class | html %]">[% p.metadata.name | html %] ( other format via plugin)</option>
127             [% END %]
128         </select>
129     </li>
130 </ol></fieldset>
131
132   [% IF MarcModificationTemplatesLoop %]
133     <fieldset class="rows">
134       <legend>Use MARC Modification Template:</legend>
135       <ol>
136         <li>
137           <label for="comments">Modify record using the following template: </label>
138           <select name="marc_modification_template_id" id="marc_modification_template_id">
139             <option value="">Do not use.</option>
140               [% FOREACH mmt IN MarcModificationTemplatesLoop %]
141                 <option value="[% mmt.template_id | html %]">[% mmt.name | html %]</option>
142               [% END %]
143           </select>
144         </li>
145       </ol>
146     </fieldset>
147   [% END %]
148
149   <fieldset class="rows">
150     <legend>Look for existing records in catalog?</legend>
151     <ol><li><label for="matcher">Record matching rule:</label>
152     <select name="matcher" id="matcher">
153        <option value="">Do not look for matching records</option> 
154        [% FOREACH available_matcher IN available_matchers %]
155           <option value="[% available_matcher.matcher_id | html %]">[% available_matcher.code | html %] ([% available_matcher.description | html %])
156           </option>
157        [% END %]
158     </select>
159     </li>
160       <li><label for="overlay_action">Action if matching record found: </label>
161            [% INCLUDE 'tools-overlay-action.inc' %]
162       </li>
163       <li><label for="nomatch_action">Action if no match is found: </label>
164            [% INCLUDE 'tools-nomatch-action.inc' %]
165       </li>
166     </ol>
167   </fieldset>
168   <fieldset class="rows" id="items">
169     <legend>Check for embedded item record data?</legend>
170     <ol>
171       <li class="radio">
172         <input type="radio" id="parse_itemsyes" name="parse_items" value="1" checked="checked" />
173         <label for="parse_itemsyes">Yes</label>
174       </li>
175       <li class="radio">
176         <input type="radio" id="parse_itemsno" name="parse_items" value="0" />
177         <label for="parse_itemsno">No</label>
178       </li>
179     </ol>
180     <ol>
181       <li><label for="item_action">How to process items: </label>
182            [% INCLUDE 'tools-item-action.inc' %]
183       </li>
184     </ol>
185   </fieldset>
186   <fieldset class="action"><input type="button" id="mainformsubmit" value="Stage for import" /></fieldset>
187  
188        <div id="jobpanel"><div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
189      <div id="jobfailed"></div></div>
190   
191 </form>
192 [% END %]
193
194 </div>
195 </div>
196 <div class="yui-b">
197 [% INCLUDE 'tools-menu.inc' %]
198 </div>
199 </div>
200
201 [% MACRO jsinclude BLOCK %]
202     [% Asset.js("js/tools-menu.js") | $raw %]
203     [% Asset.js("js/background-job-progressbar.js") | $raw %]
204     [% Asset.js("js/file-upload.js") | $raw %]
205     <script type="text/javascript">
206         var xhr;
207         $(document).ready(function(){
208             $("#processfile").hide();
209             $("#record_type").change(function() {
210                 if ($(this).val() == 'auth') {
211                     $('#items').hide();
212                 } else {
213                     $('#items').show();
214                 }
215             });
216             $("#fileuploadbutton").on("click",function(e){
217                 e.preventDefault();
218                 StartUpload();
219             });
220             $("#fileuploadcancel").on("click",function(e){
221                 e.preventDefault();
222                 CancelUpload();
223             });
224             $("#mainformsubmit").on("click",function(){
225                 return CheckForm( document.getElementById("processfile"));
226             });
227         });
228         function CheckForm(f) {
229             if ($("#fileToUpload").value == '') {
230                 alert(_("Please upload a file first."));
231             } else {
232                 return submitBackgroundJob(f);
233             }
234             return false;
235         }
236         function StartUpload() {
237             if( $('#fileToUpload').prop('files').length == 0 ) return;
238             $('#fileuploadbutton').hide();
239             $("#fileuploadfailed").hide();
240             $("#processfile").hide();
241             $("#fileuploadstatus").show();
242             $("#uploadedfileid").val('');
243             xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), 'temp=1', cbUpload );
244             $("#fileuploadcancel").show();
245         }
246         function CancelUpload() {
247             if( xhr ) xhr.abort();
248             $("#fileuploadstatus").hide();
249             $('#fileuploadbutton').show();
250             $("#fileuploadcancel").hide();
251             $("#fileuploadfailed").show();
252             $("#fileuploadfailed").text( _("Upload status: Cancelled ") );
253         }
254         function cbUpload( status, fileid, errors ) {
255             if( status=='done' ) {
256                 $("#uploadedfileid").val( fileid );
257                 $('#fileToUpload').prop('disabled',true);
258                 $('#fileuploadbutton').prop('disabled',true);
259                 $('#fileuploadbutton').show();
260                 $("#fileuploadcancel").hide();
261                 var filename=$('#fileToUpload').prop('files')[0].name;
262                 if( filename.match( new RegExp(/\.[^.]+xml$/) ) ) {
263                     $('#format').val('MARCXML');
264                 }
265                 $("#processfile").show();
266             } else {
267                 var errMsgs = [ _("Error code 0 not used"), _("File already exists"), _("Directory is not writeable"), _("Root directory for uploads not defined"), _("Temporary directory for uploads not defined") ];
268                 var errCode = errors[$('#fileToUpload').prop('files')[0].name].code;
269                 $('#fileuploadbutton').show();
270                 $("#fileuploadcancel").hide();
271                 $("#fileuploadstatus").hide();
272                 $("#fileuploadfailed").show();
273                 $("#fileuploadfailed").text( _("Upload status: ") +
274                     ( status=='failed'? _("Failed") + " - (" + errCode + ") " + errMsgs[errCode]:
275                     ( status=='denied'? _("Denied"): status ))
276                 );
277             }
278         }
279     </script>
280 [% END %]
281
282 [% INCLUDE 'intranet-bottom.inc' %]