Bug 16372 - Replace the use of "onclick" for deletion confirmation in some templates
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / patroncards / image-manage.tt
1     [% INCLUDE 'doc-head-open.inc' %]
2     <title>Koha &rsaquo; Tools &rsaquo; Patron card creator &rsaquo; Images</title>
3     [% INCLUDE 'doc-head-close.inc' %]
4     <script type="text/javascript">
5         //<![CDATA[
6             function DeleteConfirm() {
7                 var results = selected_images("delete");
8                 if (results.images != -1) {
9                     var msg = _("Are you sure you want to delete image(s): %s?").format(results.image_ids);
10                     var answer = confirm(msg);
11                     if (answer) {
12                         window.location = "/cgi-bin/koha/patroncards/image-manage.pl?op=delete&" + results.images;
13                     }
14                     else {
15                         return; // abort delete
16                     }
17                 }
18             };
19             function selected_images(op) {
20                 var selected = new Array;
21                 var image_ids = new Array;
22                 if (document.delete_images.action.length) {
23                     for (i=0;i<document.delete_images.action.length;i++){
24                         if (document.delete_images.action[i].checked){
25                             selected.push("image_id=" + document.delete_images.action[i].value);
26                             image_ids.push(document.delete_images.action[i].value);
27                         }
28                     };
29                     images = selected.join("&");
30                     return {images:images, image_ids:image_ids};
31                 }
32                 else if (document.delete_images.action.checked){
33                         return {images:"batch_id="+document.delete_images.action.value, image_ids:document.delete_images.action.value};
34                 };
35                 alert(_("Please select image(s) to %s.").format(op));
36                 return (-1);
37             };
38         $(document).ready(function() {
39             $("#delete").click(function(){
40                 return DeleteConfirm();
41             });
42             $(".delete_image").on("click", function(){
43                 return confirmDelete( _("Are you sure you want to delete this image?") );
44             });
45          });
46         //]]>
47     </script>
48 </head>
49 <body id="pcard_image-manage" class="tools pcard">
50 [% INCLUDE 'header.inc' %]
51 [% INCLUDE 'cat-search.inc' %]
52 <div id="breadcrumbs">
53     <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
54     <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
55     <a href="/cgi-bin/koha/patroncards/home.pl">Patron card creator</a> &rsaquo;
56     Images
57 </div>
58 <div id="doc3" class="yui-t2">
59     <div id="bd">
60         <div id="yui-main">
61             <div class="yui-b">
62                     <div class="yui-g">
63                     [% INCLUDE 'patroncards-toolbar.inc' %]
64                         <div class="yui-u first">
65
66                         </div>
67                     </div>
68                 [% INCLUDE 'patroncards-errors.inc' %]
69                 <div class="yui-g">
70                     <div class="yui-u first">
71                         <h1>Upload images</h1>
72                         <form name="upload_images" method="post" action="/cgi-bin/koha/patroncards/image-manage.pl" enctype="multipart/form-data">
73                             <fieldset class="brief">
74                                 <div class="hint">
75                                     <b>NOTE:</b> Only PNG, GIF, JPEG, XPM formats are supported. Images <b>must</b> be less than 500KB.
76                                 </div>
77                                 <ol>
78                                 <li>
79                                     <label for="uploadfile">Select the file to upload: </label>
80                                     <input type="file" id="uploadfile" name="uploadfile" />
81                                     <input type="hidden" id="image" name="filetype" value="image" />
82                                 </li>
83                                 <li>
84                                     <label for="image_name">Image name: </label>
85                                     <div class="hint">
86                                         This will be the name by which you will refer to this image in the patron card layout editor.
87                                     </div>
88                                     <input type="text" id="image_name" name="image_name" size="20" />
89                                 </li>
90                                 </ol>
91                                 <div class="action">
92                                     <input type="hidden" name="op" value="upload" />
93                                     <input class="btn btn-default" id="uploadsu" type="submit" value="Upload" />
94                                 </div>
95                                 [% IF ( IMPORT_SUCCESSFUL ) %]
96                                     <div class="dialog message">
97                                     <h3>Image successfully uploaded</h3>
98                                     <ul><li>File: [% SOURCE_FILE %]</li>
99                                     <li>Image name: [% IMAGE_NAME %]</li></ul>
100                                     </div>
101                                 [% END %]
102                             </fieldset>
103
104                         </form>
105                     </div>
106                     <div class="yui-u">
107                     <h1>Delete Images</h1>
108                         [% IF ( TABLE ) %]
109                         <form name="delete_images" method="post" action="/cgi-bin/koha/patroncards/image-manage.pl" enctype="multipart/form-data">
110                             <fieldset class="brief">
111                                 <div class="hint">
112                                     Select one or more images to delete.
113                                 </div>
114                                <table>
115                                     [% FOREACH TABL IN TABLE %]
116
117                                     [% IF ( TABL.header_fields ) %]
118
119                                     <tr>
120                                     [% FOREACH header_field IN TABL.header_fields %]
121                                     [% SWITCH header_field.field_label -%]
122                                         [% CASE "ID" %]
123                                             <th>Image ID</th>
124                                         [% CASE "Name" %]
125                                             <th>Name</th>
126                                         [% CASE " " %]
127                                             <th>Delete</th>
128                                         [% CASE %]
129                                            <th>[% header_field.field_label %]</th>
130                                     [% END %]
131                                     [% END %]
132                                     </tr>
133                                     [% ELSE %]
134                                     <tr>
135                                     [% FOREACH text_field IN TABL.text_fields %]
136                                     [% IF ( text_field.select_field ) %]
137                                         <td>
138                                             <a class="delete_image btn btn-mini" href="/cgi-bin/koha/patroncards/image-manage.pl?op=delete&image_id=[% text_field.field_value %]"><icon class="fa fa-trash"></icon> Delete</a>
139                                         </td>
140                                         <td align="center"><input type="checkbox" name="action" value="[% text_field.field_value %]" /></td>
141                                     [% ELSIF ( text_field.field_value ) %]
142                                         <td>[% text_field.field_value %]</td>
143                                     [% ELSE %]
144                                         <td>&nbsp;</td>
145                                     [% END %]
146                                     [% END %]
147                                     </tr>
148                                     [% END %]
149                                     [% END %]
150                                 </table>
151                                 <div class="action">
152                                     <input type="hidden" name="op" value="delete" />
153                                     <input class="btn btn-default" type="button" id="delete" value="Delete selected" />
154                                 </div>
155                                 [% IF ( DELETE_SUCCESSFULL ) %]
156                                 <div id="dialog" class="dialog message">
157                                     <h3>Image(s) successfully deleted</h3>
158                                 </div>
159                                 [% END %]
160                             </fieldset>
161                         </form>
162                         [% ELSE %]
163                         <fieldset class="brief">
164                             <div class="hint">
165                                 No images are currently available.
166                             </div>
167                             [% IF ( DELETE_SUCCESSFULL ) %]
168                                 <div id="dialog" class="dialog message">
169                                     <h3>Image(s) successfully deleted</h3>
170                                 </div>
171                             [% END %]
172                         </fieldset>
173                         [% END %]
174                     </div>
175                 </div>
176             </div>
177         </div>
178         <div class="yui-b">
179           [% INCLUDE 'tools-menu.inc' %]
180         </div>
181     </div>
182     [% INCLUDE 'intranet-bottom.inc' %]