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