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