View | Details | Raw Unified | Return to bug 17047
Collapse All | Expand All

(-)a/C4/Reports/Guided.pm (+1 lines)
Lines 33-38 use C4::Log; Link Here
33
33
34
use Koha::AuthorisedValues;
34
use Koha::AuthorisedValues;
35
use Koha::Patron::Categories;
35
use Koha::Patron::Categories;
36
use Koha::SharedContent;
36
37
37
BEGIN {
38
BEGIN {
38
    require Exporter;
39
    require Exporter;
(-)a/C4/Serials.pm (+6 lines)
Lines 278-283 sub GetSubscription { Link Here
278
    });
278
    });
279
    $subscription->{additional_fields} = $additional_field_values->{$subscriptionid};
279
    $subscription->{additional_fields} = $additional_field_values->{$subscriptionid};
280
280
281
    if ( my $mana_id = $subscription->{mana_id} ) {
282
        my $mana_subscription = Koha::SharedContent::manaGetRequestWithId(
283
            'subscription', $mana_id, {usecomments => 1});
284
        $subscription->{comments} = $mana_subscription->{data}->{comments};
285
    }
286
281
    return $subscription;
287
    return $subscription;
282
}
288
}
283
289
(-)a/Koha/SharedContent.pm (-3 / +9 lines)
Lines 78-86 sub manaIncrementRequest { Link Here
78
=cut
78
=cut
79
79
80
sub manaPostRequest {
80
sub manaPostRequest {
81
    my ($lang, $loggedinuser, $resourceid, $resourcetype) = @_;
81
    my ($lang, $loggedinuser, $resourceid, $resourcetype, $content) = @_;
82
82
83
    my $content = prepareSharedData($lang, $loggedinuser, $resourceid, $resourcetype);
83
    unless ( $content ) {
84
        $content = prepareSharedData($lang, $loggedinuser, $resourceid, $resourcetype);
85
    }
84
86
85
    my $result = manaRequest(buildRequest('post', $resourcetype, $content));
87
    my $result = manaRequest(buildRequest('post', $resourcetype, $content));
86
88
Lines 161-168 sub buildRequest { Link Here
161
163
162
    if ( $type eq 'getwithid' ) {
164
    if ( $type eq 'getwithid' ) {
163
        my $id = shift;
165
        my $id = shift;
166
        my $params = shift;
167
        $params = join '&',
168
            map { defined $params->{$_} ? $_ . "=" . $params->{$_} : () }
169
            keys %$params;
164
170
165
        my $url = "$MANA_IP/$resource/$id.json";
171
        my $url = "$MANA_IP/$resource/$id.json?$params";
166
        return HTTP::Request->new( GET => $url );
172
        return HTTP::Request->new( GET => $url );
167
    }
173
    }
168
174
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/mana.inc (+44 lines)
Line 0 Link Here
1
<script type="text/JavaScript">
2
//<![CDATA[
3
$(document).ready(function() {
4
    function mana_increment(mana_id, resource, fieldvalue, stepvalue = 1) {
5
        $.ajax( {
6
            type: "POST",
7
            url: "/cgi-bin/koha/svc/mana/increment",
8
            data: {id: mana_id, resource: resource, field: fieldvalue, step: stepvalue},
9
            datatype: "json",
10
        })
11
    }
12
13
    function mana_comment( target_id, manamsg, resource_type ) {
14
        $.ajax( {
15
            type: "POST",
16
            url: "/cgi-bin/koha/svc/mana/share",
17
            data: {message: manamsg, resource: resource_type , resource_id: target_id},
18
            datatype: "json",
19
        })
20
    }
21
22
    $(document).on('click', 'ul li.mana-comment', function() {
23
        id = $(this).attr('data-id');
24
        mana_increment(id, 'resource_comment', 'nb');
25
    });
26
27
    $(document).on('click', 'ul li.mana-other-comment', function() {
28
        $('#mana-comment-box').modal('show');
29
    });
30
31
    $(document).on('click', '#mana-send-comment', function() {
32
        var resource_type = $('#mana-resource').val();
33
        var resource_id = $('#mana-resource-id').val();
34
        var comment = $("#mana-comment").val();
35
        mana_comment(resource_id, comment, resource_type);
36
        $("#mana-comment-box").modal("hide");
37
    });
38
39
    $(document).on('click', '#mana-comment-close', function() {
40
        $("#mana-comment-box").modal("hide");
41
    });
42
});
43
//]]>
44
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-report-search-result.inc (-26 / +1 lines)
Lines 24-29 $(document).ready(function() { Link Here
24
});
24
});
25
//]]>
25
//]]>
26
</script>
26
</script>
27
[% INCLUDE 'mana.inc' %]
27
28
28
[% IF statuscode == "200" AND reports %]
29
[% IF statuscode == "200" AND reports %]
29
    <table id="mana_results_datatable" width=100%>
30
    <table id="mana_results_datatable" width=100%>
Lines 68-81 $(document).ready(function() { Link Here
68
                    [% UNLESS search_only %]
69
                    [% UNLESS search_only %]
69
                        <td>
70
                        <td>
70
                            <button class="mana-use" id="mana-use-[% report.id %]"><i class="fa fa-inbox"></i> Use</button>
71
                            <button class="mana-use" id="mana-use-[% report.id %]"><i class="fa fa-inbox"></i> Use</button>
71
                            <select class="mana-actions" id="mana-actions-[% report.id %]">
72
                                <option selected disabled>Report mistake</option>
73
                                [% FOREACH comment IN report.comments %]
74
                                    <option value="[% comment.id %]">[% comment.message %] ([% comment.nb %])</option>
75
                                [% END %]
76
                                    <option>other</option>
77
                            </select>
78
                            <button hidden class="actionreport2" hidden> Cancel</button>
79
                        </td>
72
                        </td>
80
                    [% END %]
73
                    [% END %]
81
                  </tr>
74
                  </tr>
Lines 86-106 $(document).ready(function() { Link Here
86
[% ELSE %]
79
[% ELSE %]
87
    <h4> [% msg %]  statuscode: [% statuscode %]</h4>
80
    <h4> [% msg %]  statuscode: [% statuscode %]</h4>
88
[% END %]
81
[% END %]
89
90
<div id="comment_box" class="modal" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="display: none;">
91
    <div class="modal-dialog modal-lg" style="width: 30%">
92
        <div class="modal-content" style="">
93
            <div class="modal-header">
94
                <button type="button" id="commentCloseButton" class="closebtn"  aria-hidden="true">×</button>
95
                <h3 id="mana_submit_comment"> Please enter a new commment (max 35 caracters)</h3>
96
            </div>
97
            <div class="modal-body">
98
                <form>
99
                    <input hidden id="selected_id" value="">
100
                    <input type="text" id="manamsg">
101
                </form>
102
                <button id="CommentButton"> Comment </button>
103
            </div>
104
        </div>
105
    </div>
106
</div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-subscription-search-result.inc (-12 / +1 lines)
Lines 2-8 Link Here
2
[% USE Koha %]
2
[% USE Koha %]
3
[% USE AuthorisedValues %]
3
[% USE AuthorisedValues %]
4
[% USE Branches %]
4
[% USE Branches %]
5
5
[% INCLUDE 'mana.inc' %]
6
<script type="text/javascript">
6
<script type="text/javascript">
7
//<![CDATA[
7
//<![CDATA[
8
$(document).ready(function() {
8
$(document).ready(function() {
Lines 10-26 $(document).ready(function() { Link Here
10
        id = $(this).attr('id');
10
        id = $(this).attr('id');
11
        mana_use(id.substr(9));
11
        mana_use(id.substr(9));
12
    });
12
    });
13
14
    $(document).on('change', 'select.mana-actions', function() {
15
        report_id = $(this).attr('id').substr(13);
16
        if ($(this).val() == 'other') {
17
            $('input#selected_id').val(report_id);
18
            $('#comment_box').modal('show');
19
        } else {
20
            comment_id = $(this).val();
21
            mana_increment(comment_id, 'resource_comment', 'nb');
22
        }
23
    });
24
});
13
});
25
//]]>
14
//]]>
26
</script>
15
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc (-31 / +35 lines)
Lines 1-4 Link Here
1
[% INCLUDE 'blocking_errors.inc' %]
1
[% INCLUDE 'blocking_errors.inc' %]
2
[% INCLUDE 'mana.inc' %]
2
<div id="toolbar" class="btn-toolbar">
3
<div id="toolbar" class="btn-toolbar">
3
    [% IF ( CAN_user_reports_create_reports ) %]
4
    [% IF ( CAN_user_reports_create_reports ) %]
4
        <div class="btn-group">
5
        <div class="btn-group">
Lines 50-55 Link Here
50
            </div>
51
            </div>
51
        [% END %]
52
        [% END %]
52
53
54
        [% IF ( mana_id && Koha.Preference('Mana') == 1 ) %]
55
            <div class="btn-group">
56
                <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"> Report mistake <span class="caret"></span></button>
57
                <ul class="dropdown-menu">
58
                    [% FOREACH c IN mana_comments %]
59
                        <li class="mana-comment" data-id="[% c.id %]">
60
                            <a href="#">[% c.message %] ([% c.nb %])</a>
61
                        </li>
62
                    [% END %]
63
                    <li role="separator" class="divider"></li>
64
                    <li class="mana-other-comment"><a href="#">Other</a> </li>
65
                </ul>
66
            </div>
67
68
            <div id="mana-comment-box" class="modal" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="display: none;">
69
                <div class="modal-dialog modal-lg" style="width: 30%">
70
                    <div class="modal-content" style="">
71
                        <div class="modal-header">
72
                            <button type="button" id="mana-comment-close" class="closebtn"  aria-hidden="true">×</button>
73
                            <h3 id="mana_submit_comment"> Please enter a new commment (max 35 caracters)</h3>
74
                        </div>
75
                        <div class="modal-body">
76
                            <input hidden id="mana-resource" value="report">
77
                            <input hidden id="mana-resource-id" value="[% mana_id %]">
78
                            <div>
79
                                <input type="text" maxlength="35" size="35" id="mana-comment">
80
                            </div>
81
                            <button id="mana-send-comment"> Comment </button>
82
                        </div>
83
                    </div>
84
                </div>
85
            </div>
86
        [% END %]
87
53
        [% IF ( execute ) %]
88
        [% IF ( execute ) %]
54
            [% BLOCK params %]
89
            [% BLOCK params %]
55
                [%- FOREACH param IN sql_params %]&amp;sql_params=[% param | uri %][% END %]
90
                [%- FOREACH param IN sql_params %]&amp;sql_params=[% param | uri %][% END %]
Lines 103-123 Link Here
103
        });
138
        });
104
    });
139
    });
105
140
106
    $('#search_form').on( "submit", function(event) {
107
        event.preventDefault();
108
        mana_search($(this).children("#mana_search_field").val());
109
    });
110
111
    function mana_increment(mana_id, resourcename, fieldvalue, stepvalue = 1){
112
        $.ajax( {
113
            type: "POST",
114
            url: "/cgi-bin/koha/svc/mana/increment",
115
            data: {id: mana_id, field: fieldvalue, resource: resourcename, step: stepvalue},
116
            datatype: "json",
117
        }).done( function() {
118
        }).fail( function(){ alert("") });
119
    }
120
121
    function mana_use( mana_id ){
141
    function mana_use( mana_id ){
122
        $.ajax( {
142
        $.ajax( {
123
            type:"POST",
143
            type:"POST",
Lines 165-177 Link Here
165
185
166
            $( "select[class='actionreport1']" ).show();
186
            $( "select[class='actionreport1']" ).show();
167
            $( "button[class='actionreport2']" ).hide();
187
            $( "button[class='actionreport2']" ).hide();
168
            $("#CommentButton").on("click", function(){
169
                var resource_type = "report";
170
                var target_id = $("#selected_id").val();
171
                var manamsg = $("#manamsg").val();
172
                mana_comment(target_id, manamsg, resource_type);
173
                $("#comment_box").modal("hide");
174
            });
175
188
176
            $(".showbutton").on("click", function(){
189
            $(".showbutton").on("click", function(){
177
                $(this).parent().hide();
190
                $(this).parent().hide();
Lines 201-213 Link Here
201
        }).fail( function( result ){
214
        }).fail( function( result ){
202
        });
215
        });
203
    }
216
    }
204
205
    function mana_comment( target_id, manamsg, resource_type ){
206
        $.ajax( {
207
            type: "POST",
208
            url: "/cgi-bin/koha/svc/mana/share",
209
            data: {message: manamsg, resource: resource_type , resource_id: target_id},
210
            datatype: "json",
211
        })
212
    }
213
</script>
217
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc (+35 lines)
Lines 1-4 Link Here
1
[% INCLUDE 'blocking_errors.inc' %]
1
[% INCLUDE 'blocking_errors.inc' %]
2
[% INCLUDE 'mana.inc' %]
2
<script type="text/javascript">
3
<script type="text/javascript">
3
    //<![CDATA[
4
    //<![CDATA[
4
5
Lines 99-104 Link Here
99
                [% END %]
100
                [% END %]
100
            [% END %]
101
            [% END %]
101
        [% END %]
102
        [% END %]
103
104
        [% IF ( mana_id && Koha.Preference('Mana') == 1 ) %]
105
            <div class="btn-group">
106
                <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"> Report mistake <span class="caret"></span></button>
107
                <ul class="dropdown-menu">
108
                    [% FOREACH c IN mana_comments %]
109
                        <li class="mana-comment" data-id="[% c.id %]">
110
                            <a href="#">[% c.message %] ([% c.nb %])</a>
111
                        </li>
112
                    [% END %]
113
                    <li role="separator" class="divider"></li>
114
                    <li class="mana-other-comment"><a href="#">Other</a> </li>
115
                </ul>
116
            </div>
117
118
            <div id="mana-comment-box" class="modal" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="display: none;">
119
                <div class="modal-dialog modal-lg" style="width: 30%">
120
                    <div class="modal-content" style="">
121
                        <div class="modal-header">
122
                            <button type="button" id="mana-comment-close" class="closebtn"  aria-hidden="true">×</button>
123
                            <h3 id="mana_submit_comment"> Please enter a new commment (max 35 caracters)</h3>
124
                        </div>
125
                        <div class="modal-body">
126
                            <input hidden id="mana-resource" value="subscription">
127
                            <input hidden id="mana-resource-id" value="[% mana_id %]">
128
                            <div>
129
                                <input type="text" maxlength="35" size="35" id="mana-comment">
130
                            </div>
131
                            <button id="mana-send-comment"> Comment </button>
132
                        </div>
133
                    </div>
134
                </div>
135
            </div>
136
        [% END %]
102
    </div>
137
    </div>
103
[% ELSIF CAN_user_serials_create_subscription %]
138
[% ELSIF CAN_user_serials_create_subscription %]
104
    <div id="toolbar" class="btn-toolbar">
139
    <div id="toolbar" class="btn-toolbar">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt (-20 lines)
Lines 125-150 canned reports and writing custom SQL reports.</p> Link Here
125
    </div>
125
    </div>
126
[% END %]
126
[% END %]
127
127
128
<div id="mana_search_result" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="width: 100%; left:0%; margin-left: auto; display: none;">
129
    <div class="modal-dialog modal-lg">
130
        <div class="modal-content">
131
            <div class="modal-header">
132
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
133
                <h3 id="mana_search_result_label"> Mana Search</h3>
134
            </div>
135
            <div>
136
                <form id="search_form" style="margin-left: 5%">
137
                    Please enter a few key words:
138
                    <input type=text id=mana_search_field>
139
                    <input type=button class="mana_search_button" value="Search">
140
                </form>
141
                <div class="modal-body">
142
                </div>
143
            </div>
144
        </div>
145
    </div>
146
</div>
147
148
[% IF report_converted %]
128
[% IF report_converted %]
149
    <div class="dialog message">
129
    <div class="dialog message">
150
        The report "[% report_converted %]" has been converted.
130
        The report "[% report_converted %]" has been converted.
(-)a/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js (-45 lines)
Lines 428-478 function mana_search() { Link Here
428
            $("#mana_search").html( result );
428
            $("#mana_search").html( result );
429
        }
429
        }
430
        $("#mana_search").show();
430
        $("#mana_search").show();
431
        $( "select[class='actionreport1']" ).show();
432
        $( "button[class='actionreport2']" ).hide();
433
434
        $("#CommentButton").on("click", function(){
435
            var resource_type = "subscription";
436
            var target_id = $("#selected_id").val();
437
            var manamsg = $("#manamsg").val();
438
            mana_comment(target_id, manamsg, resource_type);
439
            $("#comment_box").modal("hide");
440
        });
441
442
        $("#commentCloseButton").on("click", function(){
443
            $("#comment_box").modal("hide");
444
        });
445
446
        $(".actionreport1").on("click", function(){
447
            $("#selectedcomment").val($(this).val());
448
            $(this).parent("select").hide();
449
            $(this).parent("select").next().show();
450
        });
451
452
        $(".actionreport2").on("click", function(){
453
            $(this).hide();
454
            $(this).prev().show();
455
            mana_increment($("#selectedcomment").val(), 'resource_comment', 'nb', -1);
456
        });
457
458
    })
459
}
460
461
function mana_comment( target_id, manamsg, resource_type ){
462
    $.ajax( {
463
        type: "POST",
464
        url: "/cgi-bin/koha/svc/mana/share",
465
        data: {message: manamsg, resource: resource_type , resource_id: target_id},
466
        datatype: "json",
467
    })
468
}
469
470
function mana_increment(mana_id, resource, fieldvalue, stepvalue = 1){
471
    $.ajax( {
472
        type: "POST",
473
        url: "/cgi-bin/koha/svc/mana/increment",
474
        data: {id: mana_id, resource: resource, field: fieldvalue, step: stepvalue},
475
        datatype: "json",
476
    })
431
    })
477
}
432
}
478
433
(-)a/reports/guided_reports.pl (+4 lines)
Lines 184-189 elsif ( $phase eq 'Show SQL'){ Link Here
184
        'showsql' => 1,
184
        'showsql' => 1,
185
        'mana_success' => $input->param('mana_success'),
185
        'mana_success' => $input->param('mana_success'),
186
        'mana_success' => scalar $input->param('mana_success'),
186
        'mana_success' => scalar $input->param('mana_success'),
187
        'mana_id' => $report->{mana_id},
188
        'mana_comments' => $report->{comments}
187
    );
189
    );
188
}
190
}
189
191
Lines 202-207 elsif ( $phase eq 'Edit SQL'){ Link Here
202
        'public' => $report->public,
204
        'public' => $report->public,
203
        'usecache' => $usecache,
205
        'usecache' => $usecache,
204
        'editsql'    => 1,
206
        'editsql'    => 1,
207
        'mana_id' => $report->{mana_id},
208
        'mana_comments' => $report->{comments}
205
    );
209
    );
206
}
210
}
207
211
(-)a/serials/subscription-detail.pl (+1 lines)
Lines 153-158 $template->param( Link Here
153
    default_bib_view => $default_bib_view,
153
    default_bib_view => $default_bib_view,
154
    orders => $orders,
154
    orders => $orders,
155
    (uc(C4::Context->preference("marcflavour"))) => 1,
155
    (uc(C4::Context->preference("marcflavour"))) => 1,
156
    mana_comments => $subs->{comments},
156
);
157
);
157
158
158
output_html_with_http_headers $query, $cookie, $template->output;
159
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/svc/mana/share (-2 / +1 lines)
Lines 44-50 my $content; Link Here
44
$content->{resource_id} = $input->param("resource_id");
44
$content->{resource_id} = $input->param("resource_id");
45
$content->{resource_type} = $input->param("resource");
45
$content->{resource_type} = $input->param("resource");
46
$content->{message} = $input->param("message");
46
$content->{message} = $input->param("message");
47
Koha::SharedContent::manaPostRequest('resource_comment', $content);
47
Koha::SharedContent::manaPostRequest('', undef, undef, 'resource_comment', $content);
48
my $package = "Koha::".ucfirst($input->param('resource'));
48
my $package = "Koha::".ucfirst($input->param('resource'));
49
my $resource;
49
my $resource;
50
my $result;
50
my $result;
51
- 

Return to bug 17047