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