Bug 35378: 'This authority type is used {count} times' missing dot
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / quotes.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% PROCESS 'i18n.inc' %]
4 [% SET footerjs = 1 %]
5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>[% FILTER collapse %]
7     [% IF op == 'add_form' %]
8         [% IF ( quote ) %]
9             [% t("Modify quote") | html %]
10         [% ELSE %]
11             [% t("New quote") | html %]
12         [% END %] &rsaquo;
13     [% END %]
14     [% t("Quote editor") | html %] &rsaquo;
15     [% t("Tools") | html %] &rsaquo;
16     [% t("Koha") | html %]
17 [% END %]</title>
18 [% INCLUDE 'doc-head-close.inc' %]
19 </head>
20
21 <body id="tools_quotes" class="tools">
22 [% WRAPPER 'header.inc' %]
23     [% INCLUDE 'cat-search.inc' %]
24 [% END %]
25
26 [% WRAPPER 'sub-header.inc' %]
27     [% WRAPPER breadcrumbs %]
28         [% WRAPPER breadcrumb_item %]
29             <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
30         [% END %]
31         [% IF op == 'add_form' %]
32             [% WRAPPER breadcrumb_item %]
33                 <a href="/cgi-bin/koha/tools/quotes.pl">Quote editor</a>
34             [% END %]
35             [% WRAPPER breadcrumb_item bc_active= 1 %]
36                 [% IF ( quote ) %]
37                     [% t("Modify quote") | html %]
38                 [% ELSE %]
39                     [% t("New quote") | html %]
40                 [% END %]
41             [% END %]
42         [% ELSE %]
43             [% WRAPPER breadcrumb_item bc_active= 1 %]
44                 <span>Quote editor</span>
45             [% END %]
46         [% END %]
47     [% END #/ WRAPPER breadcrumbs %]
48 [% END #/ WRAPPER sub-header.inc %]
49
50 <div class="main container-fluid">
51     <div class="row">
52         <div class="col-sm-10 col-sm-push-2">
53             <main>
54
55 [% FOREACH m IN messages %]
56     <div class="dialog [% m.type | html %]" id="quote_action_result_dialog">
57         [% SWITCH m.code %]
58         [% CASE 'error_on_update' %]
59             <span>An error occurred when updating this quote. Perhaps it already exists</span>
60         [% CASE 'error_on_insert' %]
61             <span>An error occurred when adding this quote</span>
62         [% CASE 'success_on_update' %]
63             <span>Quote updated successfully</span>
64         [% CASE 'success_on_insert' %]
65             <span>Quote added successfully</span>
66         [% CASE %]
67             <span>[% m.code | html %]</span>
68         [% END %]
69     </div>
70 [% END %]
71
72     <div class="dialog message" id="quote_delete_success" style="display: none;"></div>
73     <div class="dialog alert"   id="quote_delete_error"   style="display: none;"></div>
74
75 [% IF op == 'list' %]
76     <div id="toolbar" class="btn-toolbar">
77         <a class="btn btn-default" id="newquote" href="/cgi-bin/koha/tools/quotes.pl?op=add_form"><i class="fa fa-plus"></i> New quote</a>
78         <a class="btn btn-default" id="import_quotes" href="/cgi-bin/koha/tools/quotes-upload.pl"><i class="fa fa-folder-open"></i> Import quotes</a>
79     </div>
80 [% END %]
81
82 [% IF op == 'add_form' %]
83     <h1>[% IF quote %]Modify quote[% ELSE %]New quote[% END %]</h1>
84     <form action="/cgi-bin/koha/tools/quotes.pl" id="Aform" name="Aform" class="validated" method="post">
85         <fieldset class="rows">
86             <input type="hidden" name="op" value="add_validate" />
87             <ol>
88                 <li>
89                     <label for="text" class="required">Source: </label>
90                     <input type="text" name="source" id="source" value="[% quote.source | html %]" class="required" required="required" />
91                     <span class="required">Required</span>
92                 </li>
93                 <li>
94                     <label for="text" class="required">Text: </label>
95                     <textarea name="text" id="text" class="required" required="required" />[% quote.text | html %]</textarea>
96                     <span class="required">Required</span>
97                 </li>
98             </ol>
99         </fieldset>
100         <fieldset class="action">
101             <input type="hidden" name="id" value="[% quote.id | html %]" />
102             <input type="submit" class="btn btn-primary" value="Submit" />
103             <a class="cancel" href="/cgi-bin/koha/tools/quotes.pl">Cancel</a>
104         </fieldset>
105     </form>
106 [% END %]
107
108 [% IF op == 'delete_confirm' %]
109     <div class="dialog alert">
110         <form action="/cgi-bin/koha/tools/quotes.pl" method="post">
111             <h1>Are you sure you want to delete the following quote?</h1>
112             [% quote.source | html %] - [% quote.text | html %]
113             <input type="hidden" name="op" value="delete_confirmed" />
114             <input type="hidden" name="id" value="[% quote.id | html %]" />
115             <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
116         </form>
117         <form action="/cgi-bin/koha/tools/quotes.pl" method="get">
118             <button type="submit" class="deny"><i class="fa fa-fw fa-times"></i> No, do not delete</button>
119         </form>
120     </div>
121 [% END %]
122
123 [% IF op == 'list' %]
124     <h1>Quotes</h1>
125     [% IF quotes_count > 0 %]
126         <div class="page-section">
127             <table id="quotes">
128                 <thead>
129                     <tr>
130                         <th>ID</th>
131                         <th>Source</th>
132                         <th>Text</th>
133                         <th>Last display</th>
134                         <th data-class-name="actions" class="noExport">Actions</th>
135                     </tr>
136                 </thead>
137             </table>
138         </div> <!-- /.page-section -->
139     [% ELSE %]
140         <div class="dialog message">There are no quotes defined. <a href="/cgi-bin/koha/tools/quotes.pl?op=add_form">Start defining quotes</a>.</div>
141     [% END %]
142
143     <div id="delete_confirm_modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="delete_confirm_modal_label" aria-hidden="true">
144         <div class="modal-dialog">
145             <div class="modal-content">
146                 <div class="modal-header">
147                     <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
148                     <h3 id="delete_confirm_modal_label">Delete quote</h3>
149                 </div>
150                 <div class="modal-body">
151                     <div id="delete_confirm_dialog"></div>
152                 </div>
153                 <div class="modal-footer">
154                     <a href="#" class="btn btn-default" id="delete_confirm_modal_button" role="button" data-toggle="modal">Delete</a>
155                     <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
156                 </div>
157             </div> <!-- /.modal-content -->
158         </div> <!-- /.modal-dialog -->
159     </div> <!-- #delete_confirm_modal -->
160 [% END %]
161
162             </main>
163         </div> <!-- /.col-sm-10.col-sm-push-2 -->
164
165         <div class="col-sm-2 col-sm-pull-10">
166             <aside>
167                 [% INCLUDE 'tools-menu.inc' %]
168             </aside>
169         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
170      </div> <!-- /.row -->
171
172 [% MACRO jsinclude BLOCK %]
173     [% Asset.js("js/tools-menu.js") | $raw %]
174     [% INCLUDE 'datatables.inc' %]
175
176     <script>
177         $(document).ready(function() {
178
179             var quotes_url = '/api/v1/quotes';
180             var quotes = $("#quotes").kohaTable({
181                 "ajax": {
182                     "url": quotes_url
183                 },
184                 'emptyTable': '<div class="dialog message">'+_("There are no quotes defined.")+' <a href="/cgi-bin/koha/tools/quotes.pl?op=add_form">'+_("Start defining quotes")+'</a>.</div>',
185                 "columnDefs": [ {
186                     "targets": [0,1,2,3],
187                     "render": function (data, type, row, meta) {
188                         if ( type == 'display' ) {
189                             if ( data != null ) {
190                                 return data.escapeHtml();
191                             }
192                             else {
193                                 return "";
194                             }
195                         }
196                         return data;
197                     }
198                 } ],
199                 "columns": [
200                     {
201                         "data": "quote_id",
202                         "searchable": true,
203                         "orderable": true
204                     },
205                     {
206                         "data": "source",
207                         "searchable": true,
208                         "orderable": true
209                     },
210                     {
211                         "data": "text",
212                         "searchable": true,
213                         "orderable": true
214                     },
215                     {
216                         "data": "displayed_on",
217                         "render": function(data, type, row, meta) {
218                             return $datetime(row.displayed_on);
219                         },
220                         "searchable": true,
221                         "orderable": true
222                     },
223                     {
224                         "data": function( row, type, val, meta ) {
225
226                             var result = '<a class="btn btn-default btn-xs" href="/cgi-bin/koha/tools/quotes.pl?op=add_form&amp;id='+encodeURIComponent(row.quote_id)+'" role="button"><i class="fa-solid fa-pencil" aria-hidden="true"></i> '+_("Edit")+'</a>';
227                             result += '<form action="/cgi-bin/koha/tools/quotes.pl" method="post">';
228                             result += '<input type="hidden" name="id" value="'+row.quote_id.escapeHtml()+'" />'+"\n";
229
230                             result += '<a class="btn btn-default btn-xs delete_quote" role="button" href="#" data-toggle="modal" data-target="#delete_confirm_modal" data-quote-id="'+ encodeURIComponent(row.quote_id) +'"><i class="fa fa-trash-can" aria-hidden="true"></i> '+_("Delete")+'</a>';
231
232                             return result;
233                         },
234                         "searchable": false,
235                         "orderable": false
236                     },
237                 ]
238             });
239
240             $('#quotes').on( "click", '.delete_quote', function () {
241                 var quote_id   = decodeURIComponent($(this).data('quote-id'));
242
243                 $("#delete_confirm_dialog").html(
244                     _("You are about to delete the quote #%s.").format(quote_id)
245                 );
246
247                 $("#delete_confirm_modal_button").unbind("click").on( "click", function () {
248                     $.ajax({
249                         method: "DELETE",
250                         url: "/api/v1/quotes/"+quote_id
251                     }).success(function() {
252                         $("#delete_confirm_modal").modal('hide');
253                         quotes.api().ajax.reload(function (data) {
254                             $("#quote_action_result_dialog").hide();
255                             $("#quote_delete_success").html(_("Quote #%s deleted successfully.").format(quote_id)).show();
256                         });
257                     }).error(function () {
258                         $("#quote_delete_error").html(_("Error deleting quote #%s. Check the logs.").format(quote_id)).show();
259                     });
260                 });
261             });
262
263         });
264     </script>
265 [% END %]
266
267 [% INCLUDE 'intranet-bottom.inc' %]