Bug 26145: Allow multi covers per item
[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"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; [% IF ( uploadimage ) %]<a href="/cgi-bin/koha/tools/upload-cover-image.pl">Upload local cover image</a> &rsaquo; Upload results[% ELSE %]Upload local cover image[% 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 <h1>Upload local cover image</h1>
24 [% IF ( uploadimage ) %]
25 <p>Image upload results :</p>
26 <ul>
27     <li>[% total | html %] images found</li>
28     [% IF ( error ) %]
29     <div class="dialog alert">
30     [% IF ( error == 'UZIPFAIL' ) %]<p><strong>Failed to unzip archive.<br />Please ensure you are uploading a valid zip file and try again.</strong></p>
31     [% ELSIF ( error == 'OPNLINK' ) %]<p><strong>Cannot open folder index (idlink.txt or datalink.txt) to read.<br />Please verify that it exists.</strong></p>
32     [% ELSIF ( error == 'OPNIMG' ) %]<p><strong>Cannot process file as an image.<br />Please ensure you only upload GIF, JPEG, PNG, or XPM images.</strong></p>
33     [% ELSIF ( error == 'DELERR' ) %]<p><strong>Unrecognized or missing field delimiter.<br />Please verify that you are using either a single quote or a tab.</strong></p>
34     [% ELSIF ( error == 'DBERR' ) %]<p><strong>Unable to save image to database.</strong></p>
35     [% ELSE %]<p><strong>An unknown error has occurred.<br />Please review the error log for more details.</strong></p>[% END %]
36     </div>
37     </li>
38     [% END %]
39     <li><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | uri %]">View final record</a></li>
40         <li><a href="/cgi-bin/koha/tools/tools-home.pl">Back</a></li>
41 </ul>
42 <hr />
43 [% END %]
44 <ul>
45         <li>Select an image file or ZIP file to upload. The tool will accept images in GIF, JPEG, PNG, and XPM formats.</li>
46 </ul>
47 <form method="post" action="/cgi-bin/koha/tools/upload-cover-image.pl" id="uploadfile" enctype="multipart/form-data">
48 <fieldset class="rows" >
49 <legend>Upload images</legend>
50 <ol>
51         <li>
52         <div id="fileuploadform">
53         <label for="fileToUpload" class="required">Select the file to upload: </label>
54         <input type="file" id="fileToUpload" name="fileToUpload" required="required" class="required" />
55     <span class="required">Required</span>
56         </div>  </li>
57 </ol>
58     <fieldset class="action"><button class="submit btn btn-default">Upload file</button></fieldset>
59 </fieldset>
60
61     <div id="uploadpanel">
62         <div id="fileuploadstatus" class="progress_panel">Upload progress:
63             <progress max="100" value="0" id="fileuploadprogress">
64             </progress>
65             <span class="fileuploadpercent">0</span>%
66         </div>
67         <div id="fileuploadfailed"></div>
68     </div>
69 </form>
70
71     <form method="post" id="processfile" action="/cgi-bin/koha/tools/upload-cover-image.pl" enctype="multipart/form-data">
72 <fieldset class="rows">
73         <input type="hidden" name="uploadedfileid" id="uploadedfileid" value="" />
74         <input type="hidden" name="runinbackground" id="runinbackground" value="" />
75         <input type="hidden" name="completedJobID" id="completedJobID" value="" />
76         </fieldset>
77   <fieldset class="rows">
78     <legend>File type</legend>
79     <ol>
80       [% UNLESS itemnumber %]
81         <li class="radio">
82           [% IF (filetype != 'image' ) %]<input type="radio" id="zipfile" name="filetype" value="zip" checked="checked" />[% ELSE %]<input type="radio" id="zipfile" name="filetype" value="zip" />[% END %]
83           <label for="zipfile">ZIP file</label>
84         </li>
85         <li class="radio">
86           [% IF (filetype == 'image' ) %]<input type="radio" id="image" name="filetype" value="image" checked="checked" />[% ELSE %]<input type="radio" id="image" name="filetype" value="image" />[% END %]
87           <label for="image">Image file</label>
88         </li>
89         <li class="radio">
90           [% IF ( filetype == 'image' ) %]<span id="bibnum">[% ELSE %]<span id="bibnum" style="display: none">[% END %]<label for="biblionumber">Enter cover biblionumber: </label><input type="text" id="biblionumber" name="biblionumber" value="[% biblionumber | html %]" size="15" /></span>
91         </li>
92       [% ELSE %]
93           <label for="itemnumber">Cover itemnumber: </label>
94           <input type="text" id="itemnumber" name="itemnumber" value="[% itemnumber | html %]" size="15" readonly="readonly" />
95           <input type="hidden" name="filetype" value="image" />
96       [% END %]
97     </ol>
98   </fieldset>
99   <fieldset class="rows">
100     <legend>Options</legend>
101     <ol>
102       <li class="checkbox">
103         [% IF AllowMultipleCovers == 0 %]
104             <input type="checkbox" id="replace" name="replace" checked="checked" disabled="disabled" value="1" />
105         [% ELSE %]
106             <input type="checkbox" id="replace" name="replace" value="1" />
107         [% END %]
108         <label for="replace">Replace existing covers</label>
109       </li>
110     </ol>
111   </fieldset>
112   <fieldset class="action"><button type="submit" class="btn btn-default btn-sm">Process images</button></fieldset>
113 </form>
114
115             </main>
116         </div> <!-- /.col-sm-10.col-sm-push-2 -->
117
118         <div class="col-sm-2 col-sm-pull-10">
119             <aside>
120                 [% INCLUDE 'tools-menu.inc' %]
121             </aside>
122         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
123      </div> <!-- /.row -->
124
125 [% MACRO jsinclude BLOCK %]
126     [% Asset.js("js/tools-menu.js") | $raw %]
127     [% Asset.js("js/file-upload.js") | $raw %]
128     <script>
129         function StartUpload() {
130             if( $('#fileToUpload').prop('files').length == 0 ) return;
131             $('#uploadform button.submit').prop('disabled',true);
132             $("#fileuploadstatus").show();
133             $("#uploadedfileid").val('');
134             xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), 'temp=1', cbUpload );
135         }
136         function cbUpload( status, fileid, errors ) {
137             if( status=='done' ) {
138                 $("#uploadedfileid").val( fileid );
139                 $('#fileToUpload').prop('disabled',true);
140                 $("#processfile").show();
141             } else {
142                 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") ];
143                 var errCode = errors[$('#fileToUpload').prop('files')[0].name].code;
144                 $("#fileuploadstatus").hide();
145                 $("#fileuploadfailed").show();
146                 $("#fileuploadfailed").text( _("Upload status: ") +
147                     ( status=='failed'? _("Failed") + " - (" + errCode + ") " + errMsgs[errCode]:
148                     ( status=='denied'? _("Denied"): status ))
149                 );
150                 $("#processfile").hide();
151             }
152         }
153         $(document).ready(function(){
154             $("#processfile").hide();
155             $("#zipfile").click(function(){
156                 $("#bibnum").hide();
157             });
158             $("#image").click(function(){
159                 $("#bibnum").show();
160             });
161             $("#uploadfile").validate({
162                 submitHandler: function(form) {
163                     StartUpload();
164                     return false;
165                 }
166             });
167         });
168     </script>
169 [% END %]
170
171 [% INCLUDE 'intranet-bottom.inc' %]