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 280-285 sub GetSubscription { Link Here
280
    });
280
    });
281
    $subscription->{additional_fields} = $additional_field_values->{$subscriptionid};
281
    $subscription->{additional_fields} = $additional_field_values->{$subscriptionid};
282
282
283
    if ( my $mana_id = $subscription->{mana_id} ) {
284
        my $mana_subscription = Koha::SharedContent::manaGetRequestWithId(
285
            'subscription', $mana_id, {usecomments => 1});
286
        $subscription->{comments} = $mana_subscription->{data}->{comments};
287
    }
288
283
    return $subscription;
289
    return $subscription;
284
}
290
}
285
291
(-)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 110-130 Link Here
110
        });
145
        });
111
    });
146
    });
112
147
113
    $('#search_form').on( "submit", function(event) {
114
        event.preventDefault();
115
        mana_search($(this).children("#mana_search_field").val());
116
    });
117
118
    function mana_increment(mana_id, resourcename, fieldvalue, stepvalue = 1){
119
        $.ajax( {
120
            type: "POST",
121
            url: "/cgi-bin/koha/svc/mana/increment",
122
            data: {id: mana_id, field: fieldvalue, resource: resourcename, step: stepvalue},
123
            datatype: "json",
124
        }).done( function() {
125
        }).fail( function(){ alert("") });
126
    }
127
128
    function mana_use( mana_id ){
148
    function mana_use( mana_id ){
129
        $.ajax( {
149
        $.ajax( {
130
            type:"POST",
150
            type:"POST",
Lines 172-184 Link Here
172
192
173
            $( "select[class='actionreport1']" ).show();
193
            $( "select[class='actionreport1']" ).show();
174
            $( "button[class='actionreport2']" ).hide();
194
            $( "button[class='actionreport2']" ).hide();
175
            $("#CommentButton").on("click", function(){
176
                var resource_type = "report";
177
                var target_id = $("#selected_id").val();
178
                var manamsg = $("#manamsg").val();
179
                mana_comment(target_id, manamsg, resource_type);
180
                $("#comment_box").modal("hide");
181
            });
182
195
183
            $(".showbutton").on("click", function(){
196
            $(".showbutton").on("click", function(){
184
                $(this).parent().hide();
197
                $(this).parent().hide();
Lines 208-220 Link Here
208
        }).fail( function( result ){
221
        }).fail( function( result ){
209
        });
222
        });
210
    }
223
    }
211
212
    function mana_comment( target_id, manamsg, resource_type ){
213
        $.ajax( {
214
            type: "POST",
215
            url: "/cgi-bin/koha/svc/mana/share",
216
            data: {message: manamsg, resource: resource_type , resource_id: target_id},
217
            datatype: "json",
218
        })
219
    }
220
</script>
224
</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 135-160 canned reports and writing custom SQL reports.</p> Link Here
135
    </div>
135
    </div>
136
[% END %]
136
[% END %]
137
137
138
<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;">
139
    <div class="modal-dialog modal-lg">
140
        <div class="modal-content">
141
            <div class="modal-header">
142
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
143
                <h3 id="mana_search_result_label"> Mana Search</h3>
144
            </div>
145
            <div>
146
                <form id="search_form" style="margin-left: 5%">
147
                    Please enter a few key words:
148
                    <input type=text id=mana_search_field>
149
                    <input type=button class="mana_search_button" value="Search">
150
                </form>
151
                <div class="modal-body">
152
                </div>
153
            </div>
154
        </div>
155
    </div>
156
</div>
157
158
[% IF report_converted %]
138
[% IF report_converted %]
159
    <div class="dialog message">
139
    <div class="dialog message">
160
        The report "[% report_converted %]" has been converted.
140
        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 171-176 $template->param( Link Here
171
    default_bib_view => $default_bib_view,
171
    default_bib_view => $default_bib_view,
172
    orders_grouped => $orders_grouped,
172
    orders_grouped => $orders_grouped,
173
    (uc(C4::Context->preference("marcflavour"))) => 1,
173
    (uc(C4::Context->preference("marcflavour"))) => 1,
174
    mana_comments => $subs->{comments},
174
);
175
);
175
176
176
output_html_with_http_headers $query, $cookie, $template->output;
177
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