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