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