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