Bug 31203: Add End action to cronjobs and log viewer
[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 'datatables.inc' %]
153
154     <script>
155         $(document).ready(function() {
156
157             var quotes_url = '/api/v1/quotes';
158             var quotes = $("#quotes").kohaTable({
159                 "ajax": {
160                     "url": quotes_url
161                 },
162                 '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>',
163                 "columnDefs": [ {
164                     "targets": [0,1,2,3],
165                     "render": function (data, type, row, meta) {
166                         if ( type == 'display' ) {
167                             if ( data != null ) {
168                                 return data.escapeHtml();
169                             }
170                             else {
171                                 return "";
172                             }
173                         }
174                         return data;
175                     }
176                 } ],
177                 "columns": [
178                     {
179                         "data": "quote_id",
180                         "searchable": true,
181                         "orderable": true
182                     },
183                     {
184                         "data": "source",
185                         "searchable": true,
186                         "orderable": true
187                     },
188                     {
189                         "data": "text",
190                         "searchable": true,
191                         "orderable": true
192                     },
193                     {
194                         "data": "displayed_on",
195                         "render": function(data, type, row, meta) {
196                             return $datetime(row.displayed_on);
197                         },
198                         "searchable": true,
199                         "orderable": true
200                     },
201                     {
202                         "data": function( row, type, val, meta ) {
203
204                             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>';
205                             result += '<form action="/cgi-bin/koha/tools/quotes.pl" method="post">';
206                             result += '<input type="hidden" name="id" value="'+row.quote_id.escapeHtml()+'" />'+"\n";
207
208                             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>';
209
210                             return result;
211                         },
212                         "searchable": false,
213                         "orderable": false
214                     },
215                 ]
216             });
217
218             $('#quotes').on( "click", '.delete_quote', function () {
219                 var quote_id   = decodeURIComponent($(this).data('quote-id'));
220
221                 $("#delete_confirm_dialog").html(
222                     _("You are about to delete the quote #%s.").format(quote_id)
223                 );
224
225                 $("#delete_confirm_modal_button").unbind("click").on( "click", function () {
226                     $.ajax({
227                         method: "DELETE",
228                         url: "/api/v1/quotes/"+quote_id
229                     }).success(function() {
230                         $("#delete_confirm_modal").modal('hide');
231                         quotes.api().ajax.reload(function (data) {
232                             $("#quote_action_result_dialog").hide();
233                             $("#quote_delete_success").html(_("Quote #%s deleted successfully.").format(quote_id)).show();
234                         });
235                     }).error(function () {
236                         $("#quote_delete_error").html(_("Error deleting quote #%s. Check the logs.").format(quote_id)).show();
237                     });
238                 });
239             });
240
241         });
242     </script>
243 [% END %]
244
245 [% INCLUDE 'intranet-bottom.inc' %]