b2e0ea5a08f79536b6e5d0ee6dd44fc276c18d97
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / problem-reports.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE KohaDates %]
5 [% SET footerjs = 1 %]
6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>Koha &rsaquo; Administration &rsaquo; OPAC problem reports</title>
8 [% INCLUDE 'doc-head-close.inc' %]
9 </head>
10
11 <body id="admin_problem-reports" class="admin">
12
13 [% INCLUDE 'header.inc' %]
14 [% INCLUDE 'prefs-admin-search.inc' %]
15 <div id="breadcrumbs">
16     <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
17     <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo;
18     OPAC problem reports
19 </div>
20
21 <div class="main container-fluid">
22     <div class="row">
23         <div class="col-sm-10 col-sm-push-2">
24             <main>
25
26             <h1>OPAC problem reports</h1>
27
28             <div class="dialog alert" id="error" style="display:none;"></div>
29
30             [% IF ( selected_count ) %]
31                 <div class="dialog message">
32                     [% IF ( action == 'viewed' ) %]
33                         <span>[% selected_count | html %] problem report(s) marked as viewed.</span>
34                     [% ELSIF ( action == 'closed' ) %]
35                         <span>[% selected_count | html %] problem report(s) marked as closed.</span>
36                     [% ELSIF ( action == 'new' ) %]
37                         <span>[% selected_count | html %] problem report(s) marked as new.</span>
38                     [% ELSE %]
39                         <span>Failed to change the status of [% selected_count | html %] problem report(s).</span>
40                     [% END %]
41                 </div>
42             [% END %]
43
44             [% IF ( problem_reports.count ) %]
45                 <form id="mark_selected" method="post" action="/cgi-bin/koha/admin/problem-reports.pl">
46                     <div id="toolbar" class="btn-toolbar">
47                         <button type="submit" class="btn btn-default markviewed" name="mark_selected-viewed" value="viewed" disabled="disabled"><i class="fa fa-eye"></i> Mark viewed</button>
48                         <button type="submit" class="btn btn-default markclosed" name="mark_selected-closed" value="closed" disabled="disabled"><i class="fa fa-times-circle"></i> Mark closed</button>
49                         <button type="submit" class="btn btn-default marknew" name="mark_selected-new" value="new" disabled="disabled"><i class="fa fa-star"></i> Mark new</button>
50                     </div>
51
52                     <fieldset class="action" style="cursor:pointer;">
53                         <a class="SelectAll"><i class="fa fa-check"></i> Select all</a>
54                         | <a class="ClearAll"><i class="fa fa-remove"></i> Clear all</a>
55                         | <a class="HideViewed"><i class="fa fa-minus-square"></i> Hide viewed</a>
56                         | <a class="HideClosed"><i class="fa fa-minus-square"></i> Hide closed</a>
57                         | <a class="HideNew"><i class="fa fa-minus-square"></i> Hide new</a>
58                         | <a class="ShowAll"><i class="fa fa-bars"></i> Show all</a>
59                     </fieldset>
60
61                     <table id="problemreportstable">
62                         <thead>
63                             <tr>
64                                 <th class="NoSort">&nbsp;</th>
65                                 <th class="anti-the">Message</th>
66                                 <th>Problem page</th>
67                                 <th>Sent to</th>
68                                 <th class="title-string">Created on</th>
69                                 <th>Set by</th>
70                                 <th>Status</th>
71                                 <th class="NoSort">Actions</th>
72                             </tr>
73                         </thead>
74                         <tbody>
75                             [% FOREACH report IN problem_reports %]
76                                 <tr>
77                                     <td><input type="checkbox" name="report_ids" value="[% report.reportid | html %]"></td>
78                                     <td>
79                                         <b>[% report.title | html %]</b><br>
80                                         [% report.content | html %]
81                                     </td>
82                                     <td><a href="[% OPACBaseURL | url %][% report.problempage | url %]">[% OPACBaseURL | url %][% report.problempage | html %]</a></td>
83                                     <td>[% report.recipient | html %]</td>
84                                     <td><span title="[% report.created_on | html %]">[% report.created_on | $KohaDates with_hours => 1 %]</span></td>
85                                     <td>[% INCLUDE 'patron-title.inc' patron => report.patron hide_patron_infos_if_needed=1 %]</td>
86                                     <td class="status[% report.status | html %]" name="status"><span id="status_[% report.reportid | html %]">[% report.status | html %]</span></td>
87                                     <td class="actions">
88                                         [% IF ( report.status == 'New' ) %]
89                                             <button name="viewed" data-report_id="[% report.reportid | html %]" class="viewed btn btn-default btn-xs"><i class="fa fa-eye"></i> Mark viewed</button> <button name="closed" data-report_id="[% report.reportid | html %]" class="closed btn btn-default btn-xs"><i class="fa fa-times-circle"></i> Mark closed</button> <button name="new" disabled="disabled" data-report_id="[% report.reportid | html %]" class="new btn btn-default btn-xs"><i class="fa fa-star"></i> Mark new</button>
90                                         [% ELSIF ( report.status == 'Viewed' ) %]
91                                             <button name="viewed" disabled="disabled" data-report_id="[% report.reportid | html %]" class="viewed btn btn-default btn-xs"><i class="fa fa-eye"></i> Mark viewed</button> <button name="closed" data-report_id="[% report.reportid | html %]" class="closed btn btn-default btn-xs"><i class="fa fa-times-circle"></i> Mark closed</button> <button name="new" data-report_id="[% report.reportid | html %]" class="new btn btn-default btn-xs"><i class="fa fa-star"></i> Mark new</button>
92                                         [% ELSE %]
93                                             <button name="viewed" data-report_id="[% report.reportid | html %]" class="viewed btn btn-default btn-xs"><i class="fa fa-eye"></i> Mark viewed</button> <button name="closed" disabled="disabled" data-report_id="[% report.reportid | html %]" class="closed btn btn-default btn-xs"><i class="fa fa-times-circle"></i> Mark closed</button> <button name="new" data-report_id="[% report.reportid | html %]" class="new btn btn-default btn-xs"><i class="fa fa-star"></i> Mark new</button>
94                                         [% END %]
95                                     </td>
96                                 </tr>
97                             [% END %]
98                         </tbody>
99                     </table>
100
101                 </form>
102
103             [% ELSE %]
104                 <div class="dialog message">There are currently no problem reports.</div>
105             [% END %] <!-- problem reports -->
106
107             </main>
108         </div> <!-- /.col-sm-10.col-sm-push-2 -->
109
110         <div class="col-sm-2 col-sm-pull-10">
111             <aside>
112                 [% INCLUDE 'admin-menu.inc' %]
113             </aside>
114         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
115
116     </div> <!-- /.row -->
117
118 [% MACRO jsinclude BLOCK %]
119     [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
120     [% INCLUDE 'calendar.inc' %]
121     [% INCLUDE 'datatables.inc' %]
122     <script>
123         $(document).ready(function(){
124             $("#problemreportstable").dataTable($.extend(true, {}, dataTablesDefaults, {
125                 "order": [[ 1, "asc" ]],
126                 "aoColumnDefs": [
127                     { "orderable": false, "searchable": false, 'targets': [ 'NoSort' ] },
128                     { "type": "title-string", "targets" : [ "title-string" ] },
129                     { "type": "anti-the", "targets": [ "anti-the" ] }
130                 ],
131                 "pagingType": "full"
132             }));
133
134             $(".SelectAll").on("click", function(){
135                 $("input[name='report_ids'][type='checkbox']").prop("checked", true);
136                 $(".markviewed").prop("disabled", false);
137                 $(".markclosed").prop("disabled", false);
138                 $(".marknew").prop("disabled", false);
139             });
140
141             $(".ClearAll").on("click", function(){
142                 $("input[name='report_ids'][type='checkbox']").prop("checked", false);
143                 $(".markviewed").prop("disabled", true);
144                 $(".markclosed").prop("disabled", true);
145                 $(".marknew").prop("disabled", true);
146             });
147
148
149
150             $(".HideViewed").on("click", function(){
151                 $(".statusViewed").parent().hide();
152             });
153
154             $(".HideClosed").on("click", function(){
155                 $(".statusClosed").parent().hide();
156             });
157
158             $(".HideNew").on("click", function(){
159                 $(".statusNew").parent().hide();
160             });
161
162             $(".ShowAll").on("click", function(){
163                 $("tr").show();
164             });
165
166             $("#error").hide();
167
168             $("#problemreportstable").on("change", "input[type='checkbox']", function(){
169                 if ( $("input[type='checkbox']").is(":checked") ) {
170                     $(".markviewed").prop("disabled", false);
171                     $(".markclosed").prop("disabled", false);
172                     $(".marknew").prop("disabled", false);
173                 } else {
174                     $(".markviewed").prop("disabled", true);
175                     $(".markclosed").prop("disabled", true);
176                     $(".marknew").prop("disabled", true);
177                 }
178             });
179
180             $("#problemreportstable").on("click", "button.viewed, button.closed, button.new", function(event){
181                 event.preventDefault(); // prevent form submission
182                 var $action = $(this).attr("name");
183                 var $report_id = $(this).data('report_id');
184                 var ajaxData = {
185                     'action': $action,
186                     'report_id': $report_id,
187                 };
188
189                 $.ajax({
190                     url: '/cgi-bin/koha/svc/problem_reports/',
191                     type: 'POST',
192                     dataType: 'json',
193                     data: ajaxData,
194                 })
195
196                 .done(function(data){
197                     if (data.status == 'success'){
198                         if ( $action == 'viewed' ){
199                             $("#status_" + $report_id).text(_("Viewed"));
200                             $(event.target).parent().siblings("[name='status']").removeClass().addClass("statusViewed");
201                             $(event.target).siblings(".closed").prop("disabled", false);
202                             $(event.target).siblings(".new").prop("disabled", false);
203                             $(event.target).prop("disabled", true);
204                         } else if ( $action == 'new' ){
205                             $("#status_" + $report_id).text(_("New"));
206                             $(event.target).parent().siblings("[name='status']").removeClass().addClass("statusNew");
207                             $(event.target).siblings(".closed").prop("disabled", false);
208                             $(event.target).siblings(".viewed").prop("disabled", false);
209                             $(event.target).prop("disabled", true);
210                         } else {
211                             $("#status_" + $report_id).text(_("Closed"));
212                             $(event.target).parent().siblings("[name='status']").removeClass().addClass("statusClosed");
213                             $(event.target).siblings(".viewed").prop("disabled", false);
214                             $(event.target).siblings(".new").prop("disabled", false);
215                             $(event.target).prop("disabled", true);
216                         }
217                     } else {
218                         $("#error").text(_("Unable to change status of problem report."));
219                         $("#error").show();
220                     }
221                 })
222                 .error(function(data){
223                     $("#error").text(_("Unable to change status of problem report."));
224                     $("#error").show();
225                 });
226             });
227         });
228     </script>
229 [% END %]
230
231 [% INCLUDE 'intranet-bottom.inc' %]