Bug 21526: uri escape TT variables when used in 'a href'
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / circ / checkout-notes.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE KohaDates %]
5 [% USE Branches %]
6 [% SET footerjs = 1 %]
7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>Home &rsaquo; Circulation &rsaquo; Checkout notes</title>
9 [% INCLUDE 'doc-head-close.inc' %]
10 [% Asset.css("css/datatables.css") | $raw %]
11 </head>
12
13 <body id="circ_checkout-notes" class="circ">
14
15 [% INCLUDE 'header.inc' %]
16 [% INCLUDE 'circ-search.inc' %]
17 <div id="breadcrumbs">
18     <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
19     <a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a> &rsaquo;
20     Checkout notes
21 </div>
22
23 [% IF Koha.Preference('CircSidebar') %]<div id="doc3" class="yui-t2">[% ELSE %]<div id="doc" class="yui-t7">[% END %]
24     <div id="bd">
25         <div id="yui-main">
26         [% IF Koha.Preference('CircSidebar') %]<div class="yui-b">[% END %]
27
28             <h1>Checkout notes</h1>
29
30             <div class="dialog alert" id="error" style="display:none;"></div>
31
32             [% IF ( selected_count ) %]
33                 <div class="dialog message">
34                     [% IF ( action == 'seen' ) %]
35                         <span>[% selected_count | html %] note(s) marked as seen.</span>
36                     [% ELSIF ( action == 'notseen' ) %]
37                         <span>[% selected_count | html %] note(s) marked as not seen.</span>
38                     [% ELSE %]
39                         <span>Failed to change the status of [% selected_count | html %] item(s).</span>
40                     [% END %]
41                 </div>
42             [% END %]
43
44             [% IF ( notes.count ) %]
45                 <fieldset class="action" style="cursor:pointer;">
46                     <a class="SelectAll"><i class="fa fa-check"></i> Select all</a>
47                     | <a class="ClearAll"><i class="fa fa-remove"></i> Clear all</a>
48                     | <a class="HideSeen"><i class="fa fa-minus-square"></i> Hide seen</a>
49                     | <a class="ShowAll"><i class="fa fa-bars"></i> Show all</a>
50                 </fieldset>
51
52                 <form id="mark_selected" method="post" action="/cgi-bin/koha/circ/checkout-notes.pl">
53
54                     <fieldset class="action">
55                         <button type="submit" class="btn btn-default btn-sm" name="mark_selected-seen" value="seen" disabled="disabled"><i class="fa fa-eye"></i> Mark seen</button>
56                         <button type="submit" class="btn btn-default btn-sm" name="mark_selected-notseen" value="notseen" disabled="disabled"><i class="fa fa-eye-slash"></i> Mark not seen</button>
57                     </fieldset>
58
59                     <table id="notestable">
60                         <thead>
61                             <tr>
62                                 <th>&nbsp;</th>
63                                 <th>Title</th>
64                                 <th>Note</th>
65                                 <th class="title-string">Date</th>
66                                 <th>Set by</th>
67                                 <th>Status</th>
68                                 <th>Actions</th>
69                             </tr>
70                         </thead>
71                         <tbody>
72                             [% FOREACH note IN notes %]
73                                 <tr>
74                                     <td><input type="checkbox" name="issue_ids" value="[% note.issue_id | html %]"></td>
75                                     <td>[% note.item.biblio.title | html %] - [% note.item.biblio.author | html %] (<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% note.item.biblionumber | uri %]">[% note.item.barcode | html %]</a>)</td>
76                                     <td>[% note.note | html %]</td>
77                                     <td><span title="[% note.notedate | html %]">[% note.notedate | $KohaDates %]</span></td>
78                                     <td>[% INCLUDE 'patron-title.inc' patron => note.patron hide_patron_infos_if_needed=1 %]</td>
79                                     <td class="seen[% note.noteseen | html %]">
80                                         [% IF ( note.noteseen == 0 ) %]
81                                             <span id="status_[% note.issue_id | html %]">Not seen</span>
82                                         [% ELSIF ( note.noteseen == 1 ) %]
83                                             <span id="status_[% note.issue_id | html %]">Seen</span>
84                                         [% END %]
85                                     </td>
86                                     <td class="actions">
87                                         [% IF ( note.noteseen == 1 ) %]
88                                             <button name="seen" data-issue_id="[% note.issue_id | html %]" class="seen btn btn-default btn-xs" disabled="disabled"><i class="fa fa-eye"></i> Mark seen</button> <button name="notseen" data-issue_id="[% note.issue_id | html %]" class="notseen btn btn-default btn-xs"><i class="fa fa-eye-slash"></i> Mark not seen</button>
89                                         [% ELSIF ( note.noteseen == 0 ) %]
90                                             <button name="seen" data-issue_id="[% note.issue_id | html %]" class="seen btn btn-default btn-xs"><i class="fa fa-eye"></i> Mark seen</button> <button name="notseen" data-issue_id="[% note.issue_id | html %]" class="notseen btn btn-default btn-xs" disabled="disabled"><i class="fa fa-eye-slash"></i> Mark not seen</button>
91                                         [% END %]
92                                     </td>
93                                 </tr>
94                             [% END %]
95                         </tbody>
96                     </table>
97
98                 </form>
99
100             [% ELSE %]
101                 <span>There are currently no checkout notes.</span>
102             [% END %] <!-- notes -->
103
104         </div> <!-- yui-main -->
105
106         [% IF Koha.Preference('CircSidebar') %]
107         </div>
108
109         <div class="yui-b noprint">
110             [% INCLUDE 'circ-nav.inc' %]
111         </div>
112         [% END %]
113
114     </div> <!-- bd -->
115 </div> <!-- doc3 -->
116
117 [% MACRO jsinclude BLOCK %]
118     [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
119     [% INCLUDE 'calendar.inc' %]
120     [% INCLUDE 'datatables.inc' %]
121     <script>
122         $(document).ready(function(){
123             $("#notestable").dataTable($.extend(true, {}, dataTablesDefaults, {
124                 "aoColumnDefs": [
125                     { "aTargets": [ 0, -1 ], "bSearchable": false, "bSortable": false },
126                     { "sType": "title-string", "aTargets" : [ "title-string" ] },
127                 ],
128                 "sPaginationType": "four_button"
129             }));
130
131             $(".SelectAll").on("click", function(){
132                 $("input[name='issue_ids'][type='checkbox']").prop("checked", true);
133                 $(".btn-sm").prop("disabled", false);
134             });
135
136             $(".ClearAll").on("click", function(){
137                 $("input[name='issue_ids'][type='checkbox']").prop("checked", false);
138                 $(".btn-sm").prop("disabled", true);
139             });
140
141             $(".HideSeen").on("click", function(){
142                 $(".seen1").parent().hide();
143             });
144
145             $(".ShowAll").on("click", function(){
146                 $("tr").show();
147             });
148
149             $("#error").hide();
150
151             $("input[type='checkbox']").click(function(event){
152                 if ( $("input[type='checkbox']").is(":checked") ) {
153                     $(".btn-sm").prop("disabled", false);
154                 } else {
155                     $(".btn-sm").prop("disabled", true);
156                 }
157             });
158
159             $("button.seen, button.notseen").click(function(event){
160                 event.preventDefault(); // prevent form submission
161                 var $action = $(this).attr("name");
162                 var $issue_id = $(this).data('issue_id');
163                 var ajaxData = {
164                     'action': $action,
165                     'issue_id': $issue_id,
166                 };
167
168                 $.ajax({
169                     url: '/cgi-bin/koha/svc/checkout_notes/',
170                     type: 'POST',
171                     dataType: 'json',
172                     data: ajaxData,
173                 })
174
175                 .done(function(data){
176                     if (data.status == 'success'){
177                         if ( $action == 'notseen' ){
178                             $("#status_" + $issue_id).text(_("Not seen"));
179                             $(event.target).parent().siblings(".seen1").removeClass("seen1").addClass("seen0");
180                             $(event.target).siblings(".seen").prop("disabled", false);
181                             $(event.target).prop("disabled", true);
182                         } else {
183                             $("#status_" + $issue_id).text(_("Seen"));
184                             $(event.target).parent().siblings(".seen0").removeClass("seen0").addClass("seen1");
185                             $(event.target).siblings(".notseen").prop("disabled", false);
186                             $(event.target).prop("disabled", true);
187                         }
188                     } else {
189                         $("#error").text(_("Unable to change status of note."));
190                         $("#error").show();
191                     }
192                 })
193                 .error(function(data){
194                     $("#error").text(_("Unable to change status of note."));
195                     $("#error").show();
196                 });
197             });
198         });
199     </script>
200 [% END %]
201
202 [% INCLUDE 'intranet-bottom.inc' %]