Bug 15774: Add permission for managing additional fields
[srvgit] / koha-tmpl / intranet-tmpl / prog / en / includes / reports-toolbar.inc
1 [% INCLUDE 'blocking_errors.inc' %]
2 <div id="toolbar" class="btn-toolbar">
3     [% IF ( CAN_user_reports_create_reports ) %]
4         <div class="btn-group">
5             <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"><i class="fa fa-plus"></i> New report <span class="caret"></span></button>
6             <ul class="dropdown-menu">
7                 <li id="newmenuc"><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new">New guided report</a> </li>
8                 <li id="newsql"><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Create%20report%20from%20SQL">New SQL report</a> </li>
9                 [% IF Koha.Preference('Mana')==1 %]
10                 <li id="newsql"><a href="" data-toggle="modal" data-target="#mana_search_result">New SQL from Mana</a> </li>
11                 [% END %]
12             </ul>
13         </div>
14     [% END %]
15
16     [% IF ( showsql || execute || editsql || save_successful ) %]
17         [% IF ( CAN_user_reports_create_reports ) %]
18             [% UNLESS ( editsql ) # Do not show edit button on edit page %]
19                 <div class="btn-group">
20                     <a id="editreport" class="btn btn-default btn-sm" href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% id | html %]&amp;phase=Edit%20SQL">
21                         <i class="fa fa-pencil"></i> Edit
22                     </a>
23                 </div>
24             [% END %]
25             <div class="btn-group">
26                 <a class="btn btn-default btn-sm" title="Duplicate this saved report" href="/cgi-bin/koha/reports/guided_reports.pl?phase=Create report from SQL&amp;sql=[% original_sql || sql |uri %]&amp;reportname=[% reportname |uri %]&amp;notes=[% notes |uri %]">
27                     <i class="fa fa-copy"></i> Duplicate
28                 </a>
29             </div>
30         [% END %]
31
32         [% IF ( CAN_user_reports_delete_reports ) %]
33             <div class="btn-group">
34                 <a class="delete btn btn-default btn-sm" href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% id | html %]&phase=Delete%20Saved">
35                     <i class="fa fa-trash"></i> Delete
36                 </a>
37             </div>
38         [% END %]
39
40         [% UNLESS ( errors ) # Unless there are errors saving a report %]
41             <div class="btn-group">
42                 <a id="runreport" class="btn btn-default btn-sm" href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% id | html %]&amp;phase=Run%20this%20report">
43                     <i class="fa fa-play"></i> Run report
44                 </a>
45             </div>
46             <div class="btn-group">
47                 <a class="btn btn-default btn-sm" href="/cgi-bin/koha/tools/scheduler.pl?id=[% id | html %]">
48                     <i class="fa fa-clock-o"></i> Schedule
49                 </a>
50             </div>
51         [% END %]
52
53         [% IF ( mana_id && Koha.Preference('Mana') == 1 ) %]
54             <div class="btn-group">
55                 <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"> Report mistake <span class="caret"></span></button>
56                 <ul class="dropdown-menu">
57                     [% FOREACH c IN mana_comments %]
58                         <li class="mana-comment" data-id="[% c.id | $raw %]">
59                             <a href="#">[% c.message | html %] ([% c.nb | html %])</a>
60                         </li>
61                     [% END %]
62                     <li role="separator" class="divider"></li>
63                     <li class="mana-other-comment"><a href="#">Other</a> </li>
64                 </ul>
65             </div>
66
67             <div id="mana-comment-box" class="modal" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="display: none;">
68                 <div class="modal-dialog modal-lg" style="width: 30%">
69                     <div class="modal-content" style="">
70                         <div class="modal-header">
71                             <button type="button" id="mana-comment-close" class="closebtn"  aria-hidden="true">×</button>
72                             <h3 id="mana_submit_comment"> Please enter a new commment (max 35 caracters)</h3>
73                         </div>
74                         <div class="modal-body">
75                             <input hidden id="mana-resource" value="report">
76                             <input hidden id="mana-resource-id" value="[% mana_id | $raw %]">
77                             <div>
78                                 <input type="text" maxlength="35" size="35" id="mana-comment">
79                             </div>
80                             <button id="mana-send-comment"> Comment </button>
81                         </div>
82                     </div>
83                 </div>
84             </div>
85         [% END %]
86
87         [% IF ( execute ) %]
88             [% BLOCK params %]
89                 [%- FOREACH param IN sql_params %]&amp;sql_params=[% param | uri %][% END %]
90                     [%- FOREACH param_name IN param_names %]&amp;param_name=[% param_name | uri %][% END %]
91             [%- END %]
92
93
94             <div class="btn-group">
95                 <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown" id="format"><i class="fa fa-upload"></i> Download <span class="caret"></span></button>
96                 <ul class="dropdown-menu">
97                     <li><a id="csv" href="/cgi-bin/koha/reports/guided_reports.pl?reports=1&phase=Export&amp;format=csv&amp;report_id=[% id | html %]&amp;reportname=[% name |uri %][% PROCESS params %]">[% PROCESS 'delimiter_text.inc' %]</a></li>
98                     <li><a id="tab" href="/cgi-bin/koha/reports/guided_reports.pl?reports=1&phase=Export&amp;format=tab&amp;report_id=[% id | html %]&amp;reportname=[% name |uri %][% PROCESS params %]">Tab separated text</a></li>
99                     <li><a id="ods" href="/cgi-bin/koha/reports/guided_reports.pl?reports=1&phase=Export&amp;format=ods&amp;report_id=[% id | html %]&amp;reportname=[% name |uri %][% PROCESS params %]">Open Document Spreadsheet</a></li>
100                     [% IF (results.json) %]
101                         <li><a id="download-chart" href="#">Chart (.svg)</a></li>
102                     [% END %]
103                 </ul>
104             </div>
105             <div class="btn-group">
106                 <a class="btn btn-default btn-sm toggle_sql" id="toggle_sql_hid" href="#"><i class="fa fa-eye"></i> Show SQL code</a>
107                 <a class="btn btn-default btn-sm toggle_sql" id="toggle_sql_vis" href="#" style="display:none;"><i class="fa fa-eye-slash"></i> Hide SQL code</a>
108             </div>
109             <div class="btn-group">
110                 <a class="btn btn-default btn-sm" href="#" data-toggle="modal" data-target="#chartModal"><i class="fa fa-bar-chart"></i> Create chart</a>
111             </div>
112         [% END %]
113
114     [% END %]
115 </div>
116
117 [% IF Koha.Preference('Mana')==1 %]
118     <div id="mana_search_result" class="modal fade container-fluid" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="width: 100%; left:0%; margin-left: auto; display: none;">
119         <div class="modal-dialog modal-lg">
120             <div class="modal-content">
121                 <div class="modal-header">
122                     <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
123                     <h3 id="mana_search_result_label"> Mana Search</h3>
124                 </div>
125                 <div>
126                     <div class="modal-body">
127                         <fieldset>
128                             <form id="mana_search_form" style="margin-left: 5%">
129                                 Please enter a few key words:
130                                 <input type="text" id="mana_search_field">
131                                 <input type="submit" class="mana_search_button" value="Search">
132                             </form>
133                         </fieldset>
134                         <div class="mana_result_content">
135                         </div>
136                     </div>
137                 </div>
138             </div>
139         </div>
140     </div>
141 [% END %]
142
143 <script>
144     function mana_use( mana_id ){
145         $.ajax( {
146             type:"POST",
147             url: "/cgi-bin/koha/svc/mana/use",
148             data: {id:mana_id, resource: 'report', saveinbase: 1},
149             dataType: "json",
150         })
151         .done( function (result){
152             if ( result.errmsg ){
153                 alert( result.errmsg );
154             }
155             else{
156                 window.location = ("/cgi-bin/koha/reports/guided_reports.pl?reports=").concat(result.id).concat("&amp;phase=Show%20SQL&mana_success=1&phase=Edit%20SQL");
157             }
158         })
159         .fail( function ( foo, msg, longmsg, bla ){
160         });
161     }
162
163     function mana_search( textquery ){
164         $(document.body).css({'cursor' : 'wait'});
165         $.ajax({
166             type: "POST",
167             url: "/cgi-bin/koha/svc/mana/search",
168             data: {biblionumber: $("#biblionumber").val(), resource: 'report', id: textquery, usecomments: 1},
169             dataType: "html",
170         })
171         .done( function( result ) {
172             $(document.body).css({'cursor' : 'default'});
173             $("#mana_search_result .modal-body .mana_result_content").html(result);
174             $("#mana_search_result_label").text(_("Results from Mana Knowledge Base"));
175             $("#mana_results_datatable").dataTable($.extend(true, {}, dataTablesDefaults,{
176                 "sPaginationType":"four_button",
177                 "autoWidth": false,
178                 "columnDefs": [
179                     { "width": "35%", "targets": 1 }
180                 ],
181                 "aoColumnDefs": [
182                     { 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
183                     { "sType": "title-string", "aTargets" : [ "title-string" ] },
184                     { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] }
185                 ]
186             }));
187             if($("td.dataTables_empty").length == 0){
188                  $("#mana_search").show();
189             }
190
191             $( "select[class='actionreport1']" ).show();
192             $( "button[class='actionreport2']" ).hide();
193
194             $(".showbutton").on("click", function(){
195                 $(this).parent().hide();
196                 $(this).parent().next().show();
197             });
198
199             $("a[class='hidebutton']").on("click", function(){
200                 $(this).parent().hide();
201                 $(this).parent().prev().show();
202             });
203
204             $("#commentCloseButton").on("click", function(){
205                 $("#comment_box").modal("hide");
206             });
207
208             $(".actionreport1").on("click", function(){
209                 $("#selectedcomment").val($(this).val());
210                 $(this).parent("select").hide();
211                 $(this).parent("select").next().show();
212             });
213
214             $(".actionreport2").on("click", function(){
215                 $(this).hide();
216                 $(this).prev().show();
217                 mana_increment($("#selectedcomment").val(), 'resource_comment', 'nb', -1);
218             });
219         }).fail( function( result ){
220         });
221     }
222 </script>