Bug 19679: Move templates JavaScript to the footer: More tools templates
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / upload-images.tt
1 [% SET footerjs = 1 %]
2 [% INCLUDE 'doc-head-open.inc' %]
3 <title>Koha &rsaquo; Tools &rsaquo; Upload images</title>
4 [% INCLUDE 'doc-head-close.inc' %]
5 <style type="text/css">
6     #fileuploadstatus,#fileuploadfailed,#jobpanel,#jobstatus,#jobfailed { display : none; }
7 </style>
8 </head>
9
10 <body id="tools_upload-images" class="tools">
11 [% INCLUDE 'header.inc' %]
12 [% INCLUDE 'cat-search.inc' %]
13
14 <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>
15
16 <div id="doc3" class="yui-t2">
17
18    <div id="bd">
19         <div id="yui-main">
20         <div class="yui-b">
21
22 <h1>Upload local cover image</h1>
23 [% IF ( uploadimage ) %]
24 <p>Image upload results :</p>
25 <ul>
26     <li>[% total %] images found</li>
27     [% IF ( error ) %]
28     <div class="dialog alert">
29     [% IF ( error == 'UZIPFAIL' ) %]<p><b>Failed to unzip archive.<br />Please ensure you are uploading a valid zip file and try again.</b></p>
30     [% ELSIF ( error == 'OPNLINK' ) %]<p><b>Cannot open folder index (idlink.txt or datalink.txt) to read.<br />Please verify that it exists.</b></p>
31     [% 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>
32     [% 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>
33     [% ELSIF ( error == 'DBERR' ) %]<p><b>Unable to save image to database.</b></p>
34     [% ELSE %]<p><b>An unknown error has occurred.<br />Please review the error log for more details.</b></p>[% END %]
35     </div>
36     </li>
37     [% END %]
38     <li><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber %]">View final record</a></li>
39         <li><a href="/cgi-bin/koha/tools/tools-home.pl">Back</a></li>
40 </ul>
41 <hr />
42 [% END %]
43 <ul>
44         <li>Select an image file or ZIP file to upload. The tool will accept images in GIF, JPEG, PNG, and XPM formats.</li>
45 </ul>
46 <form method="post" action="/cgi-bin/koha/tools/upload-cover-image.pl" id="uploadfile" enctype="multipart/form-data">
47 <fieldset class="rows" id="uploadform">
48 <legend>Upload images</legend>
49 <ol>
50         <li>
51         <div id="fileuploadform">
52         <label for="fileToUpload" class="required">Select the file to upload: </label>
53         <input type="file" id="fileToUpload" name="fileToUpload" required="required" class="required" />
54     <span class="required">Required</span>
55         </div>  </li>
56 </ol>
57     <fieldset class="action"><button class="submit btn btn-default btn-sm">Upload file</button></fieldset>
58 </fieldset>
59
60     <div id="uploadpanel">
61         <div id="fileuploadstatus" class="progress_panel">Upload progress:
62             <progress max="100" value="0" id="fileuploadprogress">
63             </progress>
64             <span class="fileuploadpercent">0</span>%
65         </div>
66         <div id="fileuploadfailed"></div>
67     </div>
68 </form>
69
70     <form method="post" id="processfile" action="/cgi-bin/koha/tools/upload-cover-image.pl" enctype="multipart/form-data">
71 <fieldset class="rows">
72         <input type="hidden" name="uploadedfileid" id="uploadedfileid" value="" />
73         <input type="hidden" name="runinbackground" id="runinbackground" value="" />
74         <input type="hidden" name="completedJobID" id="completedJobID" value="" />
75         </fieldset>
76   <fieldset class="rows">
77     <legend>File type</legend>
78     <ol>
79       <li class="radio">
80         [% 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 %]
81         <label for="zipfile">ZIP file</label>
82       </li>
83       <li class="radio">
84         [% 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 %]
85         <label for="image">Image file</label>
86       </li>
87       <li class="radio">
88         [% 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 %]" size="15" /></span>
89       </li>
90     </ol>
91   </fieldset>
92   <fieldset class="rows">
93     <legend>Options</legend>
94     <ol>
95       <li class="checkbox">
96         [% 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 %]
97         <label for="replace">Replace existing covers</label>
98       </li>
99     </ol>
100   </fieldset>
101   <fieldset class="action"><button type="submit" class="btn btn-default btn-sm">Process images</button></fieldset>
102 </form>
103
104 </div>
105 </div>
106 <div class="yui-b">
107 [% INCLUDE 'tools-menu.inc' %]
108 </div>
109 </div>
110
111 [% MACRO jsinclude BLOCK %]
112     <script type="text/javascript" src="[% interface %]/[% theme %]/js/tools-menu.js"></script>
113     <script type="text/javascript" src="[% interface %]/[% theme %]/js/background-job-progressbar.js"></script>
114     <script type="text/javascript" src="[% interface %]/[% theme %]/js/file-upload.js"></script>
115     <script type="text/javascript">
116         function StartUpload() {
117             if( $('#fileToUpload').prop('files').length == 0 ) return;
118             $('#uploadform button.submit').prop('disabled',true);
119             $("#fileuploadstatus").show();
120             $("#uploadedfileid").val('');
121             xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), 'temp=1', cbUpload );
122         }
123         function cbUpload( status, fileid, errors ) {
124             if( status=='done' ) {
125                 $("#uploadedfileid").val( fileid );
126                 $('#fileToUpload').prop('disabled',true);
127                 $("#processfile").show();
128             } else {
129                 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") ];
130                 var errCode = errors[$('#fileToUpload').prop('files')[0].name].code;
131                 $("#fileuploadstatus").hide();
132                 $("#fileuploadfailed").show();
133                 $("#fileuploadfailed").text( _("Upload status: ") +
134                     ( status=='failed'? _("Failed") + " - (" + errCode + ") " + errMsgs[errCode]:
135                     ( status=='denied'? _("Denied"): status ))
136                 );
137                 $("#processfile").hide();
138             }
139         }
140         $(document).ready(function(){
141             $("#processfile").hide();
142             $("#zipfile").click(function(){
143                 $("#bibnum").hide();
144             });
145             $("#image").click(function(){
146                 $("#bibnum").show();
147             });
148             $("#uploadfile").validate({
149                 submitHandler: function(form) {
150                     StartUpload();
151                     return false;
152                 }
153             });
154         });
155     </script>
156 [% END %]
157
158 [% INCLUDE 'intranet-bottom.inc' %]