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