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