Bug 27576: Don't show import recordds table after cleaning a batch
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / upload-images.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% SET footerjs = 1 %]
4 [% INCLUDE 'doc-head-open.inc' %]
5 <title>Koha &rsaquo; Tools &rsaquo; Upload images</title>
6 [% INCLUDE 'doc-head-close.inc' %]
7 <style>
8     #fileuploadstatus,#fileuploadfailed,#jobpanel,#jobstatus,#jobfailed { display : none; }
9 </style>
10 </head>
11
12 <body id="tools_upload-images" class="tools">
13 [% INCLUDE 'header.inc' %]
14 [% INCLUDE 'cat-search.inc' %]
15
16 <div id="breadcrumbs">
17     <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
18     <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
19     <a href="/cgi-bin/koha/tools/upload-cover-image.pl">Upload local cover image</a>
20     [% IF ( uploadimage ) %] &rsaquo; Upload results
21     [% ELSIF itemnumber %] &rsaquo; Upload cover for itemnumber: [% itemnumber | html %]
22     [% ELSIF biblionumber %] &rsaquo; Upload cover for biblionumber: [% biblionumber | html %]
23     [% END %]
24 </div>
25
26 <div class="main container-fluid">
27     <div class="row">
28         <div class="col-sm-10 col-sm-push-2">
29             <main>
30
31                 [% IF ( uploadimage ) %]
32                     <h1>Image upload results :</h1>
33                     <ul>
34                         <li>[% total | html %] images found</li>
35                         [% IF ( error ) %]
36                             <li>
37                                 <div class="dialog alert">
38                                     [% IF ( error == 'UZIPFAIL' ) %]
39                                         <p><strong>Failed to unzip archive.<br />Please ensure you are uploading a valid zip file and try again.</strong></p>
40                                     [% ELSIF ( error == 'OPNLINK' ) %]
41                                         <p><strong>Cannot open folder index (idlink.txt or datalink.txt) to read.<br />Please verify that it exists.</strong></p>
42                                     [% ELSIF ( error == 'OPNIMG' ) %]
43                                         <p><strong>Cannot process file as an image.<br />Please ensure you only upload GIF, JPEG, PNG, or XPM images.</strong></p>
44                                     [% ELSIF ( error == 'DELERR' ) %]
45                                         <p><strong>Unrecognized or missing field delimiter.<br />Please verify that you are using either a single quote or a tab.</strong></p>
46                                     [% ELSIF ( error == 'DBERR' ) %]
47                                         <p><strong>Unable to save image to database.</strong></p>
48                                     [% ELSE %]
49                                         <p><strong>An unknown error has occurred.<br />Please review the error log for more details.</strong></p>
50                                     [% END %]
51                                 </div>
52                             </li>
53                         [% END # /IF error  %]
54                         <li><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | uri %]">View final record</a></li>
55                         <li><a href="/cgi-bin/koha/tools/tools-home.pl">Back</a></li>
56                     </ul>
57                     <hr />
58                 [% END # /IF uploadimage %]
59
60                 [% UNLESS itemnumber || biblionumber %]
61                     <h1>Upload local cover image</h1>
62                 [% ELSIF itemnumber %]
63                     <h1>Upload local cover image for itemnumber: [% itemnumber | html %]</h1>
64                 [% ELSIF biblionumber %]
65                     <h1>Upload local cover image for biblionumber: [% biblionumber | html %]</h1>
66                 [% END %]
67
68                 <ul>
69                     [% UNLESS itemnumber || biblionumber %]
70                         <li>Select an image file or ZIP file to upload. The tool will accept images in GIF, JPEG, PNG, and XPM formats.</li>
71                     [% ELSE %]
72                         <li>Select an image file to upload. The tool will accept images in GIF, JPEG, PNG, and XPM formats.</li>
73                     [% END %]
74                 </ul>
75
76                 <form method="post" action="/cgi-bin/koha/tools/upload-cover-image.pl" id="uploadfile" enctype="multipart/form-data">
77                     <fieldset class="rows" >
78                         <legend>Upload images</legend>
79                         <ol>
80                             <li>
81                                 <div id="fileuploadform">
82                                     <label for="fileToUpload" class="required">Select the file to upload: </label>
83                                     <input type="file" id="fileToUpload" name="fileToUpload" required="required" class="required" />
84                                     <span class="required">Required</span>
85                                 </div>
86                             </li>
87                         </ol>
88                         <fieldset class="action"><button class="submit btn btn-default">Upload file</button></fieldset>
89                     </fieldset>
90
91                     <div id="uploadpanel">
92                         <div id="fileuploadstatus" class="progress_panel">Upload progress:
93                             <progress max="100" value="0" id="fileuploadprogress">
94                             </progress>
95                             <span class="fileuploadpercent">0</span>%
96                         </div>
97                         <div id="fileuploadfailed"></div>
98                     </div>
99                 </form> <!-- /#uploadfile -->
100
101                 <form method="post" id="processfile" action="/cgi-bin/koha/tools/upload-cover-image.pl" enctype="multipart/form-data">
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                     [% UNLESS itemnumber || biblionumber %]
106                         <fieldset class="rows">
107                             <legend>File type</legend>
108                             <ol>
109                                 <li class="radio">
110                                     [% IF (filetype != 'image' ) %]
111                                         <input type="radio" id="zipfile" name="filetype" value="zip" checked="checked" />
112                                     [% ELSE %]
113                                         <input type="radio" id="zipfile" name="filetype" value="zip" />
114                                     [% END %]
115                                     <label for="zipfile">ZIP file</label>
116                                 </li>
117                                 <li class="radio">
118                                     [% IF (filetype == 'image' ) %]
119                                         <input type="radio" id="image" name="filetype" value="image" checked="checked" />
120                                     [% ELSE %]
121                                         <input type="radio" id="image" name="filetype" value="image" />
122                                     [% END %]
123                                     <label for="image">Image file</label>
124                                 </li>
125                                 <li class="radio">
126                                     [% IF ( filetype == 'image' ) %]
127                                         <span id="bibnum">
128                                     [% ELSE %]
129                                         <span id="bibnum" style="display: none">
130                                     [% END %]
131                                     <label for="biblionumber">Enter cover biblionumber: </label>
132                                     <input type="text" id="biblionumber" name="biblionumber" value="[% biblionumber | html %]" size="15" /></span>
133                                 </li>
134                             </ol>
135                         </fieldset>
136                     [% ELSIF itemnumber %]
137                         <input type="hidden" id="itemnumber" name="itemnumber" value="[% itemnumber | html %]" />
138                         <input type="hidden" name="filetype" value="image" />
139                     [% ELSIF biblionumber %]
140                         <input type="hidden" id="biblionumber" name="biblionumber" value="[% biblionumber | html %]" />
141                         <input type="hidden" name="filetype" value="image" />
142                     [% END %]
143                     <fieldset class="rows">
144                         <legend>Options</legend>
145                         <ol>
146                             <li class="checkbox">
147                                 [% IF AllowMultipleCovers == 0 %]
148                                     <input type="checkbox" id="replace" name="replace" checked="checked" disabled="disabled" value="1" />
149                                 [% ELSE %]
150                                     <input type="checkbox" id="replace" name="replace" value="1" />
151                                 [% END %]
152                                 <label for="replace">Replace existing covers</label>
153                             </li>
154                         </ol>
155                     </fieldset>
156                     <fieldset class="action">
157                         <button type="submit" class="btn btn-default btn-sm">Process images</button>
158                     </fieldset>
159                 </form> <!-- /#processfile -->
160
161             </main>
162         </div> <!-- /.col-sm-10.col-sm-push-2 -->
163
164         <div class="col-sm-2 col-sm-pull-10">
165             <aside>
166                 [% INCLUDE 'tools-menu.inc' %]
167             </aside>
168         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
169      </div> <!-- /.row -->
170
171 [% MACRO jsinclude BLOCK %]
172     [% Asset.js("js/tools-menu.js") | $raw %]
173     [% Asset.js("js/file-upload.js") | $raw %]
174     <script>
175         function StartUpload() {
176             if( $('#fileToUpload').prop('files').length == 0 ) return;
177             $('#uploadform button.submit').prop('disabled',true);
178             $("#fileuploadstatus").show();
179             $("#uploadedfileid").val('');
180             xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), 'temp=1', cbUpload );
181         }
182         function cbUpload( status, fileid, errors ) {
183             if( status=='done' ) {
184                 $("#uploadedfileid").val( fileid );
185                 $('#fileToUpload').prop('disabled',true);
186                 $("#processfile").show();
187             } else {
188                 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") ];
189                 var errCode = errors[$('#fileToUpload').prop('files')[0].name].code;
190                 $("#fileuploadstatus").hide();
191                 $("#fileuploadfailed").show();
192                 $("#fileuploadfailed").text( _("Upload status: ") +
193                     ( status=='failed'? _("Failed") + " - (" + errCode + ") " + errMsgs[errCode]:
194                     ( status=='denied'? _("Denied"): status ))
195                 );
196                 $("#processfile").hide();
197             }
198         }
199         $(document).ready(function(){
200             $("#processfile").hide();
201             $("#zipfile").click(function(){
202                 $("#bibnum").hide();
203             });
204             $("#image").click(function(){
205                 $("#bibnum").show();
206             });
207             $("#uploadfile").validate({
208                 submitHandler: function(form) {
209                     StartUpload();
210                     return false;
211                 }
212             });
213         });
214     </script>
215 [% END %]
216
217 [% INCLUDE 'intranet-bottom.inc' %]