Bug 21993: Display a user-friendly message when the CSRF token is wrong
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / picture-upload.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% SET footerjs = 1 %]
4 [% INCLUDE 'doc-head-open.inc' %]
5 <title>Koha &rsaquo; Tools &rsaquo; Upload patron images</title>
6 [% INCLUDE 'doc-head-close.inc' %]
7 </head>
8
9 <body id="tools_picture-upload" class="tools">
10
11 [% INCLUDE 'header.inc' %]
12 [% INCLUDE 'patron-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 ( TOTAL ) %]<a href="/cgi-bin/koha/tools/picture-upload.pl">Upload patron images</a> &rsaquo; Results[% ELSE %]Upload patron images[% END %] </div>
15
16 [% INCLUDE 'blocking_errors.inc' %]
17 <div class="main container-fluid">
18     <div class="row">
19         <div class="col-sm-10 col-sm-push-2">
20             <main>
21
22 [% IF ( TOTAL ) %]
23             [% IF ( ERRORS ) %]
24                                 [% IF ( TCOUNTS ) %]
25                                         <div class="dialog alert">
26                     <h3>Patron image(s) uploaded with some errors</h3>
27                     </div>
28                                 [% ELSE %]
29                                         <div class="dialog alert">
30                     <h3>Patron image failed to upload</h3>
31                     </div>
32                                 [% END %]
33             [% ELSE %]
34                 <div class="dialog message">
35                 <h3>Patron image(s) successfully uploaded</h3>
36                 </div>
37             [% END %]
38                 <ul class="data">
39                     <li>Unpacking completed</li>
40                   <li>[% TOTAL | html %] directories scanned.</li>
41                     <li>[% HANDLED | html %] directories processed.</li>
42                 </ul>
43
44                 [% FOREACH COUNT IN COUNTS %]
45                 <div class="container">
46                     <table>
47                         <caption>Results</caption>
48                         <thead>
49                             <tr><th>File name</th><th>Card number</th><th>Result</th></tr>
50                         </thead>
51                         <tbody>
52                         [% IF ( COUNT.TCOUNTS ) %]<li>[% COUNT.TCOUNTS | html %] image(s) moved into the database:</li>[% END %]
53                             [% FOREACH filename IN COUNT.filenames %]
54                                 <tr>
55                                 <td>[% filename.source | html %]</td>
56                                 <td><a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% filename.cardnumber | url %]">[% filename.cardnumber | html %]</a></td>
57                                 <td>
58                                     [% IF ( filename.filerrors ) %]
59                                     [% FOREACH filerror IN filename.filerrors %]
60                                         [% IF ( filerror.DBERR ) %]<b>ERROR:</b> Image not imported because the database returned an error. Please refer to the error log for more details.
61                                         [% ELSIF ( filerror.IMGEXISTS ) %]<b>ERROR:</b> Image not imported because this patron does not exist in the database.
62                                         [% ELSIF ( filerror.MIMERR ) %]<b>ERROR:</b> Image not imported because the image format is unrecognized.
63                                         [% ELSIF ( filerror.CORERR ) %]<b>ERROR:</b> Image not imported because the image file is corrupted.
64                                         [% ELSIF ( filerror.OPNERR ) %]<b>ERROR:</b> Image not imported because Koha was unable to open the image for reading.
65                                         [% ELSIF ( filerror.OVRSIZ ) %]<b>ERROR:</b> Image not imported because the image file is too big (see online help for maximum size).
66                                         [% ELSIF ( filerror.CRDFIL ) %]<b>ERROR:</b> Image not imported ([% filerror.CRDFIL | html %] missing).
67                                         [% ELSIF ( filerror.CARDNUMBER_DOES_NOT_EXIST ) %]<b>ERROR:</b> Image not imported because this patron does not exist in the database.
68                                         [% ELSE %]<b>ERROR:</b> Image not imported because of an unknown error. Please refer to the error log for more details.
69                                         [% END %]
70                                     [% END %]
71                                 [% ELSE %] imported successfully.
72                                     [% END %]</td>
73                                 </tr>
74                         [% END %]
75                         </tbody>
76                     </table>
77                     </div>
78                 [% END %]
79 <ul>
80                 [% IF ( borrowernumber ) %]
81                     <li><a id="member" href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber | html %]">Return to patron detail</a></li>
82                 [% ELSE %]
83                     <li><a id="uploadmore" href="/cgi-bin/koha/tools/picture-upload.pl">Upload more images</a></li>
84                     <li><a id="doneupload" href="/cgi-bin/koha/tools/tools-home.pl">Return to tools</a></li>
85                 [% END %]</ul>
86 [% ELSE %]
87                 <h1>Upload patron images</h1>
88                 [% IF ( ERRORS ) %]
89                 <div class="dialog alert">
90                     [% FOREACH ERROR IN ERRORS %]
91                         [% IF ( ERROR.NOTZIP ) %]<li><b>The upload file does not appear to be a zip file.  The extension is not '.zip'.</b></li>
92                         [% ELSIF ( ERROR.NOWRITETEMP ) %]<li><b>This script is not able to create/write to the necessary temporary directory.</b></li>
93                         [% ELSIF ( ERROR.EMPTYUPLOAD ) %]<li><b>The upload file appears to be empty.</b></li>
94                         [% ELSIF ( ERROR.OPNLINK ) %]<li><b>Cannot open [% ERROR.OPNLINK | html %] to read.<br />Please verify that it exists.</b></li>
95                         [% ELSIF ( ERROR.OPNIMG ) %]<li><b>Cannot open [% ERROR.OPNIMG | html %] to read.<br />Please verify that it exists.</b></li>
96                         [% ELSIF ( ERROR.DELERR ) %]<li><b>Unrecognized or missing field delimiter.<br />Please verify that you are using either a single quote or a tab.</b></li>
97                         [% ELSIF ( ERROR.UZIPFAIL ) %]<li><b>[% ERROR.UZIPFAIL | html %] failed to unpack.<br />Please verify the integrity of the ZIP file and retry.</b></li>
98                         [% ELSE %]<li><b>[% ERROR.CORERR | html %] An unknown error has occurred.<br />Please review the error log for more details.</b></li>[% END %]
99                     [% END %]
100                 </div>
101                 [% END %]
102             <form method="post" action="/cgi-bin/koha/tools/picture-upload.pl" enctype="multipart/form-data" id="upload_form">
103                 <fieldset class="rows">
104                     <p><b>NOTE:</b> Only PNG, GIF, JPEG, XPM formats are supported.</p>
105                         <ol class="radio">
106                             <li>
107                                 <label for="zipfile"><input type="radio" id="zipfile" name="filetype" value="zip" checked="checked" /> Zip file</label></li>
108                             <li>
109                                 <label for="image">
110                                 [% 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 %] Image file</label>
111                             </li>
112                             [% IF ( filetype == 'image' ) %]
113                                 <li id="cardnum">
114                             [% ELSE %]
115                                 <li id="cardnum" style="display: none">
116                             [% END %]
117                                 <label for="cardnumber">Enter patron cardnumber: </label>
118                                 <input type="text" id="cardnumber" name="cardnumber" value="[% cardnumber | html %]" size="15" />
119                                 <span class="required">Required</span>
120                             </li>
121                             <li class="required">
122                                 <label for="uploadfile">Select the file to upload: </label>
123                                 <input type="file" id="uploadfile" name="uploadfile" class="required" required="required" />
124                                 <span class="required">Required</span>
125                             </li>
126                         </ol>
127                     </fieldset>
128                     <fieldset class="action">
129                         <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
130                         <input type="hidden" name="op" value="Upload" />
131                         <input type="submit" value="Upload" class="submit" />
132                                                 <a href="/cgi-bin/koha/tools/tools-home.pl" class="cancel">Cancel</a>
133                     </fieldset>
134                 </form>
135 [% END %]
136
137             </main>
138         </div> <!-- /.col-sm-10.col-sm-push-2 -->
139
140         <div class="col-sm-2 col-sm-pull-10">
141             <aside>
142                 [% INCLUDE 'tools-menu.inc' %]
143             </aside>
144         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
145      </div> <!-- /.row -->
146
147 [% MACRO jsinclude BLOCK %]
148     [% Asset.js("js/tools-menu.js") | $raw %]
149     [% INCLUDE 'str/members-menu.inc' %]
150     [% Asset.js("js/members-menu.js") | $raw %]
151     <script>
152         $(document).ready(function() {
153             $("#zipfile").click(function(){
154                 $("#cardnum").hide();
155             });
156             $("#image").click(function(){
157                 $("#cardnum").show();
158             });
159             $( "#upload_form" ).validate({
160                 rules: {
161                     cardnumber: {
162                         required: {
163                             depends: function(element) {
164                                 return $("#image").is(":checked");
165                             }
166                         }
167                     }
168                 }
169             });
170         });
171     </script>
172 [% END %]
173
174 [% INCLUDE 'intranet-bottom.inc' %]