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