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