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