Bug 21333: (follow-up) Make link a button
[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 [% IF basketno && booksellerid %]
62 <p>
63     <a id="addtobasket" class="btn btn-default btn-sm" 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>
64 </p>
65 [% END %]
66 [% ELSE %]
67 <ul>
68     <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>
69     <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>
70 </ul>
71 <form method="post" action="[% SCRIPT_NAME | html %]" id="uploadfile" enctype="multipart/form-data">
72 <fieldset class="rows" id="uploadform">
73 <legend>Stage records into the reservoir</legend>
74 <ol>
75         <li>
76         <div id="fileuploadform">
77                 <label for="fileToUpload">Select the file to stage: </label>
78                 <input type="file" id="fileToUpload" name="fileToUpload" />
79         </div>  </li>
80 </ol>
81     <fieldset class="action">
82         <button id="fileuploadbutton">Upload file</button>
83         <button id="fileuploadcancel">Cancel</button>
84     </fieldset>
85 </fieldset>
86                 
87     <div id="fileuploadpanel">
88         <div id="fileuploadstatus" class="progress_panel">Upload progress:
89             <progress id="fileuploadprogress" max="100" value="0">
90             </progress>
91             <span class="fileuploadpercent">0</span>%
92         </div>
93         <div id="fileuploadfailed"></div>
94     </div>
95 </form>
96
97     <form method="post" id="processfile" action="[% SCRIPT_NAME | html %]" enctype="multipart/form-data">
98 [% IF basketno && booksellerid %]
99     <input type="hidden" name="basketno" id="basketno" value="[% basketno | html %]" />
100     <input type="hidden" name="booksellerid" id="booksellerid" value="[% booksellerid | html %]" />
101 [% END %]
102 <fieldset class="rows">
103         <input type="hidden" name="uploadedfileid" id="uploadedfileid" value="" />
104         <input type="hidden" name="runinbackground" id="runinbackground" value="" />
105         <input type="hidden" name="completedJobID" id="completedJobID" value="" />
106         <ol><li>
107                 <label for="comments">Comments about this file: </label>
108                 <input type="text" id="comments" name="comments" />
109                 
110         </li>
111     <li>
112         <label for='record_type'>Record type:</label>
113         <select name='record_type' id='record_type'>
114             <option value='biblio' selected='selected'>Bibliographic</option>
115             <option value='auth'>Authority</option>
116         </select>
117     </li>
118         <li>
119                 <label for="encoding">Character encoding: </label>
120             <select name="encoding" id="encoding">
121                 <option value="UTF-8" selected="selected">UTF-8 (Default)</option>
122                 <option value="MARC-8">MARC 8</option>
123                 <option value="ISO_5426">ISO 5426</option>
124                 <option value="ISO_6937">ISO 6937</option>
125                 <option value="ISO_8859-1">ISO 8859-1</option>
126                 <option value="EUC-KR">EUC-KR</option>
127             </select>
128         </li>
129     <li>
130         <label for='format'>Format:</label>
131         <select name='format' id='format'>
132             <option value='ISO2709'>MARC</option>
133             <option value='MARCXML'>MARCXML</option>
134             [% FOREACH p IN plugins %]
135                 <option value="[% p.metadata.class | html %]">[% p.metadata.name | html %] ( other format via plugin)</option>
136             [% END %]
137         </select>
138     </li>
139 </ol></fieldset>
140
141   [% IF MarcModificationTemplatesLoop %]
142     <fieldset class="rows">
143       <legend>Use MARC Modification Template:</legend>
144       <ol>
145         <li>
146           <label for="comments">Modify record using the following template: </label>
147           <select name="marc_modification_template_id" id="marc_modification_template_id">
148             <option value="">Do not use.</option>
149               [% FOREACH mmt IN MarcModificationTemplatesLoop %]
150                 <option value="[% mmt.template_id | html %]">[% mmt.name | html %]</option>
151               [% END %]
152           </select>
153         </li>
154       </ol>
155     </fieldset>
156   [% END %]
157
158   <fieldset class="rows">
159     <legend>Look for existing records in catalog?</legend>
160     <ol><li><label for="matcher">Record matching rule:</label>
161     <select name="matcher" id="matcher">
162        <option value="">Do not look for matching records</option> 
163        [% FOREACH available_matcher IN available_matchers %]
164           <option value="[% available_matcher.matcher_id | html %]">[% available_matcher.code | html %] ([% available_matcher.description | html %])
165           </option>
166        [% END %]
167     </select>
168     </li>
169       <li><label for="overlay_action">Action if matching record found: </label>
170            [% INCLUDE 'tools-overlay-action.inc' %]
171       </li>
172       <li><label for="nomatch_action">Action if no match is found: </label>
173            [% INCLUDE 'tools-nomatch-action.inc' %]
174       </li>
175     </ol>
176   </fieldset>
177   <fieldset class="rows" id="items">
178     <legend>Check for embedded item record data?</legend>
179     <ol>
180       <li class="radio">
181         <input type="radio" id="parse_itemsyes" name="parse_items" value="1" checked="checked" />
182         <label for="parse_itemsyes">Yes</label>
183       </li>
184       <li class="radio">
185         <input type="radio" id="parse_itemsno" name="parse_items" value="0" />
186         <label for="parse_itemsno">No</label>
187       </li>
188     </ol>
189     <ol>
190       <li><label for="item_action">How to process items: </label>
191            [% INCLUDE 'tools-item-action.inc' %]
192       </li>
193     </ol>
194   </fieldset>
195   <fieldset class="action"><input type="button" id="mainformsubmit" value="Stage for import" /></fieldset>
196  
197        <div id="jobpanel"><div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
198      <div id="jobfailed"></div></div>
199   
200 </form>
201 [% END %]
202
203 </div>
204 </div>
205 <div class="yui-b">
206 [% INCLUDE 'tools-menu.inc' %]
207 </div>
208 </div>
209
210 [% MACRO jsinclude BLOCK %]
211     [% Asset.js("js/tools-menu.js") | $raw %]
212     [% Asset.js("js/background-job-progressbar.js") | $raw %]
213     [% Asset.js("js/file-upload.js") | $raw %]
214     <script type="text/javascript">
215         var xhr;
216         $(document).ready(function(){
217             $("#processfile").hide();
218             $("#record_type").change(function() {
219                 if ($(this).val() == 'auth') {
220                     $('#items').hide();
221                 } else {
222                     $('#items').show();
223                 }
224             });
225             $("#fileuploadbutton").on("click",function(e){
226                 e.preventDefault();
227                 StartUpload();
228             });
229             $("#fileuploadcancel").on("click",function(e){
230                 e.preventDefault();
231                 CancelUpload();
232             });
233             $("#mainformsubmit").on("click",function(){
234                 return CheckForm( document.getElementById("processfile"));
235             });
236         });
237         function CheckForm(f) {
238             if ($("#fileToUpload").value == '') {
239                 alert(_("Please upload a file first."));
240             } else {
241                 return submitBackgroundJob(f);
242             }
243             return false;
244         }
245         function StartUpload() {
246             if( $('#fileToUpload').prop('files').length == 0 ) return;
247             $('#fileuploadbutton').hide();
248             $("#fileuploadfailed").hide();
249             $("#processfile").hide();
250             $("#fileuploadstatus").show();
251             $("#uploadedfileid").val('');
252             xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), 'temp=1', cbUpload );
253             $("#fileuploadcancel").show();
254         }
255         function CancelUpload() {
256             if( xhr ) xhr.abort();
257             $("#fileuploadstatus").hide();
258             $('#fileuploadbutton').show();
259             $("#fileuploadcancel").hide();
260             $("#fileuploadfailed").show();
261             $("#fileuploadfailed").text( _("Upload status: Cancelled ") );
262         }
263         function cbUpload( status, fileid, errors ) {
264             if( status=='done' ) {
265                 $("#uploadedfileid").val( fileid );
266                 $('#fileToUpload').prop('disabled',true);
267                 $('#fileuploadbutton').prop('disabled',true);
268                 $('#fileuploadbutton').show();
269                 $("#fileuploadcancel").hide();
270                 var filename=$('#fileToUpload').prop('files')[0].name;
271                 if( filename.match( new RegExp(/\.[^.]+xml$/) ) ) {
272                     $('#format').val('MARCXML');
273                 }
274                 $("#processfile").show();
275             } else {
276                 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") ];
277                 var errCode = errors[$('#fileToUpload').prop('files')[0].name].code;
278                 $('#fileuploadbutton').show();
279                 $("#fileuploadcancel").hide();
280                 $("#fileuploadstatus").hide();
281                 $("#fileuploadfailed").show();
282                 $("#fileuploadfailed").text( _("Upload status: ") +
283                     ( status=='failed'? _("Failed") + " - (" + errCode + ") " + errMsgs[errCode]:
284                     ( status=='denied'? _("Denied"): status ))
285                 );
286             }
287         }
288     </script>
289 [% END %]
290
291 [% INCLUDE 'intranet-bottom.inc' %]