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