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