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